Skip to content

Commit cfb49e0

Browse files
committed
more testcases.
1 parent 653b62f commit cfb49e0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

trantor/unittests/DateUnittest.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <trantor/utils/Date.h>
22
#include <gtest/gtest.h>
33
#include <string>
4+
#include <vector>
45
#include <iostream>
56
using namespace trantor;
67
TEST(Date, constructorTest)
@@ -110,15 +111,18 @@ TEST(Date, DatabaseStringTest)
110111
TEST(Date, TimezoneTest)
111112
{
112113
std::string str0 = "2024-01-01 04:00:00.123";
113-
std::string str1 = "2024-01-01 12:00:00.123 +08:00";
114-
std::string str2 = "2024-01-01 11:00:00.123+0700";
115-
std::string str3 = "2024-01-01 10:00:00.123 0600";
116-
std::string str4 = "2024-01-01 03:00:00.123 -01:00";
117-
std::string str5 = "2024-01-01 02:00:00.123-02:00";
118-
std::string str6 = "2024-01-01 01:00:00.123 -0300";
114+
std::vector<std::string> strs{"2024-01-01 12:00:00.123 +08:00",
115+
"2024-01-01 11:00:00.123+0700",
116+
"2024-01-01 10:00:00.123 0600",
117+
"2024-01-01 03:00:00.123 -01:00",
118+
"2024-01-01 02:00:00.123-02:00",
119+
"2024-01-01 01:00:00.123 -0300",
120+
"2024-01-01 12:00:00.123 08",
121+
"2024-01-01 02:00:00.123-02",
122+
"2024-01-01 14:00:00.123+10"};
119123

120124
auto date = trantor::Date::fromDbString(str0);
121-
for (auto &s : {str1, str2, str3, str4, str5, str6})
125+
for (auto &s : strs)
122126
{
123127
auto dateTz = trantor::Date::parseDatetimeTz(s);
124128
EXPECT_EQ(date.microSecondsSinceEpoch(),

0 commit comments

Comments
 (0)