1 | #!/bin/sh |
---|
2 | |
---|
3 | ${test1:=./test1} |
---|
4 | |
---|
5 | run() { |
---|
6 | prog=$1; shift |
---|
7 | name=$1; shift |
---|
8 | answer=$1; shift |
---|
9 | |
---|
10 | echo Running test $name. |
---|
11 | |
---|
12 | result=`./$prog $*` |
---|
13 | if [ "$answer" != "$result" ]; then |
---|
14 | echo "Test \"$*\" failed with: $result" |
---|
15 | exit 2 |
---|
16 | fi |
---|
17 | } |
---|
18 | |
---|
19 | make -q testcases |
---|
20 | |
---|
21 | run test1 "test1 - 1" "arg1: 1 arg2: (none)" --arg1 |
---|
22 | run test1 "test1 - 2" "arg1: 0 arg2: foo" --arg2 foo |
---|
23 | run test1 "test1 - 3" "arg1: 1 arg2: something" --arg1 --arg2 something |
---|
24 | run test1 "test1 - 4" "arg1: 0 arg2: another" --simple another |
---|
25 | run test1 "test1 - 5" "arg1: 1 arg2: alias" --two |
---|
26 | run test1 "test1 - 6" "arg1: 1 arg2: (none) rest: --arg2" --arg1 -- --arg2 |
---|
27 | run test1 "test1 - 7" "arg1: 0 arg2: abcd rest: --arg1" --simple abcd -- --arg1 |
---|
28 | run test1 "test1 - 8" "arg1: 1 arg2: (none) rest: --arg2" --arg1 --takerest --arg2 |
---|
29 | run test1 "test1 - 9" "arg1: 0 arg2: foo" -2 foo |
---|
30 | run test1 "test1 - 10" "arg1: 0 arg2: (none) arg3: 50" -3 50 |
---|
31 | run test1 "test1 - 11" "arg1: 0 arg2: bar" -T bar |
---|
32 | run test1 "test1 - 12" "arg1: 1 arg2: (none)" -O |
---|
33 | run test1 "test1 - 13" "arg1: 1 arg2: foo" -OT foo |
---|
34 | run test1 "test1 - 14" "arg1: 0 arg2: (none) inc: 1" --inc |
---|
35 | run test1 "test1 - 15" "arg1: 0 arg2: foo inc: 1" -i --arg2 foo |
---|
36 | POSIX_ME_HARDER=1 run test1 "test1 - 16" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something |
---|
37 | POSIXLY_CORRECT=1 run test1 "test1 - 17" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something |
---|
38 | run test1 "test1 - 18" "callback: c sampledata bar arg1: 1 arg2: (none)" --arg1 --cb bar |
---|
39 | run test1 "test1 - 19" "${test1} ;" --echo-args |
---|
40 | run test1 "test1 - 20" "${test1} ; --arg1" --echo-args --arg1 |
---|
41 | run test1 "test1 - 21" "${test1} ; --arg2 something" -T something -e |
---|
42 | run test1 "test1 - 22" "${test1} ; --arg2 something -- more args" -T something -a more args |
---|
43 | run test1 "test1 - 23" "${test1} ; --echo-args -a" --echo-args -e -a |
---|
44 | run test1 "test1 - 24" "arg1: 0 arg2: (none) short: 1" -shortoption |
---|
45 | run test1 "test1 - 25" "arg1: 0 arg2: (none) short: 1" --shortoption |
---|
46 | run test1 "test1 - 26" "callback: c arg for cb2 foo arg1: 0 arg2: (none)" --cb2 foo |
---|
47 | run test1 "test1 - 27" "arg1: 0 arg2: (none) -" - |
---|
48 | run test1 "test1 - 28" "arg1: 0 arg2: foo -" - -2 foo |
---|
49 | run test1 "test1 - 29" "arg1: 0 arg2: bbbb" --arg2=aaaa -2 bbbb |
---|
50 | run test1 "test1 - 30" "arg1: 0 arg2: 'foo bingo' rest: boggle" --grab bingo boggle |
---|
51 | run test1 "test1 - 31" "arg1: 0 arg2: 'foo bar' rest: boggle" --grabbar boggle |
---|
52 | |
---|
53 | echo "" |
---|
54 | echo "Passed." |
---|