blob: 1150f28c1fbe8be99a2c5e2081f1d72e486fee8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# Tests @'s date/time parsing
#
# 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"
fmts="$(TZ=UTC0 "${TOP_BUILDDIR}/@" -d '1970-01-01 00:00:00' -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_ $((\
$(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) \
))
IFS='
'
for fmt in $(printf '%s\n' "${fmts}"); do
diag_ "${fmt}"
done
run_test()
{
datetime="${1}"
shift 1
got="$(TZ=UTC0 "${TOP_BUILDDIR}/@" -d '1969-12-31 23:59:30' \
"${datetime}" 2>&1)" || :
if [ x"${got}" = x'0' ]; then
ok_ -- "${datetime}"
else
not_ok_ -- "${datetime}"
diag_ " Failed test '${datetime}'"
diag_ " got: '${got}'"
diag_ " expected: '0'"
fi
}
for time_fmt in ${time_fmts}; do
run_test "${time_fmt}"
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
run_test "${misc_fmt}"
done
|