summaryrefslogtreecommitdiffstats
path: root/util/draft/date_ut.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/draft/date_ut.cpp
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/draft/date_ut.cpp')
-rw-r--r--util/draft/date_ut.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/util/draft/date_ut.cpp b/util/draft/date_ut.cpp
new file mode 100644
index 00000000000..8c33a6c1cfd
--- /dev/null
+++ b/util/draft/date_ut.cpp
@@ -0,0 +1,36 @@
+#include "date.h"
+
+#include <library/cpp/testing/unittest/registar.h>
+
+Y_UNIT_TEST_SUITE(TDateTest) {
+ Y_UNIT_TEST(ComponentsTest) {
+ {
+ TDate d("20110215");
+ UNIT_ASSERT_EQUAL(d.GetYear(), 2011);
+ UNIT_ASSERT_EQUAL(d.GetMonth(), 2);
+ UNIT_ASSERT_EQUAL(d.GetMonthDay(), 15);
+ UNIT_ASSERT_EQUAL(d.ToStroka("%Y%m%d"), "20110215");
+ UNIT_ASSERT_EQUAL(d.ToStroka(), "20110215");
+ UNIT_ASSERT_EQUAL(d.ToStroka("%Y--%m--%d"), "2011--02--15");
+ UNIT_ASSERT_EQUAL(d.ToStroka("%U"), "07");
+ UNIT_ASSERT_EQUAL(d.GetStartUTC(), 1297728000);
+ }
+ {
+ TDate d(2005, 6, 3);
+ UNIT_ASSERT_EQUAL(d.GetYear(), 2005);
+ UNIT_ASSERT_EQUAL(d.GetMonth(), 6);
+ UNIT_ASSERT_EQUAL(d.GetMonthDay(), 3);
+ UNIT_ASSERT_EQUAL(d.ToStroka(), "20050603");
+ UNIT_ASSERT_EQUAL(d.ToStroka("____%Y__%m____%d"), "____2005__06____03");
+ UNIT_ASSERT_EQUAL(d.GetStartUTC(), 1117756800);
+ }
+ {
+ TDate d("2011-02-15", "%Y-%m-%d");
+ UNIT_ASSERT_EQUAL(d.GetYear(), 2011);
+ UNIT_ASSERT_EQUAL(d.GetMonth(), 2);
+ UNIT_ASSERT_EQUAL(d.GetMonthDay(), 15);
+ UNIT_ASSERT_EQUAL(d.ToStroka("%Y%m%d"), "20110215");
+ UNIT_ASSERT_EQUAL(d.GetStartUTC(), 1297728000);
+ }
+ }
+}