summaryrefslogtreecommitdiffstats
path: root/tests/parse.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parse.sh')
-rwxr-xr-xtests/parse.sh34
1 files changed, 19 insertions, 15 deletions
diff --git a/tests/parse.sh b/tests/parse.sh
index 1150f28..eadd2cf 100755
--- a/tests/parse.sh
+++ b/tests/parse.sh
@@ -21,7 +21,10 @@ set -eu
. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
-fmts="$(TZ=UTC0 "${TOP_BUILDDIR}/@" -d '1970-01-01 00:00:00' -F)"
+now='1969-12-31 23:59:30'
+tgt='1970-01-01 00:00:00'
+
+fmts="$(TZ=UTC0 "${TOP_BUILDDIR}/atsign" -d "${tgt}" -F)"
time_fmts="$(printf '%s\n' "${fmts}" | \
sed -n '/^Time formats:$/,/^Date formats:$/s/^ \* //p')"
date_fmts="$(printf '%s\n' "${fmts}" | \
@@ -44,30 +47,31 @@ for fmt in $(printf '%s\n' "${fmts}"); do
diag_ "${fmt}"
done
-run_test()
+test_fmt()
{
- datetime="${1}"
- shift 1
+ now="${1}"
+ tgt="${2}"
+ fmt="${3}"
+ shift 3
- got="$(TZ=UTC0 "${TOP_BUILDDIR}/@" -d '1969-12-31 23:59:30' \
- "${datetime}" 2>&1)" || :
- if [ x"${got}" = x'0' ]; then
- ok_ -- "${datetime}"
+ got="$(TZ=UTC0 "${TOP_BUILDDIR}/atsign" -d "${now}" "${fmt}" 2>&1)" || :
+ if [ x"${got}" = x"${tgt}" ]; then
+ ok_ -- "${fmt}"
else
- not_ok_ -- "${datetime}"
- diag_ " Failed test '${datetime}'"
+ not_ok_ -- "${fmt}"
+ diag_ " Failed test '${fmt}'"
diag_ " got: '${got}'"
- diag_ " expected: '0'"
+ diag_ " expected: '${tgt}'"
fi
}
for time_fmt in ${time_fmts}; do
- run_test "${time_fmt}"
+ test_fmt "${now}" "${tgt}" "${time_fmt}"
for date_fmt in ${date_fmts}; do
- run_test "${date_fmt} ${time_fmt}"
- run_test "${time_fmt} ${date_fmt}"
+ test_fmt "${now}" "${tgt}" "${date_fmt} ${time_fmt}"
+ test_fmt "${now}" "${tgt}" "${time_fmt} ${date_fmt}"
done
done
for misc_fmt in ${misc_fmts}; do
- run_test "${misc_fmt}"
+ test_fmt "${now}" "${tgt}" "${misc_fmt}"
done