msvcrt/tests: Added more strftime tests.

This commit is contained in:
Piotr Caban 2012-04-11 15:22:44 +02:00 committed by Alexandre Julliard
parent ef08e80765
commit 43d208d215
1 changed files with 102 additions and 0 deletions

View File

@ -599,9 +599,47 @@ static void test_strftime(void)
gmt_tm = p_gmtime(&gmt);
ok(gmt_tm != NULL, "gmtime failed\n");
errno = 0xdeadbeef;
retA = strftime(NULL, 0, "copy", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);
ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
retA = strftime(bufA, 256, "copy", NULL);
ok(retA == 4, "expected 4, got %ld\n", retA);
ok(!strcmp(bufA, "copy"), "got %s\n", bufA);
retA = strftime(bufA, 256, "copy it", gmt_tm);
ok(retA == 7, "expected 7, got %ld\n", retA);
ok(!strcmp(bufA, "copy it"), "got %s\n", bufA);
errno = 0xdeadbeef;
retA = strftime(bufA, 2, "copy", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);
ok(!strcmp(bufA, "") || broken(!strcmp(bufA, "copy it")), "got %s\n", bufA);
ok(errno==ERANGE || errno==0xdeadbeef, "errno = %d\n", errno);
errno = 0xdeadbeef;
retA = strftime(bufA, 256, "a%e", gmt_tm);
ok(retA==0 || broken(retA==1), "expected 0, got %ld\n", retA);
ok(!strcmp(bufA, "") || broken(!strcmp(bufA, "a")), "got %s\n", bufA);
ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
if(0) { /* crashes on Win2k */
errno = 0xdeadbeef;
retA = strftime(bufA, 256, "%c", NULL);
ok(retA == 0, "expected 0, got %ld\n", retA);
ok(!strcmp(bufA, ""), "got %s\n", bufA);
ok(errno == EINVAL, "errno = %d\n", errno);
}
retA = strftime(bufA, 256, "e%#%e", gmt_tm);
ok(retA == 3, "expected 3, got %ld\n", retA);
ok(!strcmp(bufA, "e%e"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%c", gmt_tm);
ok(retA == 17, "expected 17, got %ld\n", retA);
ok(strcmp(bufA, expected) == 0, "expected %s, got %s\n", expected, bufA);
retW = wcsftime(bufW, 256, cW, gmt_tm);
ok(retW == 17, "expected 17, got %ld\n", retW);
ok(retA == retW, "expected %ld, got %ld\n", retA, retW);
@ -609,6 +647,70 @@ static void test_strftime(void)
retA = WideCharToMultiByte(CP_ACP, 0, bufW, retW, buf, 256, NULL, NULL);
buf[retA] = 0;
ok(strcmp(bufA, buf) == 0, "expected %s, got %s\n", bufA, buf);
retA = strftime(bufA, 256, "%x", gmt_tm);
ok(retA == 8, "expected 8, got %ld\n", retA);
ok(!strcmp(bufA, "01/01/70"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%X", gmt_tm);
ok(retA == 8, "expected 8, got %ld\n", retA);
ok(!strcmp(bufA, "00:00:00"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%a", gmt_tm);
ok(retA == 3, "expected 3, got %ld\n", retA);
ok(!strcmp(bufA, "Thu"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%A", gmt_tm);
ok(retA == 8, "expected 8, got %ld\n", retA);
ok(!strcmp(bufA, "Thursday"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%b", gmt_tm);
ok(retA == 3, "expected 3, got %ld\n", retA);
ok(!strcmp(bufA, "Jan"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%B", gmt_tm);
ok(retA == 7, "expected 7, got %ld\n", retA);
ok(!strcmp(bufA, "January"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%d", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "01"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%#d", gmt_tm);
ok(retA == 1, "expected 1, got %ld\n", retA);
ok(!strcmp(bufA, "1"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%H", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "00"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%I", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "12"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%j", gmt_tm);
ok(retA == 3, "expected 3, got %ld\n", retA);
ok(!strcmp(bufA, "001"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%m", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "01"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%#M", gmt_tm);
ok(retA == 1, "expected 1, got %ld\n", retA);
ok(!strcmp(bufA, "0"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%p", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "AM"), "got %s\n", bufA);
gmt_tm->tm_mon = 1;
gmt_tm->tm_mday = 30;
retA = 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);
}
}
static void test_asctime(void)