From 00c03295315cb2d359733858d2945bb6a7070c70 Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Thu, 31 Dec 2015 14:19:31 +0100 Subject: Add pacsort tests with invalid input Signed-off-by: Rikard Falkeborn Signed-off-by: Allan McRae --- test/util/pacsorttest.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test') 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: -- cgit v1.2.3-24-g4f1b