test/json-parse: add json parsing test

This commit is contained in:
Danny Robson 2018-07-05 13:43:28 +10:00
parent 8d921aacc2
commit 74568d1c2d
2 changed files with 23 additions and 13 deletions

View File

@ -576,6 +576,10 @@ if (TESTS)
add_test(NAME util_${name} COMMAND util_${name})
endforeach(t)
configure_file (test/json-parse.sh.in util_test_json_parse.sh @ONLY)
add_test(NAME util_test_json_parse COMMAND util_test_json_parse.sh)
set_property(TEST util_test_json_parse APPEND PROPERTY DEPENDS util_json-validate)
configure_file (test/cpp.sh.in util_test_cpp.sh @ONLY)
add_test (NAME util_test_cpp COMMAND util_test_cpp.sh)
set_property (TEST util_test_cpp APPEND PROPERTY DEPENDS util_macro)

View File

@ -1,31 +1,37 @@
#!/bin/sh
validate=@abs_top_builddir@/tools/json-validate@EXEEXT@
validate="@CMAKE_CURRENT_BINARY_DIR@/json-validate"
count=0
code=0
for i in $(ls @abs_top_srcdir@/test/json/good/*);
for i in $(ls "@CMAKE_CURRENT_SOURCE_DIR@/test/json/good/"*);
do
@abs_top_srcdir@/build-aux/wine-crlf.sh $validate $i 2>/dev/null 1>&2
$validate $i 2>/dev/null 1>&2
case $? in
0) echo "ok - good/$(basename $i .json)";;
*) echo "not ok - good/$(basename $i .json)"; code=1;;
esac
if [ $? -eq 0 ]; then
echo "ok - good/$(basename $i .json)"
else
echo "not ok - good/$(basename $i .json)"
code=1
fi
count=$((count+1))
done
for i in $(ls @abs_top_srcdir@/test/json/bad/*);
for i in $(ls "@CMAKE_CURRENT_SOURCE_DIR@/test/json/bad/"*);
do
@abs_top_srcdir@/build-aux/wine-crlf.sh $validate $i 1>&2 2>/dev/null
case $? in
0) echo "not ok - bad/$(basename $i .json)"; code=1;;
*) echo "ok - bad/$(basename $i .json)";;
esac
$validate $i 1>&2 2>/dev/null
if [ $? -eq 0 ]; then
echo "not ok - bad/$(basename $i .json)"
code=1
else
echo "ok - bad/$(basename $i .json)"
fi
count=$((count+1))
done
echo "1..$count"
exit $code