This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v3 3/4] [BZ #14161] tst-strptime2.c: test %z range to +/-9959


This is part of a fix for [BZ #16141] strptime %z offset restriction.

Add tests to time/tst-strptime2.c to explicitly test the following areas
of strptime's %z input field descriptor:

1) Unable to parse time offsets less than -1200.

* Although there are currently no timezones with offset less than -1200,
  historical time zones exist less than -1500, POSIX supports offsets as
  low as -2459, and offsets as low as -9959 are useful.
* Existing tests are modified to verify valid results for offsets -1201
  and -1330.
* New tests verify offsets -1201, -2459, -2500, -99, and -9959.

2) Unable to parse time offsets greater than +1200.

* Current timezones with offset of +1400, namely Pacific/Kiritimati and
  summer time for Pacific/Apia. Historical time zones exist greater than
  +1500. POSIX supports offsets as high as +2559.  Offsets as high as
  +9959 are useful.
* Existing tests are modified to verify valid results for offsets +1201
  and +1330.
* New tests verify offsets +1400, +1401, +2559, +2600, +99, and +9959.

James

2014-12-03  James Perkins  james@loowit.net

	* time/strptime2.c (tests[]): Modify and add tests for the
	strptime %z input field descriptor, expecting a time zone
	offset range of -9959 to +9959.

---
 time/tst-strptime2.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
index 5f9860a..f5f9a2b 100644
--- a/time/tst-strptime2.c
+++ b/time/tst-strptime2.c
@@ -22,10 +22,20 @@ static const struct
     { "1113472456 +1159", 43140 },
     { "1113472456 +1200", 43200 },
     { "1113472456 -1200", -43200 },
-    { "1113472456 +1201", LONG_MAX },
-    { "1113472456 -1201", LONG_MAX },
-    { "1113472456 -1330", LONG_MAX },
-    { "1113472456 +1330", LONG_MAX },
+    { "1113472456 +1201", 43260 },
+    { "1113472456 -1201", -43260 },
+    { "1113472456 +1330", 48600 },
+    { "1113472456 -1330", -48600 },
+    { "1113472456 +1400", 50400 },
+    { "1113472456 +1401", 50460 },
+    { "1113472456 -2459", -89940 },
+    { "1113472456 -2500", -90000 },
+    { "1113472456 +2559", 93540 },
+    { "1113472456 +2600", 93600 },
+    { "1113472456 -99", -356400 },
+    { "1113472456 +99", 356400 },
+    { "1113472456 -9959", -359940 },
+    { "1113472456 +9959", 359940 },
     { "1113472456 -1060", LONG_MAX },
     { "1113472456 +1060", LONG_MAX },
     { "1113472456  1030", LONG_MAX },
-- 
1.7.9.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]