forked from aks/bash-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-template.sh
executable file
·65 lines (55 loc) · 1.54 KB
/
test-template.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
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# Copyright 2006-2022, Alan K. Stebbens <[email protected]>
#
# test-template.sh -- a template on which to create new test cases
PATH=.:$PATH:$HOME/lib
source test-utils.sh
test_1_NAME1() {
start_test
# ... do some operations to be tested
# ... now test the results of the operations
# check_value VAR ERROR
# check_empty VAR ERROR
#
# array size and item tests
#
# check_size LIST SIZE ERROR # same as check_size_eq
# check_size_XX LIST SIZE ERROR
# check_item VAR INDEX VAL ERROR
# check_item_equal VAR INDEX VAL ERROR
# check_item_unequal VAR INDEX NONVAL ERROR
#
# String value tests
#
# check_equal VAL1 VAL2 ERROR
# check_unequal VAL1 VAL2 ERROR
# check_match VAL1 REGEXP ERROR
# check_nomatch VAL1 REGEXP ERROR
#
# Numeric value tests
#
# check_lt N1 N2 ERROR
# check_le N1 N2 ERROR
# check_eq N1 N2 ERROR
# check_ne N1 N2 ERROR
# check_ge N1 N2 ERROR
# check_gt N1 N2 ERROR
#
# ERROR is optional
#...
#... more operations
end_test
}
test_2_NAME2() {
start_test
#....
end_test
}
# ... more tests
# If you pass arguments to init_tests, they will be processed just like
# command-line args (ie? -v == verbose, -e == verbose_errors, -n == norun,
# -h == help)
init_tests "$@"
run_tests
summarize_tests
exit