diff options
author | James Perkins <james@loowit.net> | 2015-08-17 13:48:39 -0700 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-08-28 23:48:10 -0400 |
commit | be13f5a4baa40af3611208edc77fd588ff2c0fab (patch) | |
tree | 156087370058bd6886da219fd252144ebf504fe3 /ChangeLog | |
parent | cccc95f28ace0be4fe97537dbd867c08fbf71a8e (diff) | |
download | glibc-be13f5a4baa40af3611208edc77fd588ff2c0fab.tar.gz glibc-be13f5a4baa40af3611208edc77fd588ff2c0fab.tar.xz glibc-be13f5a4baa40af3611208edc77fd588ff2c0fab.zip |
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
Diffstat (limited to 'ChangeLog')
-rw-r--r-- | ChangeLog | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index 6c1f804fd2..6f13c33769 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2015-08-28 James Perkins <james@loowit.net> + * time/tst-strptime2.c (tests): Replace short list of test + strings for strptime %z specifier with code which exhaustively + tests every combination of sign and 0 to 5 digits. Tests for + rejection of invalid strings. + +2015-08-28 James Perkins <james@loowit.net> + [BZ #16141] * time/strptime_l.c (__strptime_internal): Fix %z minutes calculation, removing incorrect decimal time rounding, so that |