Skip to content

Commit dfb4520

Browse files
committed
removing leading zero in datetime test
1 parent 085dccd commit dfb4520

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

tests/date_time_test.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class DateTimeTest : public ::testing::Test
3838
}
3939
};
4040

41+
std::wstring RemoveLeadingZeros(std::wstring& str) {
42+
while (str.length() > 0 && str[0] == L'0') {
43+
str.erase(str.begin());
44+
}
45+
return str;
46+
}
47+
4148
void ControlRoundTrip(const int64_t& time_point, const wchar_t* sys_time) {
4249
DatetimeContainer f;
4350
f.id = 0;
@@ -49,8 +56,13 @@ void ControlRoundTrip(const int64_t& time_point, const wchar_t* sys_time) {
4956
const auto retrieved = db.FetchAll<DatetimeContainer>();
5057
EXPECT_EQ(1, retrieved.size());
5158

52-
const auto system_time = retrieved[0].creation_date.SystemTime();
53-
EXPECT_EQ(std::wstring(sys_time), system_time);
59+
auto sys_time_actual = retrieved[0].creation_date.SystemTime();
60+
sys_time_actual = RemoveLeadingZeros(sys_time_actual);
61+
62+
auto sys_time_expected = std::wstring(sys_time);
63+
sys_time_expected = RemoveLeadingZeros(sys_time_expected);
64+
65+
EXPECT_EQ(sys_time_expected, sys_time_actual);
5466
}
5567

5668
TEST_F(DateTimeTest, UnixEpoch) {

0 commit comments

Comments
 (0)