2019-10-10 16:11:52 +08:00
|
|
|
if ! (which jq >& /dev/null); then
|
|
|
|
echo "ERROR: please install the 'jq' utility"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-10-09 07:58:18 +08:00
|
|
|
#
|
|
|
|
# POSITIVE tests
|
|
|
|
#
|
|
|
|
for i in toml-spec-tests/values/*.toml; do
|
2019-10-10 19:15:45 +08:00
|
|
|
fname="$i"
|
|
|
|
ext="${fname##*.}"
|
|
|
|
fname="${fname%.*}"
|
|
|
|
echo -n $fname ' '
|
2019-10-10 16:11:52 +08:00
|
|
|
res='[OK]'
|
2019-10-10 19:15:45 +08:00
|
|
|
if (../toml_json $fname.toml >& $fname.json.out); then
|
2019-10-11 08:32:54 +08:00
|
|
|
jq -S . $fname.json.out > t.json
|
2019-10-10 19:15:45 +08:00
|
|
|
mv t.json $fname.json.out
|
|
|
|
if [ -f $fname.json ]; then
|
|
|
|
if ! (diff $fname.json $fname.json.out >& /dev/null); then
|
|
|
|
res='[FAILED]'
|
|
|
|
else
|
|
|
|
rm -f $fname.json.out
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
res='[??]'
|
2019-10-10 16:11:52 +08:00
|
|
|
fi
|
2019-10-09 07:58:18 +08:00
|
|
|
fi
|
2019-10-11 08:34:45 +08:00
|
|
|
echo ... $res
|
2019-10-09 07:58:18 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# NEGATIVE tests
|
|
|
|
#
|
|
|
|
for i in toml-spec-tests/errors/*.toml; do
|
|
|
|
echo -n $i ' '
|
2019-10-11 08:34:45 +08:00
|
|
|
res='[OK]'
|
2019-10-10 16:11:52 +08:00
|
|
|
if (../toml_json $i >& $i.json.out); then
|
2019-10-11 08:34:45 +08:00
|
|
|
res='[FAILED]'
|
2019-10-09 07:58:18 +08:00
|
|
|
fi
|
2019-10-11 08:34:45 +08:00
|
|
|
echo ... $res
|
2019-10-09 07:58:18 +08:00
|
|
|
done
|