diff options
author | Matthew Wild <mwild1@gmail.com> | 2016-03-05 20:50:17 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2016-03-05 20:50:17 +0000 |
commit | 9fc74d1c41dcaa0b256255c5ca1a96621157d270 (patch) | |
tree | 50a8c372a53ab0e814fee4015df46d5686649052 /tests/test_util_json.sh | |
parent | 26aa750e1c62b7994e790073620bf1fed7af476b (diff) | |
parent | 5d33051ecc8a62231f0dd37f4176a87b19e83534 (diff) | |
download | prosody-9fc74d1c41dcaa0b256255c5ca1a96621157d270.tar.gz prosody-9fc74d1c41dcaa0b256255c5ca1a96621157d270.zip |
Merge 0.10->trunk
Diffstat (limited to 'tests/test_util_json.sh')
-rwxr-xr-x | tests/test_util_json.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_util_json.sh b/tests/test_util_json.sh new file mode 100755 index 00000000..bbbd132b --- /dev/null +++ b/tests/test_util_json.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +export LUA_PATH="../?.lua;;" +export LUA_CPATH="../?.so;;" + +#set -x + +if ! which "$RUNWITH"; then + echo "Unable to find interpreter $RUNWITH"; + exit 1; +fi + +if ! $RUNWITH -e 'assert(require"util.json")' 2>/dev/null; then + echo "Unable to find util.json"; + exit 1; +fi + +FAIL=0 + +for f in json/pass*.json; do + if ! $RUNWITH -e 'local j=require"util.json" assert(j.decode(io.read("*a"))~=nil)' <"$f" 2>/dev/null; then + echo "Failed to decode valid JSON: $f"; + FAIL=1 + fi +done + +for f in json/fail*.json; do + if ! $RUNWITH -e 'local j=require"util.json" assert(j.decode(io.read("*a"))==nil)' <"$f" 2>/dev/null; then + echo "Invalid JSON decoded without error: $f"; + FAIL=1 + fi +done + +if [ "$FAIL" == "1" ]; then + echo "JSON tests failed" + exit 1; +fi + +exit 0; |