diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c index cf79e5971ec..c8acd848bf1 100644 --- a/dlls/msvcrt/tests/time.c +++ b/dlls/msvcrt/tests/time.c @@ -588,13 +588,59 @@ static void test_daylight(void) static void test_strftime(void) { + const struct { + const char *format; + } tests_einval[] = { + {"%C"}, + {"%D"}, + {"%e"}, + {"%F"}, + {"%h"}, + {"%n"}, + {"%R"}, + {"%t"}, + {"%T"}, + {"%u"}, + }; + + const struct { + const char *format; + const char *ret; + struct tm tm; + BOOL todo; + } tests[] = { + {"e%#%e", "e%e", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%c", "01/01/70 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%c", "02/30/70 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE}, + {"%x", "01/01/70", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%X", "00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%a", "Thu", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%A", "Thursday", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%b", "Jan", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%B", "January", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%d", "01", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%#d", "1", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%H", "00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%I", "12", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%j", "001", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%m", "01", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%#M", "0", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%p", "AM", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%U", "00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%W", "00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%U", "01", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }}, + {"%W", "00", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }}, + {"%U", "53", { 0, 0, 0, 1, 0, 70, 0, 365, 0 }}, + {"%W", "52", { 0, 0, 0, 1, 0, 70, 0, 365, 0 }}, + }; + static const wchar_t cW[] = { '%','c',0 }; - static const char expected[] = "01/01/70 00:00:00"; time_t gmt; struct tm* gmt_tm; char buf[256], bufA[256]; WCHAR bufW[256]; long retA, retW; + int i; if (!p_strftime || !p_wcsftime || !p_gmtime) { @@ -608,55 +654,13 @@ static void test_strftime(void) gmt_tm = p_gmtime(&gmt); ok(gmt_tm != NULL, "gmtime failed\n"); - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%C", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%D", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%e", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%F", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%h", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%n", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%R", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%t", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%T", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); - - errno = 0xdeadbeef; - retA = p_strftime(bufA, 256, "%u", gmt_tm); - ok(retA == 0, "expected 0, got %ld\n", retA); - ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + for (i=0; itm_wday = 0; - retA = p_strftime(bufA, 256, "%U", gmt_tm); - ok(retA == 2, "expected 2, got %ld\n", retA); - ok(!strcmp(bufA, "01"), "got %s\n", bufA); - - retA = p_strftime(bufA, 256, "%W", gmt_tm); - ok(retA == 2, "expected 2, got %ld\n", retA); - ok(!strcmp(bufA, "00"), "got %s\n", bufA); - - gmt_tm->tm_yday = 365; - retA = p_strftime(bufA, 256, "%U", gmt_tm); - ok(retA == 2, "expected 2, got %ld\n", retA); - ok(!strcmp(bufA, "53"), "got %s\n", bufA); - - retA = p_strftime(bufA, 256, "%W", gmt_tm); - ok(retA == 2, "expected 2, got %ld\n", retA); - ok(!strcmp(bufA, "52"), "got %s\n", bufA); - - gmt_tm->tm_mon = 1; - gmt_tm->tm_mday = 30; - retA = p_strftime(bufA, 256, "%c", gmt_tm); - todo_wine { - ok(retA == 17, "expected 17, got %ld\n", retA); - ok(!strcmp(bufA, "02/30/70 00:00:00"), "got %s\n", bufA); - } - if(!setlocale(LC_ALL, "Japanese_Japan.932")) { win_skip("Japanese_Japan.932 locale not available\n"); return;