summaryrefslogtreecommitdiff
path: root/tools/qa
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-04-28 17:14:32 +0200
committerEike Rathke <erack@redhat.com>2017-04-28 17:22:06 +0200
commit8bdbfdb97d94745454b2ad87d341bcb32d10461c (patch)
treee0239fef77d4646175489e654c759ff822cf6fc1 /tools/qa
parent9054648bab5d4d89e7e3654847102d62ab9e77a1 (diff)
Add unit tests for Date::Normalize()
Change-Id: I4edb04748b1f407eb6ce17cd24ff022cef6e1f67
Diffstat (limited to 'tools/qa')
-rw-r--r--tools/qa/cppunit/test_date.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/qa/cppunit/test_date.cxx b/tools/qa/cppunit/test_date.cxx
index 0ee30089b7b5..c2c31e10b51c 100644
--- a/tools/qa/cppunit/test_date.cxx
+++ b/tools/qa/cppunit/test_date.cxx
@@ -56,6 +56,23 @@ void DateTest::testDate()
CPPUNIT_ASSERT_EQUAL( aMin.GetDate(), (aDate += (kMinDays-10)).GetDate());
aDate = aBCE;
CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), (aDate += (kMaxDays+10)).GetDate());
+ aDate = aMax;
+ aDate.SetDay(32);
+ aDate.Normalize();
+ CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), aDate.GetDate());
+
+ // 0001-00-x normalized to -0001-12-x
+ aDate.SetYear(1);
+ aDate.SetMonth(0);
+ aDate.SetDay(22);
+ aDate.Normalize();
+ CPPUNIT_ASSERT_EQUAL( Date(22,12,-1).GetDate(), aDate.GetDate());
+ // 1999-02-32 normalized to 1999-03-04
+ aDate.SetYear(1999);
+ aDate.SetMonth(2);
+ aDate.SetDay(32);
+ aDate.Normalize();
+ CPPUNIT_ASSERT_EQUAL( Date(4,3,1999).GetDate(), aDate.GetDate());
// Year -1 is a leap year.
aDate = Date(28,2,-1);