[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#49217: [PATCH] tests: exercise shuf --input-range edge cases
From: |
Erik Auerswald |
Subject: |
bug#49217: [PATCH] tests: exercise shuf --input-range edge cases |
Date: |
Sat, 26 Jun 2021 19:02:23 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
* tests/misc/shuf.sh: Test valid "shuf -i" edge cases that result
in a single line of input, or no line at all. Test an invalid
range, too.
---
tests/misc/shuf.sh | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tests/misc/shuf.sh b/tests/misc/shuf.sh
index 892386b3f..83e940ec4 100755
--- a/tests/misc/shuf.sh
+++ b/tests/misc/shuf.sh
@@ -39,6 +39,15 @@ compare in out > /dev/null && { fail=1; echo "not random?"
1>&2; }
sort -n out > out1
compare in out1 || { fail=1; echo "not a permutation" 1>&2; }
+# Exercise border conditions of shuf's -i option
+# LO == HI gives one line
+echo 1 > in1 || framework_failure_
+shuf -i 1-1 > out || fail=1
+compare in1 out || fail=1
+# LO == HI+1 gives no output
+shuf -i 1-0 > out || fail=1
+compare /dev/null out || fail=1
+
# Exercize shuf's -r -n 0 options, with no standard input.
shuf -r -n 0 in <&- >out || fail=1
compare /dev/null out || fail=1
@@ -95,7 +104,7 @@ test "$c" -eq 3 || { fail=1; echo "Multiple -n failed">&2 ; }
{ shuf -i0-9 -n10 -i8-90 || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect multiple -i usage.">&2 ; }
# Test invalid range
-for ARG in '1' 'A' '1-' '1-A'; do
+for ARG in '1' 'A' '1-' '1-A' '3-1'; do
{ shuf -i$ARG || test $? -ne 1; } &&
{ fail=1; echo "shuf did not detect erroneous -i$ARG usage.">&2 ; }
done
--
2.17.1
bug#49217: [PATCH] shuf: fix bug with "-i 1-0", Erik Auerswald, 2021/06/25
bug#49217: [PATCH] doc: clarify valid ranges for shuf -i, Erik Auerswald, 2021/06/26
bug#49217: [PATCH] tests: exercise shuf --input-range edge cases,
Erik Auerswald <=