summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2022-03-17 17:07:15 (EDT)
committer P. J. McDermott <pj@pehjota.net>2022-03-17 17:07:15 (EDT)
commitd84cbfa242fb4ae3a80c54e8941d792a419b2be9 (patch)
tree075efa4a164e5db4963ba9fc8e56bf5b12ad983e
parent043e869f1700fc7089e6abe6d8626990320610ad (diff)
downloadatsign-d84cbfa242fb4ae3a80c54e8941d792a419b2be9.zip
atsign-d84cbfa242fb4ae3a80c54e8941d792a419b2be9.tar.gz
atsign-d84cbfa242fb4ae3a80c54e8941d792a419b2be9.tar.bz2
tests: Use @'s -F option to auto test all fmts
-rwxr-xr-xtests/parse.sh99
1 files changed, 20 insertions, 79 deletions
diff --git a/tests/parse.sh b/tests/parse.sh
index 13ccbfc..95a8a93 100755
--- a/tests/parse.sh
+++ b/tests/parse.sh
@@ -21,108 +21,49 @@ set -eu
. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
-DATE_FMTS='
- Wed
- 1969-12-31
- 1969/12/31
- 12-31-1969
- 12-31
- 12/31/1969
- 12/31
- 31 Dec 1969
- 31 Dec
- 31-Dec-1969
- 31-Dec
- 31/Dec/1969
- 31/Dec
- Wed 31 Dec 1969
- Wed 31 Dec
- Wed 31-Dec-1969
- Wed 31-Dec
- Wed 31/Dec/1969
- Wed 31/Dec
- Wed, 31 Dec 1969
- Wed, 31 Dec
- Wed, 31-Dec-1969
- Wed, 31-Dec
- Wed, 31/Dec/1969
- Wed, 31/Dec
- Dec 31, 1969
- Dec 31
- Dec-31-1969
- Dec-31
- Dec/31/1969
- Dec/31
- Wed Dec 31, 1969
- Wed Dec 31
- Wed Dec-31-1969
- Wed Dec-31
- Wed Dec/31/1969
- Wed Dec/31
- Wed, Dec 31, 1969
- Wed, Dec 31
- Wed, Dec-31-1969
- Wed, Dec-31
- Wed, Dec/31/1969
- Wed, Dec/31
- '
-TIME_FMTS='
- 7:00:01 PM
- 19:00:01
- 7:00 PM
- 19:00
- 70001 PM
- 190001
- 700 PM
- 1900
- '
-MISC_FMTS='
- 1969-12-31T19:00:01
- 1969-12-31T19:00
- 19691231T190001
- 19691231T1900
- 19691231 70001 PM
- 19691231 190001
- 19691231 700 PM
- 19691231 1900
- Wed Dec 31 19:00:01 1969
- '
+fmts="$(TZ=UTC0 faketime -f '1970-01-01 00:00:00' "${TOP_BUILDDIR}/@" -F)"
+time_fmts="$(printf '%s\n' "${fmts}" | \
+ sed -n '/^Time formats:$/,/^Date formats:$/s/^ \* //p')"
+date_fmts="$(printf '%s\n' "${fmts}" | \
+ sed -n '/^Date formats:$/,/^Additional formats:$/s/^ \* //p')"
+misc_fmts="$(printf '%s\n' "${fmts}" | \
+ sed -n '/^Additional formats:$/,$s/^ \* //p')"
-plan_ 704
+plan_ $((\
+ $(printf '%s\n' "${time_fmts}" | wc -l) + \
+ $(printf '%s\n' "${time_fmts}" | wc -l) * \
+ $(printf '%s\n' "${date_fmts}" | wc -l) * \
+ 2 + \
+ $(printf '%s\n' "${misc_fmts}" | wc -l) \
+ ))
run_test()
{
datetime="${1}"
shift 1
- got="$(TZ=EST5EDT faketime -f '1969-12-31 18:00:00' \
+ got="$(TZ=UTC0 faketime -f '1969-12-31 23:59:30' \
"${TOP_BUILDDIR}/@" -d "${datetime}" 2>&1)" || :
- if [ x"${got}" = x'1' ]; then
+ if [ x"${got}" = x'0' ]; then
ok_ -- "${datetime}"
else
not_ok_ -- "${datetime}"
diag_ " Failed test '${datetime}'"
diag_ " got: '${got}'"
- diag_ " expected: '1'"
+ diag_ " expected: '0'"
fi
}
IFS='
'
-for time_fmt in ${TIME_FMTS}; do
- time_fmt="${time_fmt# }"
- [ -z "${time_fmt}" ] && continue
+for time_fmt in ${time_fmts}; do
run_test "${time_fmt}"
- for date_fmt in ${DATE_FMTS}; do
- date_fmt="${date_fmt# }"
- [ -z "${date_fmt}" ] && continue
+ for date_fmt in ${date_fmts}; do
run_test "${date_fmt} ${time_fmt}"
run_test "${time_fmt} ${date_fmt}"
done
done
-for misc_fmt in ${MISC_FMTS}; do
- misc_fmt="${misc_fmt# }"
- [ -z "${misc_fmt}" ] && continue
+for misc_fmt in ${misc_fmts}; do
run_test "${misc_fmt}"
done