diff options
author | gotmanov <gotmanov@yandex-team.ru> | 2022-02-10 16:49:26 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:26 +0300 |
commit | b3c1a086292c74ed88830693f15a96ddeadc6b9a (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/timezone_conversion/ut | |
parent | 243edeedfd2c5152b5c7812e0af471e1bb0232e8 (diff) | |
download | ydb-b3c1a086292c74ed88830693f15a96ddeadc6b9a.tar.gz |
Restoring authorship annotation for <gotmanov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/timezone_conversion/ut')
-rw-r--r-- | library/cpp/timezone_conversion/ut/civil_ut.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/library/cpp/timezone_conversion/ut/civil_ut.cpp b/library/cpp/timezone_conversion/ut/civil_ut.cpp index a4e45879af..a21bd4bd7d 100644 --- a/library/cpp/timezone_conversion/ut/civil_ut.cpp +++ b/library/cpp/timezone_conversion/ut/civil_ut.cpp @@ -4,17 +4,17 @@ #include <util/stream/str.h> -namespace NDatetime { +namespace NDatetime { inline bool operator==(const NDatetime::TCivilDiff& x, const NDatetime::TCivilDiff& y) { - return x.Unit == y.Unit && x.Value == y.Value; - } + return x.Unit == y.Unit && x.Value == y.Value; + } +} + +template <> +inline void Out<NDatetime::TCivilDiff>(IOutputStream& out, const NDatetime::TCivilDiff& diff) { + out << "(" << diff.Value << "," << diff.Unit << ")"; } - -template <> -inline void Out<NDatetime::TCivilDiff>(IOutputStream& out, const NDatetime::TCivilDiff& diff) { - out << "(" << diff.Value << "," << diff.Unit << ")"; -} - + Y_UNIT_TEST_SUITE(DateTime) { Y_UNIT_TEST(Calc) { NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); @@ -83,40 +83,40 @@ Y_UNIT_TEST_SUITE(DateTime) { UNIT_ASSERT_VALUES_EQUAL(NDatetime::WeekdayOnTheWeek(d, NDatetime::TWeekday::friday), NDatetime::TCivilDay(2013, 1, 4)); } Y_UNIT_TEST(CivilUnit) { - using namespace NDatetime; - - UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit<TCivilMonth>(), ECivilUnit::Month); - UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit(TCivilHour{}), ECivilUnit::Hour); - - UNIT_ASSERT_VALUES_EQUAL(TCivilTime<ECivilUnit::Day>(2017, 1, 11), TCivilDay(2017, 1, 11)); - - NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); - - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{2, ECivilUnit::Day}), - NDatetime::AddDays(s, 2)); - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{-2, ECivilUnit::Month}), - NDatetime::AddMonths(s, -2)); - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{-55, ECivilUnit::Year}), - NDatetime::AddYears(s, -55)); - UNIT_ASSERT_VALUES_EQUAL( - NDatetime::AddCivil(s, TCivilDiff{40, ECivilUnit::Hour}), - NDatetime::AddHours(s, 40)); - - UNIT_ASSERT_VALUES_EQUAL( - GetCivilDiff(TCivilSecond(2017, 10), TCivilSecond(2017, 7), ECivilUnit::Month), - TCivilDiff(3, ECivilUnit::Month)); - - UNIT_ASSERT_VALUES_EQUAL( - GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 30), ECivilUnit::Month), - TCivilDiff(1, ECivilUnit::Month)); - - UNIT_ASSERT_VALUES_EQUAL( - GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 31), ECivilUnit::Month), - TCivilDiff(0, ECivilUnit::Month)); - } + using namespace NDatetime; + + UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit<TCivilMonth>(), ECivilUnit::Month); + UNIT_ASSERT_VALUES_EQUAL(GetCivilUnit(TCivilHour{}), ECivilUnit::Hour); + + UNIT_ASSERT_VALUES_EQUAL(TCivilTime<ECivilUnit::Day>(2017, 1, 11), TCivilDay(2017, 1, 11)); + + NDatetime::TCivilSecond s(2017, 2, 1, 10, 12, 9); + + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{2, ECivilUnit::Day}), + NDatetime::AddDays(s, 2)); + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{-2, ECivilUnit::Month}), + NDatetime::AddMonths(s, -2)); + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{-55, ECivilUnit::Year}), + NDatetime::AddYears(s, -55)); + UNIT_ASSERT_VALUES_EQUAL( + NDatetime::AddCivil(s, TCivilDiff{40, ECivilUnit::Hour}), + NDatetime::AddHours(s, 40)); + + UNIT_ASSERT_VALUES_EQUAL( + GetCivilDiff(TCivilSecond(2017, 10), TCivilSecond(2017, 7), ECivilUnit::Month), + TCivilDiff(3, ECivilUnit::Month)); + + UNIT_ASSERT_VALUES_EQUAL( + GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 30), ECivilUnit::Month), + TCivilDiff(1, ECivilUnit::Month)); + + UNIT_ASSERT_VALUES_EQUAL( + GetCivilDiff(TCivilSecond(2017, 10, 1), TCivilSecond(2017, 9, 31), ECivilUnit::Month), + TCivilDiff(0, ECivilUnit::Month)); + } Y_UNIT_TEST(TestYearWeekNmb) { |