summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2022-03-20 20:16:34 (EDT)
committer P. J. McDermott <pj@pehjota.net>2022-03-20 20:20:10 (EDT)
commitdc8ce050ea8f2011fbbb2879ed3b10c183a3143d (patch)
treedf92c70d1b7d2ebef47cc8b3908317cc94a4ed06
parent90b59c4aeeabf47ea0977872e982fac515e47e32 (diff)
downloadatsign-dc8ce050ea8f2011fbbb2879ed3b10c183a3143d.zip
atsign-dc8ce050ea8f2011fbbb2879ed3b10c183a3143d.tar.gz
atsign-dc8ce050ea8f2011fbbb2879ed3b10c183a3143d.tar.bz2
tests: Add format listing test
-rw-r--r--TODO1
-rw-r--r--tests/formats.exp63
-rwxr-xr-xtests/formats.sh43
-rw-r--r--tests/local.mk1
4 files changed, 107 insertions, 1 deletions
diff --git a/TODO b/TODO
index f59891c..27e0571 100644
--- a/TODO
+++ b/TODO
@@ -2,7 +2,6 @@ spaces between specifiers in strptime() formats -- strftime()?
format printing: copy format to another buffer, skipping certain char
test with other libc's (newlib? musl? fbsd? obsd?)
`./@ 7:00 PM` doesn't work with musl strptime()
-formats test
test other times
"." in date/time formats
gettext?
diff --git a/tests/formats.exp b/tests/formats.exp
new file mode 100644
index 0000000..8286264
--- /dev/null
+++ b/tests/formats.exp
@@ -0,0 +1,63 @@
+Time formats:
+ * 03:04:05 AM
+ * 03:04:05
+ * 03:04 AM
+ * 03:04
+ * 030405 AM
+ * 030405
+ * 0304 AM
+ * 0304
+Date formats:
+ * Fri
+ * 1970-01-02
+ * 1970/01/02
+ * 01-02-1970
+ * 01-02
+ * 01/02/1970
+ * 01/02
+ * 2 Jan 1970
+ * 2 Jan
+ * 02-Jan-1970
+ * 02-Jan
+ * 02/Jan/1970
+ * 02/Jan
+ * Fri 2 Jan 1970
+ * Fri 2 Jan
+ * Fri 02-Jan-1970
+ * Fri 02-Jan
+ * Fri 02/Jan/1970
+ * Fri 02/Jan
+ * Fri, 2 Jan 1970
+ * Fri, 2 Jan
+ * Fri, 02-Jan-1970
+ * Fri, 02-Jan
+ * Fri, 02/Jan/1970
+ * Fri, 02/Jan
+ * Jan 2, 1970
+ * Jan 2
+ * Jan-02-1970
+ * Jan-02
+ * Jan/02/1970
+ * Jan/02
+ * Fri Jan 2, 1970
+ * Fri Jan 2
+ * Fri Jan-02-1970
+ * Fri Jan-02
+ * Fri Jan/02/1970
+ * Fri Jan/02
+ * Fri, Jan 2, 1970
+ * Fri, Jan 2
+ * Fri, Jan-02-1970
+ * Fri, Jan-02
+ * Fri, Jan/02/1970
+ * Fri, Jan/02
+Additional formats:
+ * 1970-01-02T03:04:05
+ * 1970-01-02T03:04
+ * 19700102T030405
+ * 19700102T0304
+ * 19700102 030405 AM
+ * 19700102 030405
+ * 19700102 0304 AM
+ * 19700102 0304
+ * Fri Jan 02 03:04:05 1970
diff --git a/tests/formats.sh b/tests/formats.sh
new file mode 100755
index 0000000..a0c4188
--- /dev/null
+++ b/tests/formats.sh
@@ -0,0 +1,43 @@
+# Tests `@ -F` output
+#
+# Copyright (C) 2022 P. J. McDermott
+#
+# This file is part of @
+#
+# @ is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# @ is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with @. If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+
+plan_ 1
+
+exp="$(cat "${0%.sh}.exp")"
+got="$("${TOP_BUILDDIR}/@" -d '1970-01-02 03:04:05' -F)"
+
+if [ x"${got}" = x"${exp}" ]; then
+ ok_ -- 'formats list'
+ exit 0
+fi
+not_ok_ -- 'formats list'
+
+IFS='
+'
+
+for line in $(printf '%s\n' "${got}" | diff -u "${0%.sh}.exp" '-' | sed '1,2d')
+do
+ diag_ "${line}"
+done
+
+exit 0
diff --git a/tests/local.mk b/tests/local.mk
index 0f8fb45..9124d94 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -1,4 +1,5 @@
tests = \
+ %reldir%/formats.sh \
%reldir%/parse.sh
if ENABLE_TESTS
TESTS = $(tests)