summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2022-03-17 14:20:40 (EDT)
committer P. J. McDermott <pj@pehjota.net>2022-03-17 16:17:43 (EDT)
commit043e869f1700fc7089e6abe6d8626990320610ad (patch)
tree3d2854642b915c3c913aa88bd84a3fda82545b35
parent8ae8df6d9f903cee298e1cc821a73dc6ab916367 (diff)
downloadatsign-043e869f1700fc7089e6abe6d8626990320610ad.zip
atsign-043e869f1700fc7089e6abe6d8626990320610ad.tar.gz
atsign-043e869f1700fc7089e6abe6d8626990320610ad.tar.bz2
tests: WIP parse test
-rwxr-xr-xtests/parse.sh110
1 files changed, 103 insertions, 7 deletions
diff --git a/tests/parse.sh b/tests/parse.sh
index 1de2320..13ccbfc 100755
--- a/tests/parse.sh
+++ b/tests/parse.sh
@@ -21,12 +21,108 @@ set -eu
. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
-plan_ later
+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
+ '
-if [ x"$(TZ=UTC0 "${TOP_BUILDDIR}/@" -d '19700101T000000')" = x'0' ]; then
- ok_ -- '19700101T000000'
-else
- not_ok_ -- '19700101T000000'
-fi
+plan_ 704
-plan_ now
+run_test()
+{
+ datetime="${1}"
+ shift 1
+
+ got="$(TZ=EST5EDT faketime -f '1969-12-31 18:00:00' \
+ "${TOP_BUILDDIR}/@" -d "${datetime}" 2>&1)" || :
+ if [ x"${got}" = x'1' ]; then
+ ok_ -- "${datetime}"
+ else
+ not_ok_ -- "${datetime}"
+ diag_ " Failed test '${datetime}'"
+ diag_ " got: '${got}'"
+ diag_ " expected: '1'"
+ fi
+}
+
+IFS='
+'
+
+for time_fmt in ${TIME_FMTS}; do
+ time_fmt="${time_fmt# }"
+ [ -z "${time_fmt}" ] && continue
+ run_test "${time_fmt}"
+ for date_fmt in ${DATE_FMTS}; do
+ date_fmt="${date_fmt# }"
+ [ -z "${date_fmt}" ] && continue
+ 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
+ run_test "${misc_fmt}"
+done