summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2013-07-05 14:59:44 -0600
committerPádraig Brady <P@draigBrady.com>2013-07-11 01:17:30 +0100
commitf3fa3b2990c13623b80439039a92f72e08bb42be (patch)
treef2846ec81fa39b88186d95e75ceb2e153f314871
parent75c090931c164d31c57ff4bccf923f4b765c2bb2 (diff)
downloadcoreutils-f3fa3b2990c13623b80439039a92f72e08bb42be.tar.xz
tests: add more tests for shuf option combinations
* test/misc/shuf.sh: Add tests for erroneous conditions like multiple '-o' and '--random-source'.
-rwxr-xr-xtests/misc/shuf.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/misc/shuf.sh b/tests/misc/shuf.sh
index 3e33b6151..492fd4186 100755
--- a/tests/misc/shuf.sh
+++ b/tests/misc/shuf.sh
@@ -65,4 +65,33 @@ if ! test -r unreadable; then
shuf -n1 unreadable && fail=1
fi
+# Multiple -n is accepted, should use the smallest value
+shuf -n10 -i0-9 -n3 -n20 > exp || framework_failure_
+c=$(wc -l < exp) || framework_failure_
+test "$c" -eq 3 || { fail=1; echo "Multiple -n failed">&2 ; }
+
+# Test error conditions
+
+# -i and -e must not be used together
+: | shuf -i -e A B &&
+ { fail=1; echo "shuf did not detect erroneous -e and -i usage.">&2 ; }
+# Test invalid value for -n
+: | shuf -nA &&
+ { fail=1; echo "shuf did not detect erroneous -n usage.">&2 ; }
+# Test multiple -i
+shuf -i0-9 -n10 -i8-90 &&
+ { fail=1; echo "shuf did not detect multiple -i usage.">&2 ; }
+# Test invalid range
+for ARG in '1' 'A' '1-' '1-A'; do
+ shuf -i$ARG &&
+ { fail=1; echo "shuf did not detect erroneous -i$ARG usage.">&2 ; }
+done
+
+# multiple -o are forbidden
+shuf -i0-9 -o A -o B &&
+ { fail=1; echo "shuf did not detect erroneous multiple -o usage.">&2 ; }
+# multiple random-sources are forbidden
+shuf -i0-9 --random-source A --random-source B &&
+ { fail=1; echo "shuf did not detect multiple --random-source usage.">&2 ; }
+
Exit $fail