[pacman-dev] [PATCH 3/3] Add pacsort tests with invalid input
Rikard Falkeborn
rikard.falkeborn at gmail.com
Thu Dec 31 13:19:31 UTC 2015
Signed-off-by: Rikard Falkeborn <rikard.falkeborn at gmail.com>
---
test/util/pacsorttest.sh | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/test/util/pacsorttest.sh b/test/util/pacsorttest.sh
index 3b285b8..32ee6ba 100755
--- a/test/util/pacsorttest.sh
+++ b/test/util/pacsorttest.sh
@@ -35,7 +35,16 @@ tap_runtest() {
tap_diff <(printf "$1" | $bin $4) <(printf "$2") "$3"
}
-tap_plan 26
+# args:
+# check_return_value input expected_return_value test_description optional_opts
+tap_check_return_value() {
+ # run the test
+ printf "$1" | $bin $4 2>/dev/null
+ tap_is_int "$?" "$2" "$3"
+
+}
+
+tap_plan 32
in="1\n2\n3\n4\n"
tap_runtest $in $in "already ordered"
@@ -108,6 +117,13 @@ tap_runtest "$separator_reverse" "$separator" "really long input, sort key, sepa
tap_runtest "$separator_reverse" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
tap_runtest "$separator" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
+tap_check_return_value "" "2" "invalid sort key (no argument)" "-k"
+tap_check_return_value "" "2" "invalid sort key (non-numeric)" "-k asd"
+tap_check_return_value "" "2" "invalid field separator (no argument)" "-t"
+tap_check_return_value "" "2" "invalid field separator (multiple characters)" "-t sda"
+tap_check_return_value "" "2" "invalid field separator (two characters must start with a slash)" "-t ag"
+tap_check_return_value "" "2" "invalid field separator (\g is invalid)" '-t \g'
+
tap_finish
# vim: set noet:
--
2.6.4
More information about the pacman-dev
mailing list