Introduction
Introduction Statistics Contact Development Disclaimer Help
test.sh - json-testsuite - JSON test-suite
git clone git://git.codemadness.org/json-testsuite
Log
Files
Refs
README
LICENSE
---
test.sh (1292B)
---
1 #!/bin/sh
2
3 # log(f, status, text)
4 log() {
5 printf '%-4.4s %s %s\n' "$2" "$1" "$3"
6 }
7
8 # fail(f,s)
9 fail() {
10 log "$1" "FAIL" "$2"
11 }
12
13 # ok(f,s)
14 ok() {
15 log "$1" "OK" "$2"
16 }
17
18 # meh(f,s)
19 meh() {
20 log "$1" "MEH" "$2"
21 }
22
23 json() {
24 json2tsv
25 }
26
27 testaccepted() {
28 # y_ content must be accepted by parsers
29 for f in test_parsing/y_* my_tests/y_*; do
30 json < "$f" >/dev/null 2>/dev/null
31 if test $? -ne 0; then
32 fail "$f" "must be accepted, but did not"
33 echo "ABORT ABORT ABORT!"
34 exit 1
35 else
36 ok "$f" "accepted"
37 # DEBUG
38 # echo "Input:"
39 # cat "$f"
40 # echo ""
41 # echo "- - -"
42 # echo "Output:"
43 # cat "/tmp/1"
44 # echo "==="
45 fi
46 done
47 }
48
49 testrejected() {
50 # n_ content must be rejected by parsers
51 for f in test_parsing/n_* my_tests/n_*; do
52 json < "$f" > /dev/null 2>/dev/null
53 if test $? -eq 0; then
54 fail "$f" "must be rejected, but was not"
55 else
56 ok "$f" "rejected"
57 fi
58 done
59 }
60
61 testeither() {
62 # i_ parsers are free to accept or reject content
63 for f in test_parsing/i_* my_tests/i_*; do
64 json < "$f" > /dev/null 2>/dev/null
65 if test $? -eq 0; then
66 meh "$f" "Accepted, but either way is fine"
67 else
68 meh "$f" "Rejected, but either way is fine"
69 fi
70 done
71 }
72
73 # these MUST all pass.
74 testaccepted
75 # these MAY fail.
76 testrejected
77 # either way is fine.
78 testeither
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.