xref: /freebsd/usr.bin/cut/tests/cut2_test.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1*acdd2b1cSEnji Cooper#
2*acdd2b1cSEnji Cooper# Copyright (c) 2017 Dell EMC
3*acdd2b1cSEnji Cooper# All rights reserved.
4*acdd2b1cSEnji Cooper#
5*acdd2b1cSEnji Cooper# Redistribution and use in source and binary forms, with or without
6*acdd2b1cSEnji Cooper# modification, are permitted provided that the following conditions
7*acdd2b1cSEnji Cooper# are met:
8*acdd2b1cSEnji Cooper# 1. Redistributions of source code must retain the above copyright
9*acdd2b1cSEnji Cooper#    notice, this list of conditions and the following disclaimer.
10*acdd2b1cSEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright
11*acdd2b1cSEnji Cooper#    notice, this list of conditions and the following disclaimer in the
12*acdd2b1cSEnji Cooper#    documentation and/or other materials provided with the distribution.
13*acdd2b1cSEnji Cooper#
14*acdd2b1cSEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*acdd2b1cSEnji Cooper# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*acdd2b1cSEnji Cooper# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*acdd2b1cSEnji Cooper# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*acdd2b1cSEnji Cooper# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*acdd2b1cSEnji Cooper# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*acdd2b1cSEnji Cooper# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*acdd2b1cSEnji Cooper# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*acdd2b1cSEnji Cooper# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*acdd2b1cSEnji Cooper# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*acdd2b1cSEnji Cooper# SUCH DAMAGE.
25*acdd2b1cSEnji Cooper#
26*acdd2b1cSEnji Cooper
27*acdd2b1cSEnji Cooperatf_test_case s_flag
28*acdd2b1cSEnji Coopers_flag_head()
29*acdd2b1cSEnji Cooper{
30*acdd2b1cSEnji Cooper	atf_set "descr" "Check -s flag"
31*acdd2b1cSEnji Cooper}
32*acdd2b1cSEnji Cooper
33*acdd2b1cSEnji Coopers_flag_body()
34*acdd2b1cSEnji Cooper{
35*acdd2b1cSEnji Cooper	cat >input<<EOF
36*acdd2b1cSEnji Coopera,b,c,d
37*acdd2b1cSEnji Cooperb,c,d
38*acdd2b1cSEnji Cooperc,d
39*acdd2b1cSEnji Cooperd
40*acdd2b1cSEnji CooperEOF
41*acdd2b1cSEnji Cooper	atf_check -o inline:'a\nb\nc\n' cut -d, -f 1 -s < input
42*acdd2b1cSEnji Cooper	atf_check -o inline:'d\n\n\n' cut -d, -f 4 -s < input
43*acdd2b1cSEnji Cooper	atf_check -o inline:'a,b,\nb,\n\n' cut -d 'c' -f 1 -s < input
44*acdd2b1cSEnji Cooper	atf_check -o empty cut -d'!' -f 1 -s < input
45*acdd2b1cSEnji Cooper}
46*acdd2b1cSEnji Cooper
47*acdd2b1cSEnji Cooperatf_init_test_cases()
48*acdd2b1cSEnji Cooper{
49*acdd2b1cSEnji Cooper	atf_add_test_case s_flag
50*acdd2b1cSEnji Cooper}
51