Skip to content

Commit fd5d65b

Browse files
authored
Update DateTimeTest.cpp
1 parent cc6ad67 commit fd5d65b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/common/DateTimeTest.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,16 @@ class DateTimeTest : public testing::Test {};
77

88
TEST_F(DateTimeTest, CreateTest) {
99
DateTime dt;
10-
EXPECT_EQ(dt.year, 2025);
10+
const time_t ts = ::time(nullptr);
11+
tm now{};
12+
#if defined(_WIN32)
13+
::localtime_s(&now, &ts);
14+
+#else
15+
::localtime_r(&ts, &now);
16+
+#endif
17+
EXPECT_EQ(dt.year, static_cast<uint32_t>(now.tm_year + 1900));
18+
EXPECT_GE(dt.month, 1u);
19+
EXPECT_LE(dt.month, 12u);
20+
EXPECT_GE(dt.day, 1u);
21+
EXPECT_LE(dt.day, 31u);
1122
}

0 commit comments

Comments
 (0)