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