diff --git a/test/core/test_strptime_days.c b/test/core/test_strptime_days.c index ff861cc07733..de23fc84de4f 100644 --- a/test/core/test_strptime_days.c +++ b/test/core/test_strptime_days.c @@ -5,6 +5,10 @@ * found in the LICENSE file. */ +// glibc requires _XOPEN_SOURCE to be defined in order to get strptime. +#define _XOPEN_SOURCE + +#include #include #include #include @@ -31,9 +35,14 @@ int main() { for (int i = 0; i < sizeof(day_tests) / sizeof(day_tests[0]); ++i) { memset(&tm, '\0', sizeof(tm)); char *ptr = strptime(day_tests[i].input, day_tests[i].format, &tm); + assert(ptr); - printf("%s: %d/%d/%d (%dth DoW, %dth DoY)\n", - (ptr != NULL && *ptr == '\0') ? "OK" : "ERR", tm.tm_mon + 1, - tm.tm_mday, 1900 + tm.tm_year, tm.tm_wday, tm.tm_yday); + printf("%-23s -> %02d/%02d/%4d (%dth DoW, %3dth DoY)\n", + day_tests[i].input, + tm.tm_mon + 1, + tm.tm_mday, + 1900 + tm.tm_year, + tm.tm_wday, + tm.tm_yday); } } diff --git a/test/core/test_strptime_days.out b/test/core/test_strptime_days.out index dc4090326a3d..913d56cc0a29 100644 --- a/test/core/test_strptime_days.out +++ b/test/core/test_strptime_days.out @@ -1,12 +1,12 @@ -OK: 1/1/2000 (6th DoW, 0th DoY) -OK: 3/3/2000 (5th DoW, 62th DoY) -OK: 9/9/1999 (4th DoW, 251th DoY) -OK: 5/2/1999 (0th DoW, 121th DoY) -OK: 5/21/2001 (1th DoW, 140th DoY) -OK: 1/27/2006 (5th DoW, 26th DoY) -OK: 5/21/2001 (1th DoW, 140th DoY) -OK: 7/24/2013 (3th DoW, 204th DoY) -OK: 1/1/2000 (6th DoW, 0th DoY) -OK: 1/1/2000 (6th DoW, 0th DoY) -OK: 5/1/2001 (2th DoW, 120th DoY) -OK: 2/22/2001 (4th DoW, 52th DoY) +2000-01-01 -> 01/01/2000 (6th DoW, 0th DoY) +03/03/00 -> 03/03/2000 (5th DoW, 62th DoY) +9/9/99 -> 09/09/1999 (4th DoW, 251th DoY) +19990502123412 -> 05/02/1999 (0th DoW, 121th DoY) +2001 20 Mon -> 05/21/2001 (1th DoW, 140th DoY) +2006 4 Fri -> 01/27/2006 (5th DoW, 26th DoY) +2001 21 Mon -> 05/21/2001 (1th DoW, 140th DoY) +2013 29 Wed -> 07/24/2013 (3th DoW, 204th DoY) +2000-01-01 08:12:21 AM -> 01/01/2000 (6th DoW, 0th DoY) +2000-01-01 08:12:21 PM -> 01/01/2000 (6th DoW, 0th DoY) +2001 17 Tue -> 05/01/2001 (2th DoW, 120th DoY) +2001 8 Thursday -> 02/22/2001 (4th DoW, 52th DoY)