-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathassert_arrays.sh
More file actions
50 lines (41 loc) · 1.12 KB
/
assert_arrays.sh
File metadata and controls
50 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
function assert_array_contains() {
bashunit::assert::should_skip && return 0
local expected="$1"
local test_fn
test_fn="$(bashunit::helper::find_test_function_name)"
local label
label="$(bashunit::helper::normalize_test_function_name "$test_fn")"
shift
local -a actual
actual=("$@")
case "${actual[*]:-}" in
*"$expected"*)
;;
*)
bashunit::assert::mark_failed
bashunit::console_results::print_failed_test "${label}" "${actual[*]}" "to contain" "${expected}"
return
;;
esac
bashunit::state::add_assertions_passed
}
function assert_array_not_contains() {
bashunit::assert::should_skip && return 0
local expected="$1"
local test_fn
test_fn="$(bashunit::helper::find_test_function_name)"
local label
label="$(bashunit::helper::normalize_test_function_name "$test_fn")"
shift
local -a actual
actual=("$@")
case "${actual[*]:-}" in
*"$expected"*)
bashunit::assert::mark_failed
bashunit::console_results::print_failed_test "${label}" "${actual[*]}" "to not contain" "${expected}"
return
;;
esac
bashunit::state::add_assertions_passed
}