1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-21 23:38:49 -05:00

Add pacsort tests with invalid input

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Rikard Falkeborn 2015-12-31 14:19:31 +01:00 committed by Allan McRae
parent 88f348f2b1
commit 00c0329531

View File

@ -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: