No empty .Rs/.Re
[netbsd-mini2440.git] / tests / util / cut / t_cut.sh
blob81763174e2bbee8fd40a32318fc0c87908a8a784
1 # $NetBSD$
3 # Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
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.
28 h_run()
30 file="${1}"; shift
31 opts="${*}"
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"
38 done
41 h_check()
43 diff -Nru "$1" "$2" || atf_fail "files $1 and $2 differ"
46 atf_test_case basic
47 basic_head()
49 atf_set "descr" "Checks basic functionality"
51 basic_body()
53 h_run "$(atf_get_srcdir)/d_cut.in" > out
54 h_check out "$(atf_get_srcdir)/d_basic.out"
57 atf_test_case sflag
58 sflag_head()
60 atf_set "descr" "Checks -s flag"
62 sflag_body()
64 h_run "$(atf_get_srcdir)/d_cut.in" -s > out
65 h_check out "$(atf_get_srcdir)/d_sflag.out"
68 atf_test_case dflag
69 dflag_head()
71 atf_set "descr" "Checks -d flag"
73 dflag_body()
75 h_run "$(atf_get_srcdir)/d_cut.in" -d ":" > out
76 h_check out "$(atf_get_srcdir)/d_dflag.out"
79 atf_test_case dsflag
80 dsflag_head()
82 atf_set "descr" "Checks -s and -d flags combined"
84 dsflag_body()
86 h_run "$(atf_get_srcdir)/d_cut.in" -d ":" -s > out
87 h_check out "$(atf_get_srcdir)/d_dsflag.out"
90 atf_test_case latin1
91 latin1_head()
93 atf_set "descr" "Checks support for non-ascii characters"
95 latin1_body()
97 export LC_ALL=C
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"
106 atf_test_case utf8
107 utf8_head()
109 atf_set "descr" "Checks support for multibyte characters"
111 utf8_body()
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