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}) add_test(NAME util_${name} COMMAND util_${name})
endforeach(t) 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) configure_file (test/cpp.sh.in util_test_cpp.sh @ONLY)
add_test (NAME util_test_cpp COMMAND util_test_cpp.sh) add_test (NAME util_test_cpp COMMAND util_test_cpp.sh)
set_property (TEST util_test_cpp APPEND PROPERTY DEPENDS util_macro) set_property (TEST util_test_cpp APPEND PROPERTY DEPENDS util_macro)

View File

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