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 {
80
80
function assert_exactly_one_of {
81
81
local -ra args=(" $@ " )
82
82
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
83
87
84
88
local num_non_empty=0
85
89
local -a arg_names=()
Original file line number Diff line number Diff line change @@ -184,6 +184,11 @@ load "test-helper"
184
184
assert_failure
185
185
}
186
186
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
+
187
192
@test " assert_uid_is_root_or_sudo as root" {
188
193
run assert_uid_is_root_or_sudo
189
194
assert_success
You can’t perform that action at this time.
0 commit comments