aboutsummaryrefslogtreecommitdiff
path: root/testsuite/uniq.tests
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/uniq.tests')
-rwxr-xr-xtestsuite/uniq.tests25
1 files changed, 12 insertions, 13 deletions
diff --git a/testsuite/uniq.tests b/testsuite/uniq.tests
index 95764740b..a1b69c2e5 100755
--- a/testsuite/uniq.tests
+++ b/testsuite/uniq.tests
@@ -6,7 +6,6 @@
6 6
7# AUDIT: Full SUSv3 coverage (except internationalization). 7# AUDIT: Full SUSv3 coverage (except internationalization).
8 8
9if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi
10. testing.sh 9. testing.sh
11 10
12# testing "test name" "options" "expected result" "file input" "stdin" 11# testing "test name" "options" "expected result" "file input" "stdin"
@@ -15,25 +14,25 @@ if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi
15 14
16# Test exit status 15# Test exit status
17 16
18testing "uniq (exit with error)" "nonexistent 2> /dev/null || echo yes" \ 17testing "uniq (exit with error)" "uniq nonexistent 2> /dev/null || echo yes" \
19 "yes\n" "" "" 18 "yes\n" "" ""
20testing "uniq (exit success)" "/dev/null && echo yes" "yes\n" "" "" 19testing "uniq (exit success)" "uniq /dev/null && echo yes" "yes\n" "" ""
21 20
22# Test various data sources and destinations 21# Test various data sources and destinations
23 22
24testing "uniq (default to stdin)" "" "one\ntwo\nthree\n" "" \ 23testing "uniq (default to stdin)" "uniq" "one\ntwo\nthree\n" "" \
25 "one\ntwo\ntwo\nthree\nthree\nthree\n" 24 "one\ntwo\ntwo\nthree\nthree\nthree\n"
26testing "uniq - (specify stdin)" "-" "one\ntwo\nthree\n" "" \ 25testing "uniq - (specify stdin)" "uniq -" "one\ntwo\nthree\n" "" \
27 "one\ntwo\ntwo\nthree\nthree\nthree\n" 26 "one\ntwo\ntwo\nthree\nthree\nthree\n"
28testing "uniq input (specify file)" "input" "one\ntwo\nthree\n" \ 27testing "uniq input (specify file)" "uniq input" "one\ntwo\nthree\n" \
29 "one\ntwo\ntwo\nthree\nthree\nthree\n" "" 28 "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
30 29
31testing "uniq input outfile (two files)" "input actual > /dev/null" \ 30testing "uniq input outfile (two files)" "uniq input actual > /dev/null" \
32 "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" "" 31 "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
33testing "uniq (stdin) outfile" "- actual" \ 32testing "uniq (stdin) outfile" "uniq - actual" \
34 "one\ntwo\nthree\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" 33 "one\ntwo\nthree\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n"
35# Note: SUSv3 doesn't seem to require support for "-" output, but we do anyway. 34# Note: SUSv3 doesn't seem to require support for "-" output, but we do anyway.
36testing "uniq input - (specify stdout)" "input -" \ 35testing "uniq input - (specify stdout)" "uniq input -" \
37 "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" "" 36 "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
38 37
39 38
@@ -47,13 +46,13 @@ testing "uniq input - (specify stdout)" "input -" \
47 46
48# Leading whitespace is a minor technical violation of the spec, 47# Leading whitespace is a minor technical violation of the spec,
49# but since gnu does it... 48# but since gnu does it...
50testing "uniq -c (occurrence count)" "-c | sed 's/^[ \t]*//'" \ 49testing "uniq -c (occurrence count)" "uniq -c | sed 's/^[ \t]*//'" \
51 "1 one\n2 two\n3 three\n" "" \ 50 "1 one\n2 two\n3 three\n" "" \
52 "one\ntwo\ntwo\nthree\nthree\nthree\n" 51 "one\ntwo\ntwo\nthree\nthree\nthree\n"
53testing "uniq -d (dups only) " "-d" "two\nthree\n" "" \ 52testing "uniq -d (dups only) " "uniq -d" "two\nthree\n" "" \
54 "one\ntwo\ntwo\nthree\nthree\nthree\n" 53 "one\ntwo\ntwo\nthree\nthree\nthree\n"
55 54
56testing "uniq -f -s (skip fields and chars)" "-f2 -s 3" \ 55testing "uniq -f -s (skip fields and chars)" "uniq -f2 -s 3" \
57"cc dd ee8 56"cc dd ee8
58aa bb cc9 57aa bb cc9
59" "" \ 58" "" \
@@ -65,7 +64,7 @@ aa bb cc9
65# -d is "Suppress the writing fo lines that are not repeated in the input." 64# -d is "Suppress the writing fo lines that are not repeated in the input."
66# -u is "Suppress the writing of lines that are repeated in the input." 65# -u is "Suppress the writing of lines that are repeated in the input."
67# Therefore, together this means they should produce no output. 66# Therefore, together this means they should produce no output.
68testing "uniq -u and -d produce no output" "-d -u" "" "" \ 67testing "uniq -u and -d produce no output" "uniq -d -u" "" "" \
69 "one\ntwo\ntwo\nthree\nthree\nthree\n" 68 "one\ntwo\ntwo\nthree\nthree\nthree\n"
70 69
71exit $FAILCOUNT 70exit $FAILCOUNT