3 # Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
33 for fields
in 1 2 3 1-2 2,3 4 1-3,4-7 1,2-7
35 opts
="-f ${fields} $@"
36 echo "----- test: cut ${opts} $(basename $file) -----"
37 cut
$opts "$file" || atf_fail
"command failed: cut ${opts} $file"
43 diff -Nru "$1" "$2" || atf_fail
"files $1 and $2 differ"
49 atf_set
"descr" "Checks basic functionality"
53 h_run
"$(atf_get_srcdir)/d_cut.in" > out
54 h_check out
"$(atf_get_srcdir)/d_basic.out"
60 atf_set
"descr" "Checks -s flag"
64 h_run
"$(atf_get_srcdir)/d_cut.in" -s > out
65 h_check out
"$(atf_get_srcdir)/d_sflag.out"
71 atf_set
"descr" "Checks -d flag"
75 h_run
"$(atf_get_srcdir)/d_cut.in" -d ":" > out
76 h_check out
"$(atf_get_srcdir)/d_dflag.out"
82 atf_set
"descr" "Checks -s and -d flags combined"
86 h_run
"$(atf_get_srcdir)/d_cut.in" -d ":" -s > out
87 h_check out
"$(atf_get_srcdir)/d_dsflag.out"
93 atf_set
"descr" "Checks support for non-ascii characters"
99 atf_check
-o inline
:"bar\nBar\nBAr\nBAR\n" \
100 cut
-b 6,7,8 "$(atf_get_srcdir)/d_latin1.in"
102 atf_check
-o inline
:"bar\nBar\nBAr\nBAR\n" \
103 cut
-c 6,7,8 "$(atf_get_srcdir)/d_latin1.in"
109 atf_set
"descr" "Checks support for multibyte characters"
113 export LC_ALL
=en_US.UTF-8
115 atf_check
-o inline
:":ba\n:Ba\n:BA\n:BA\n" \
116 cut
-b 6,7,8 "$(atf_get_srcdir)/d_utf8.in"
118 atf_check
-o inline
:"bar\nBar\nBAr\nBAR\n" \
119 cut
-c 6,7,8 "$(atf_get_srcdir)/d_utf8.in"
122 atf_init_test_cases
()
124 atf_add_test_case basic
125 atf_add_test_case sflag
126 atf_add_test_case dflag
127 atf_add_test_case dsflag
128 atf_add_test_case latin1
129 atf_add_test_case utf8