mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-20 14:42:02 +00:00
Return two changes
This commit is contained in:
parent
40357637ec
commit
33ffdcaa4f
@ -90,10 +90,10 @@ TEST(DateLUTTest, makeDayNumTest)
|
||||
|
||||
TEST(DateLUTTest, TimeValuesInMiddleOfRange)
|
||||
{
|
||||
const DateLUTImpl & lut = DateLUT::instance("Asia/Istanbul");
|
||||
const DateLUTImpl & lut = DateLUT::instance("Europe/Minsk");
|
||||
const time_t time = 1568650811; // 2019-09-16 19:20:11 (Monday)
|
||||
|
||||
EXPECT_EQ(lut.getTimeZone(), "Asia/Istanbul");
|
||||
EXPECT_EQ(lut.getTimeZone(), "Europe/Minsk");
|
||||
EXPECT_EQ(lut.getOffsetAtStartOfEpoch(), 3600*3); // UTC-3
|
||||
|
||||
EXPECT_EQ(lut.toDate(time), 1568581200);
|
||||
@ -538,3 +538,4 @@ INSTANTIATE_TEST_SUITE_P(AllTimezones_Year1970,
|
||||
// {0, 0 + 11 * 3600 * 24 + 12, 11},
|
||||
}))
|
||||
);
|
||||
|
||||
|
@ -76,3 +76,125 @@ TEST_P(DateTime64StringParseBestEffortTest, parse)
|
||||
|
||||
EXPECT_EQ(param.dt64, actual);
|
||||
}
|
||||
|
||||
|
||||
// YYYY-MM-DD HH:MM:SS.NNNNNNNNN
|
||||
INSTANTIATE_TEST_SUITE_P(Basic,
|
||||
DateTime64StringParseTest,
|
||||
::testing::ValuesIn(std::initializer_list<DateTime64StringsTestParam>{
|
||||
{
|
||||
"When subsecond part is missing from string it is set to zero.",
|
||||
"2019-09-16 19:20:17",
|
||||
1568650817'000,
|
||||
3,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When subsecond part is present in string, but it is zero, it is set to zero.",
|
||||
"2019-09-16 19:20:17.0",
|
||||
1568650817'000,
|
||||
3,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When scale is 0, subsecond part is not set.",
|
||||
"2019-09-16 19:20:17",
|
||||
1568650817ULL,
|
||||
0,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When scale is 0, subsecond part is 0 despite being present in string.",
|
||||
"2019-09-16 19:20:17.123",
|
||||
1568650817ULL,
|
||||
0,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When subsecond part is present in string, it is set correctly to DateTime64 value of scale 3.",
|
||||
"2019-09-16 19:20:17.123",
|
||||
1568650817'123,
|
||||
3,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When subsecond part is present in string (and begins with 0), it is set correctly to DateTime64 value of scale 3.",
|
||||
"2019-09-16 19:20:17.012",
|
||||
1568650817'012,
|
||||
3,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When subsecond part scale is smaller than DateTime64 scale, subsecond part is properly adjusted (as if padded from right with zeroes).",
|
||||
"2019-09-16 19:20:17.123",
|
||||
1568650817'12300ULL,
|
||||
5,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When subsecond part scale is larger than DateTime64 scale, subsecond part is truncated.",
|
||||
"2019-09-16 19:20:17.123",
|
||||
1568650817'1ULL,
|
||||
1,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(BestEffort,
|
||||
DateTime64StringParseBestEffortTest,
|
||||
::testing::ValuesIn(std::initializer_list<DateTime64StringsTestParam>{
|
||||
{
|
||||
"When subsecond part is unreasonably large, it truncated to given scale",
|
||||
"2019-09-16 19:20:17.12345678910111213141516171819202122233435363738393031323334353637383940414243444546474849505152535455565758596061626364",
|
||||
1568650817'123456ULL,
|
||||
6,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
// TODO: add negative test cases for invalid strings, verifying that error is reported properly
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Basic,
|
||||
DateTime64StringWriteTest,
|
||||
::testing::ValuesIn(std::initializer_list<DateTime64StringsTestParam>{
|
||||
{
|
||||
"non-zero subsecond part on DateTime64 with scale of 3",
|
||||
"2019-09-16 19:20:17.123",
|
||||
1568650817'123,
|
||||
3,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"non-zero subsecond part on DateTime64 with scale of 5",
|
||||
"2019-09-16 19:20:17.12345",
|
||||
1568650817'12345ULL,
|
||||
5,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"Zero subsecond part is written to string",
|
||||
"2019-09-16 19:20:17.000",
|
||||
1568650817'000ULL,
|
||||
3,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"When scale is 0, subsecond part (and separtor) is missing from string",
|
||||
"2019-09-16 19:20:17",
|
||||
1568650817ULL,
|
||||
0,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
},
|
||||
{
|
||||
"Subsecond part with leading zeroes is written to string correctly",
|
||||
"2019-09-16 19:20:17.001",
|
||||
1568650817'001ULL,
|
||||
3,
|
||||
DateLUT::instance("Europe/Minsk")
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user