glibc/time
James Perkins be13f5a4ba time/tst-strptime2.c: test full input range +/- 0-9999
strptime's %z specifier parses a string consisting of a sign ('+'
or '-'), two hours digits, and optionally two minutes digits, into a
tm.tm_gmtoff field containing the signed number of seconds the time
zone is offset from UTC time.

The time/tst-strptime2.c program passes a short list of strings through
strptime, validating that either the gmtoff value returned matches an
expected value, or that strptime returns an expected NULL for invalid
strings (for example, when the minutes portion of the string is outside
of the range 00 to 59, or the sign is missing before the hours digits).

In review of strptime fixes, Carlos O'Donell expressed a wish that
the test function iterate through the entire range of all possible
numeric strings (-9999 to +9999) which could be passed to strptime %z,
and validate the correct response.

Specifically, the test will look for a NULL response from strptime
when:

  * sign ('+' or '-') is not present before the first digit (invalid
    format).
  * A sign and no digits are found (invalid format).
  * A sign and one digit are found (invalid format).
  * A sign and three digits are found (invalid format).
  * A sign and four digits (-9999 to +9999) are found but the last
    two digits (minutes) are in the range 60 to 99.

The test will look for a success response from strptime with
tm.tm_gmtoff matching the calculated tm_gmtoff value when:

  * A sign and four digits are found (-9999 to +9999), and the last
    two digits (minutes) are in the range 00 to 59.
  * A sign and two digit strings are found (-99 to +99).

The test's iteration over the possible digit values results in 22223
test strings prepared, tested, and passed by strptime.

The test supports a --verbose command line option which will show
the test results of every test input, and a final summary of all
tests. Here is some sample output:

  PASS: input "1113472456  1030", expected: invalid, return value NULL
  PASS: input "1113472456 +", expected: invalid, return value NULL
  PASS: input "1113472456 -", expected: invalid, return value NULL
  PASS: input "1113472456 +0", expected: invalid, return value NULL
  PASS: input "1113472456 -0", expected: invalid, return value NULL
  PASS: input "1113472456 +1", expected: invalid, return value NULL
  ...
  PASS: input "1113472456 +9", expected: invalid, return value NULL
  PASS: input "1113472456 -9", expected: invalid, return value NULL
  PASS: input "1113472456 +00", expected: valid, tm.tm_gmtoff 0
  PASS: input "1113472456 -00", expected: valid, tm.tm_gmtoff 0
  PASS: input "1113472456 +01", expected: valid, tm.tm_gmtoff 3600
  PASS: input "1113472456 -01", expected: valid, tm.tm_gmtoff -3600
  PASS: input "1113472456 +02", expected: valid, tm.tm_gmtoff 7200
  ...
  PASS: input "1113472456 +99", expected: valid, tm.tm_gmtoff 356400
  PASS: input "1113472456 -99", expected: valid, tm.tm_gmtoff -356400
  PASS: input "1113472456 +000", expected: invalid, return value NULL
  PASS: input "1113472456 -000", expected: invalid, return value NULL
  PASS: input "1113472456 +001", expected: invalid, return value NULL
  ...
  PASS: input "1113472456 +999", expected: invalid, return value NULL
  PASS: input "1113472456 -999", expected: invalid, return value NULL
  PASS: input "1113472456 +0000", expected: valid, tm.tm_gmtoff 0
  PASS: input "1113472456 -0000", expected: valid, tm.tm_gmtoff 0
  PASS: input "1113472456 +0001", expected: valid, tm.tm_gmtoff 60
  PASS: input "1113472456 -0001", expected: valid, tm.tm_gmtoff -60
  ...
  PASS: input "1113472456 +0059", expected: valid, tm.tm_gmtoff 3540
  PASS: input "1113472456 -0059", expected: valid, tm.tm_gmtoff -3540
  PASS: input "1113472456 +0060", expected: invalid, return value NULL
  PASS: input "1113472456 -0060", expected: invalid, return value NULL
  ...
  PASS: input "1113472456 +0099", expected: invalid, return value NULL
  PASS: input "1113472456 -0099", expected: invalid, return value NULL
  PASS: input "1113472456 +0100", expected: valid, tm.tm_gmtoff 3600
  PASS: input "1113472456 -0100", expected: valid, tm.tm_gmtoff -3600
  PASS: input "1113472456 +0101", expected: valid, tm.tm_gmtoff 3660
  ...
  PASS: input "1113472456 +9999", expected: invalid, return value NULL
  PASS: input "1113472456 -9999", expected: invalid, return value NULL
  PASS: 22223 input strings: 0 fail, 22223 pass

Any failing test will result in printing the failed line to stdout, and
will trigger the printing of the summary line at the of all tests. For
example:

  FAIL: input "1113472456  1030", expected: invalid, return value NULL,
    got: valid, tm.tm_gmtoff 37800
  FAIL: 22223 input strings: 1 fail, 22222 pass
2015-08-28 23:48:10 -04:00
..
sys Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
adjtime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
alt_digit.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
asctime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
bug-asctime_r.c [BZ #1468] 2005-10-14 17:20:58 +00:00
bug-asctime.c [BZ #1460] 2005-10-14 15:17:40 +00:00
bug-getdate1.c * time/bug-getdate1.c (do_test): Don't use century values which 2007-12-12 18:23:00 +00:00
bug-mktime1.c [BZ #2821] 2006-09-09 16:56:29 +00:00
clock.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
clocktest.c Define CLOCKS_PER_SEC type to the type clock_t 2015-01-06 04:59:13 -08:00
ctime_r.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
ctime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
datemsk * time/Makefile (tst-getdate-ENV): Add TZDIR to environment. 2001-07-18 09:43:36 +00:00
Depend * time/Makefile (tst-getdate-ENV): Add TZDIR to environment. 2001-07-18 09:43:36 +00:00
difftime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
dysize.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
era.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
ftime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
getdate.c Fix time/getdate.c build. 2015-02-08 17:45:25 +01:00
getitimer.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
gettimeofday.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
gmtime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
lc-time-cleanup.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
localtime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Makefile Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
mktime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
offtime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
setitimer.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
settimeofday.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
stime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
strftime_l.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
strftime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
strptime_l.c strptime %z: fix rounding, extend range to +/-9959 [BZ #16141] 2015-08-28 23:45:51 -04:00
strptime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
test_time.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
time.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
time.h Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
timegm.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
timespec_get.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
tst_wcsftime.c Update. 1999-06-16 22:55:47 +00:00
tst-ftime_l.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-ftime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
tst-getdate.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
tst-mktime2.c Testsuite #include fixes. 2012-04-02 22:31:32 +02:00
tst-mktime3.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-mktime.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-posixtz.c Replace %ld with %jd and cast to intmax_t 2014-12-30 08:09:43 -08:00
tst-strftime.c (do_test): Add tests for - flag. 2003-05-11 22:41:23 +00:00
tst-strptime2.c time/tst-strptime2.c: test full input range +/- 0-9999 2015-08-28 23:48:10 -04:00
tst-strptime3.c time: ensure failing strptime() tests are reported correctly 2015-03-06 06:06:26 -05:00
tst-strptime-whitespace.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
tst-strptime.c Modify several tests to use test-skeleton.c 2015-08-06 02:59:04 -04:00
tzfile.c Check tzspec_len == 0 in __tzfile_read 2015-04-27 09:57:51 -07:00
tzset.c test-skeleton: Support temporary files without memory leaks [BZ#18333] 2015-04-27 16:19:55 +02:00
Versions Sort Versions files 2013-02-17 16:34:04 +01:00
wcsftime_l.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
wcsftime.c Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00