File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,10 @@ function assert_value_in_list {
8080function assert_exactly_one_of {
8181 local -ra args=(" $@ " )
8282 local -r num_args=" ${# args[@]} "
83+ if [[ " $(( num_args % 2 )) " -ne 0 ]]; then
84+ log_error " This script expects an even number of arguments but received $num_args instead."
85+ exit 1
86+ fi
8387
8488 local num_non_empty=0
8589 local -a arg_names=()
Original file line number Diff line number Diff line change @@ -184,6 +184,11 @@ load "test-helper"
184184 assert_failure
185185}
186186
187+ @test " assert_exactly_one_of list of length 5, with one value set, fails for odd num_args" {
188+ run assert_exactly_one_of " --foo" " foo" " --bar" " " " --baz" " " " --qux"
189+ assert_failure
190+ }
191+
187192@test " assert_uid_is_root_or_sudo as root" {
188193 run assert_uid_is_root_or_sudo
189194 assert_success
You can’t perform that action at this time.
0 commit comments