Skip to content

Commit d66a8de

Browse files
committed
more testcases.
1 parent 63f573b commit d66a8de

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)
@@ -115,15 +116,18 @@ TEST(Date, DatabaseStringTest)
115116
TEST(Date, TimezoneTest)
116117
{
117118
std::string str0 = "2024-01-01 04:00:00.123";
118-
std::string str1 = "2024-01-01 12:00:00.123 +08:00";
119-
std::string str2 = "2024-01-01 11:00:00.123+0700";
120-
std::string str3 = "2024-01-01 10:00:00.123 0600";
121-
std::string str4 = "2024-01-01 03:00:00.123 -01:00";
122-
std::string str5 = "2024-01-01 02:00:00.123-02:00";
123-
std::string str6 = "2024-01-01 01:00:00.123 -0300";
119+
std::vector<std::string> strs{"2024-01-01 12:00:00.123 +08:00",
120+
"2024-01-01 11:00:00.123+0700",
121+
"2024-01-01 10:00:00.123 0600",
122+
"2024-01-01 03:00:00.123 -01:00",
123+
"2024-01-01 02:00:00.123-02:00",
124+
"2024-01-01 01:00:00.123 -0300",
125+
"2024-01-01 12:00:00.123 08",
126+
"2024-01-01 02:00:00.123-02",
127+
"2024-01-01 14:00:00.123+10"};
124128

125129
auto date = trantor::Date::fromDbString(str0);
126-
for (auto &s : {str1, str2, str3, str4, str5, str6})
130+
for (auto &s : strs)
127131
{
128132
auto dateTz = trantor::Date::parseDatetimeTz(s);
129133
EXPECT_EQ(date.microSecondsSinceEpoch(),

0 commit comments

Comments
 (0)