summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRikard Falkeborn <rikard.falkeborn@gmail.com>2015-12-31 14:19:31 +0100
committerAllan McRae <allan@archlinux.org>2016-01-04 14:05:31 +1000
commit00c03295315cb2d359733858d2945bb6a7070c70 (patch)
tree15a8f159e5299c44258fa31d674c951f8682010f
parent88f348f2b15fed8a7b92085d01ffeced117f3599 (diff)
downloadpacman-00c03295315cb2d359733858d2945bb6a7070c70.tar.xz
Add pacsort tests with invalid input
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
-rwxr-xr-xtest/util/pacsorttest.sh18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/util/pacsorttest.sh b/test/util/pacsorttest.sh
index 484dfca5..390a3125 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: