]> git.saurik.com Git - apple/libc.git/blob - tests/strptime.c
7cbca30b5bfd12e58a08e3ef19b695f0fcd45190
[apple/libc.git] / tests / strptime.c
1 #include <time.h>
2
3 #include <darwintest.h>
4 #include <darwintest_utils.h>
5
6 T_DECL(strptime_PR_27004626, "strptime() should fail when a %t doesn't match anything")
7 {
8 struct tm tm;
9 T_ASSERT_NULL(strptime("there'snotemplateforthis", "%t", &tm), NULL);
10 }
11
12 T_DECL(strptime_PR_29381762, "strptime() sets the tm_wday field incorrectly")
13 {
14 time_t epoch = 0;
15 struct tm t = *localtime(&epoch);
16
17 T_LOG("2015-01-01 12:00:00 -> Thursday");
18 (void)strptime("2015-01-01 12:00:00", "%F %T", &t);
19 T_EXPECT_EQ(t.tm_wday, 4, NULL);
20
21 T_LOG("2015-04-19 12:00:00 -> Sunday");
22 (void)strptime("2015-04-19 12:00:00", "%F %T", &t);
23 T_EXPECT_EQ(t.tm_wday, 0, NULL);
24
25 T_LOG("2009-03-03 12:00:00 -> Tuesday");
26 (void)strptime("2009-03-03 12:00:00", "%F %T", &t);
27 T_EXPECT_EQ(t.tm_wday, 2, NULL);
28
29 T_LOG("1990-02-15 12:00:00 -> Thursday");
30 (void)strptime("1990-02-15 12:00:00", "%F %T", &t);
31 T_EXPECT_EQ(t.tm_wday, 4, NULL);
32
33 T_LOG("1993-03-02 12:00:00 -> Sunday");
34 (void)strptime("1993-03-02 12:00:00", "%F %T", &t);
35 T_EXPECT_EQ(t.tm_wday, 2, NULL);
36 }