aboutsummaryrefslogtreecommitdiff
path: root/testsuite/uniq.tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-09-14 14:36:40 +0000
committerRob Landley <rob@landley.net>2005-09-14 14:36:40 +0000
commit1e51925684d45b65cc0ed1f3e25a0ef52c82c471 (patch)
tree99ddbff9687bbc99ca247d53e99df30afa13c593 /testsuite/uniq.tests
parentdb485cf7bce5cccaa9516377279aeee9f87c391b (diff)
downloadbusybox-w32-1e51925684d45b65cc0ed1f3e25a0ef52c82c471.tar.gz
busybox-w32-1e51925684d45b65cc0ed1f3e25a0ef52c82c471.tar.bz2
busybox-w32-1e51925684d45b65cc0ed1f3e25a0ef52c82c471.zip
Test full susv3 spec for uniq (except internationalization).
I think this covers it. We fail two corner cases, both of which are explicit violations of the spec, and both of which gnu passes.
Diffstat (limited to 'testsuite/uniq.tests')
-rwxr-xr-xtestsuite/uniq.tests61
1 files changed, 48 insertions, 13 deletions
diff --git a/testsuite/uniq.tests b/testsuite/uniq.tests
index dc37d0a32..95764740b 100755
--- a/testsuite/uniq.tests
+++ b/testsuite/uniq.tests
@@ -4,33 +4,68 @@
4# Copyright 2005 by Rob Landley <rob@landley.net> 4# Copyright 2005 by Rob Landley <rob@landley.net>
5# Licensed under GPL v2, see file LICENSE for details. 5# Licensed under GPL v2, see file LICENSE for details.
6 6
7# AUDIT: Not full coverage of the spec yet. 7# AUDIT: Full SUSv3 coverage (except internationalization).
8 8
9if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi 9if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi
10. testing.sh 10. testing.sh
11 11
12# The basic tests. These should work even with the small busybox. 12# testing "test name" "options" "expected result" "file input" "stdin"
13#-f skip fields 13# file input will be file called "input"
14#-s skip chars 14# test can create a file "actual" instead of writing to stdout
15#-c occurrences 15
16#-d dups only 16# Test exit status
17#-u 17
18testing "uniq (exit with error)" "nonexistent 2> /dev/null || echo yes" \
19 "yes\n" "" ""
20testing "uniq (exit success)" "/dev/null && echo yes" "yes\n" "" ""
21
22# Test various data sources and destinations
23
18testing "uniq (default to stdin)" "" "one\ntwo\nthree\n" "" \ 24testing "uniq (default to stdin)" "" "one\ntwo\nthree\n" "" \
19 "one\ntwo\ntwo\nthree\nthree\nthree\n" 25 "one\ntwo\ntwo\nthree\nthree\nthree\n"
20testing "uniq - (specify stdin)" "-" "one\ntwo\nthree\n" "" \ 26testing "uniq - (specify stdin)" "-" "one\ntwo\nthree\n" "" \
21 "one\ntwo\ntwo\nthree\nthree\nthree\n" 27 "one\ntwo\ntwo\nthree\nthree\nthree\n"
22testing "uniq input (specify file)" "input" "one\ntwo\nthree\n" \ 28testing "uniq input (specify file)" "input" "one\ntwo\nthree\n" \
23 "one\ntwo\ntwo\nthree\nthree\nthree\n" "" 29 "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
30
24testing "uniq input outfile (two files)" "input actual > /dev/null" \ 31testing "uniq input outfile (two files)" "input actual > /dev/null" \
25 "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" "" 32 "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
26#testing "uniq - outfile" "- outfile" "one\ntwo\nthree\n" \ 33testing "uniq (stdin) outfile" "- actual" \
27# "one\ntwo\ntwo\nthree\nthree\nthree\n" "" 34 "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.
36testing "uniq input - (specify stdout)" "input -" \
37 "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
28 38
29testing "uniq -d" "-d" "two\nthree\n" "" \ 39
40#-f skip fields
41#-s skip chars
42#-c occurrences
43#-d dups only
44#-u
45
46# Test various command line options
47
48# Leading whitespace is a minor technical violation of the spec,
49# but since gnu does it...
50testing "uniq -c (occurrence count)" "-c | sed 's/^[ \t]*//'" \
51 "1 one\n2 two\n3 three\n" "" \
52 "one\ntwo\ntwo\nthree\nthree\nthree\n"
53testing "uniq -d (dups only) " "-d" "two\nthree\n" "" \
30 "one\ntwo\ntwo\nthree\nthree\nthree\n" 54 "one\ntwo\ntwo\nthree\nthree\nthree\n"
31testing "uniq -c" "-c" " 1 one\n 2 two\n 3 three\n" "" \ 55
56testing "uniq -f -s (skip fields and chars)" "-f2 -s 3" \
57"cc dd ee8
58aa bb cc9
59" "" \
60"cc dd ee8
61bb cc dd8
62aa bb cc9
63"
64
65# -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."
67# Therefore, together this means they should produce no output.
68testing "uniq -u and -d produce no output" "-d -u" "" "" \
32 "one\ntwo\ntwo\nthree\nthree\nthree\n" 69 "one\ntwo\ntwo\nthree\nthree\nthree\n"
33# testing "uniq -c -d"
34# testing "uniq infile"
35 70
36exit $FAILCOUNT 71exit $FAILCOUNT