diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
commit | 9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /util/datetime/parser_ut.cpp | |
parent | 8cbc307de0221f84c80c42dcbe07d40727537e2c (diff) | |
download | ydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/datetime/parser_ut.cpp')
-rw-r--r-- | util/datetime/parser_ut.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp index 44834bd0ef..61364af997 100644 --- a/util/datetime/parser_ut.cpp +++ b/util/datetime/parser_ut.cpp @@ -5,8 +5,8 @@ static const time_t SECONDS_PER_HOUR = 3600; static const time_t SECONDS_PER_MINUTE = 60; -Y_UNIT_TEST_SUITE(TDateTimeParseTest) { - Y_UNIT_TEST(TestRfc822Correct) { +Y_UNIT_TEST_SUITE(TDateTimeParseTest) { + Y_UNIT_TEST(TestRfc822Correct) { bool r = false; time_t t = 0; @@ -159,14 +159,14 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { } } - Y_UNIT_TEST(TestRfc822MilitaryZones) { + Y_UNIT_TEST(TestRfc822MilitaryZones) { DoTestMilitaryZones('A', 'I'); DoTestMilitaryZones('K', 'Z'); DoTestMilitaryZones('a', 'i'); DoTestMilitaryZones('k', 'z'); } - Y_UNIT_TEST(TestRfc822IncorrectDates) { + Y_UNIT_TEST(TestRfc822IncorrectDates) { bool r = true; time_t t = 0; @@ -255,7 +255,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT(!r); } - Y_UNIT_TEST(TestRfc822Partial) { + Y_UNIT_TEST(TestRfc822Partial) { TRfc822DateTimeParser p; const char* part1 = "Fri, 4 Mar 05 1"; const char* part2 = "9:34:45 +0300"; @@ -268,7 +268,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954086), p.GetResult(TInstant::Zero())); } - Y_UNIT_TEST(TestIso8601Partial) { + Y_UNIT_TEST(TestIso8601Partial) { TIso8601DateTimeParser p; const char* part1 = "1990-03-15T15:1"; const char* part2 = "6:17+0732"; @@ -281,7 +281,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487058), p.GetResult(TInstant::Zero())); } - Y_UNIT_TEST(TestIso8601Correct) { + Y_UNIT_TEST(TestIso8601Correct) { bool ret; time_t t; @@ -361,7 +361,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(t, 1269775620); } - Y_UNIT_TEST(TestIso8601TimeZone) { + Y_UNIT_TEST(TestIso8601TimeZone) { time_t t1, t2, t3, t4; UNIT_ASSERT(ParseISO8601DateTime("2010-03-28T04:27:00.000+07:00", t1)); UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T21:27:00.000Z", t2)); @@ -372,7 +372,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT_VALUES_EQUAL(t3, t4); } - Y_UNIT_TEST(TestIso8601Incorrect) { + Y_UNIT_TEST(TestIso8601Incorrect) { bool ret; time_t t; @@ -406,7 +406,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { UNIT_ASSERT(!ret); } - Y_UNIT_TEST(TestIso8601Fractions) { + Y_UNIT_TEST(TestIso8601Fractions) { UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseIso8601("2009-09-19 03:37:08.1+04:00"), TInstant::Seconds(1253317028) + TDuration::MilliSeconds(100)); @@ -471,7 +471,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { } } - Y_UNIT_TEST(TestHttpDate) { + Y_UNIT_TEST(TestHttpDate) { UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseHttp("Sun, 06 Nov 1994 08:49:37 GMT"), TInstant::ParseIso8601("1994-11-06T08:49:37Z")); @@ -486,14 +486,14 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { TInstant::ParseIso8601("2037-01-19T08:49:37Z")); } - Y_UNIT_TEST(TestHttpDateIncorrect) { + Y_UNIT_TEST(TestHttpDateIncorrect) { bool ret; time_t t = 0; ret = ParseHTTPDateTime("1990-03-15T15:16:17Z", t); UNIT_ASSERT(!ret); } - Y_UNIT_TEST(TestX509ValidityTime) { + Y_UNIT_TEST(TestX509ValidityTime) { UNIT_ASSERT_VALUES_EQUAL( TInstant::ParseX509Validity("20091014165533Z"), TInstant::ParseRfc822("Wed, 14 Oct 2009 16:55:33 GMT")); @@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { TInstant::ParseRfc822("31 Dec 2019 23:59:59 GMT")); } - Y_UNIT_TEST(TestX509ValidityTimeIncorrect) { + Y_UNIT_TEST(TestX509ValidityTimeIncorrect) { bool ret; time_t t = 0; ret = ParseX509ValidityDateTime("500101000000Z", t); @@ -513,65 +513,65 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { ret = ParseX509ValidityDateTime("091014165533+0300", t); UNIT_ASSERT(!ret); } - - Y_UNIT_TEST(TestTInstantTryParse) { - { + + Y_UNIT_TEST(TestTInstantTryParse) { + { const TStringBuf s = "2009-09-19 03:37:08.1+04:00"; const auto i = TInstant::ParseIso8601(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseIso8601(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseIso8601(s, iTry)); - } - { + } + { const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT"; const auto i = TInstant::ParseRfc822(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseRfc822(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseRfc822(s, iTry)); - } - { + } + { const TStringBuf s = "20091014165533Z"; const auto i = TInstant::ParseX509Validity(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "200asdfasdf533Z"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509(s, iTry)); - } - { + } + { const TStringBuf s = "990104074212Z"; const auto i = TInstant::ParseX509Validity(s); - TInstant iTry; + TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509(s, iTry)); - UNIT_ASSERT_VALUES_EQUAL(i, iTry); - } - { + UNIT_ASSERT_VALUES_EQUAL(i, iTry); + } + { const TStringBuf s = "9901asdf4212Z"; - TInstant iTry; + TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509(s, iTry)); - } - } + } + } } -Y_UNIT_TEST_SUITE(TDurationParseTest) { - Y_UNIT_TEST(TestParse) { +Y_UNIT_TEST_SUITE(TDurationParseTest) { + Y_UNIT_TEST(TestParse) { UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60 * 60 * 24 * 7), TDuration::Parse("1w")); UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60), TDuration::Parse("1m")); UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1.5m")); |