-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.sh
executable file
·57 lines (50 loc) · 1.08 KB
/
tests.sh
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
51
52
53
54
55
56
57
# PUT PATH TO BASH 4.2 BINARY HERE
# Test pforb
. ./cpfb
testKeyValues() {
local tot=0
[[ "$Name" ]] || let tot+=1
[[ "$Main_Use" ]] || let tot+=1
[[ "$Main_CutSpaces" =~ ^A\ string\ with\ spaces$ ]] || let tot+=1
if [[ $tot -eq 0 ]]; then
passed "Key = Values"
else
failed "Key = Values"
fi
}
testIndexedArrays() {
local tot=0
[[ "${MyArray[1]}" =~ ^Some\ otherThing:$ ]] || let tot+=1
[[ "${#MyArray[@]}" -eq 2 ]] || let tot+=1
if [[ $tot -eq 0 ]]; then
passed "Indexed arrays"
else
failed "Indexed arrays"
fi
}
testAssociativeArrays() {
local tot=0
[[ "${OtherArray[gitgit]}" =~ ^bestThing\;maybe$ ]] || let tot+=1
[[ "${#OtherArray[@]}" -eq 2 ]] || let tot+=1
if [[ $tot -eq 0 ]]; then
passed "Associative arrays"
else
failed "Associative arrays"
fi
}
runTests() {
parseConfig "$1" || exit 1
echo "Running KeyValues..."
testKeyValues "$1"
echo "Running Arrays..."
testIndexedArrays "$1"
testAssociativeArrays "$1"
echo "Done"
}
failed() {
echo "--Failed $1"
}
passed() {
echo "--Passed $1"
}
runTests "./example.conf"