10
10
#include " test/UnitTest/Test.h"
11
11
12
12
TEST (LlvmLibcLocaltimeR, ValidUnixTimestamp0) {
13
- struct tm *input = nullptr ;
13
+ struct tm input = {
14
+ .tm_sec = 0 ,
15
+ .tm_min = 0 ,
16
+ .tm_hour = 0 ,
17
+ .tm_mday = 0 ,
18
+ .tm_mon = 0 ,
19
+ .tm_year = 0 ,
20
+ .tm_wday = 0 ,
21
+ .tm_yday = 0 ,
22
+ .tm_isdst = 0
23
+ };
14
24
const time_t timer = 0 ;
15
25
16
- struct tm *result = LIBC_NAMESPACE::localtime_r (&timer, input);
26
+ struct tm *result = LIBC_NAMESPACE::localtime_r (&timer, & input);
17
27
18
28
ASSERT_EQ (70 , result->tm_year );
19
29
ASSERT_EQ (0 , result->tm_mon );
@@ -32,9 +42,19 @@ TEST(LlvmLibcLocaltimeR, ValidUnixTimestamp0) {
32
42
// This will be resolved a new pull request.
33
43
34
44
TEST (LlvmLibcLocaltimeR, ValidUnixTimestamp) {
35
- struct tm *input = nullptr ;
45
+ struct tm input = {
46
+ .tm_sec = 0 ,
47
+ .tm_min = 0 ,
48
+ .tm_hour = 0 ,
49
+ .tm_mday = 0 ,
50
+ .tm_mon = 0 ,
51
+ .tm_year = 0 ,
52
+ .tm_wday = 0 ,
53
+ .tm_yday = 0 ,
54
+ .tm_isdst = 0
55
+ };
36
56
const time_t timer = 1756595338 ;
37
- struct tm *result = LIBC_NAMESPACE::localtime_r (&timer, input);
57
+ struct tm *result = LIBC_NAMESPACE::localtime_r (&timer, & input);
38
58
39
59
ASSERT_EQ (125 , result->tm_year );
40
60
ASSERT_EQ (7 , result->tm_mon );
@@ -48,9 +68,19 @@ TEST(LlvmLibcLocaltimeR, ValidUnixTimestamp) {
48
68
}
49
69
50
70
TEST (LlvmLibcLocaltimeR, ValidUnixTimestampNegative) {
51
- struct tm *input = nullptr ;
71
+ struct tm input = {
72
+ .tm_sec = 0 ,
73
+ .tm_min = 0 ,
74
+ .tm_hour = 0 ,
75
+ .tm_mday = 0 ,
76
+ .tm_mon = 0 ,
77
+ .tm_year = 0 ,
78
+ .tm_wday = 0 ,
79
+ .tm_yday = 0 ,
80
+ .tm_isdst = 0
81
+ };
52
82
const time_t timer = -1756595338 ;
53
- struct tm *result = LIBC_NAMESPACE::localtime_r (&timer, input);
83
+ struct tm *result = LIBC_NAMESPACE::localtime_r (&timer, & input);
54
84
55
85
ASSERT_EQ (14 , result->tm_year );
56
86
ASSERT_EQ (4 , result->tm_mon );
0 commit comments