summaryrefslogtreecommitdiff
path: root/tools/qa
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-20 18:32:57 +0200
committerEike Rathke <erack@redhat.com>2017-07-21 12:24:27 +0200
commitfcd0361d6be8d088be12e500f0120afd7995d1ac (patch)
tree9e18c0310405d68d9151db9073cc8f6926df077d /tools/qa
parent2e486daff35ab16e810bfdafb24b19bcbf2fe8cd (diff)
Eliminate Date::operator+=() and -=() and replace with Date::AddDays()
Clarifies code and gets rid of explicitly casting the operand to sal_Int32. Also in preparation of removing DateTime::operator+=(sal_Int32) that is confusingly similar to DateTime::operator+=(double) and just depends on type. Change-Id: I83422e2940fbb017978db9b5734b4966228af3de Reviewed-on: https://gerrit.libreoffice.org/40248 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'tools/qa')
-rw-r--r--tools/qa/cppunit/test_date.cxx30
1 files changed, 20 insertions, 10 deletions
diff --git a/tools/qa/cppunit/test_date.cxx b/tools/qa/cppunit/test_date.cxx
index 4f36baa07564..74d37efe5201 100644
--- a/tools/qa/cppunit/test_date.cxx
+++ b/tools/qa/cppunit/test_date.cxx
@@ -39,9 +39,11 @@ void DateTest::testDate()
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(1), aCE - aBCE);
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(-1), aBCE - aCE);
aDate = aBCE;
- CPPUNIT_ASSERT_EQUAL( aCE.GetDate(), (aDate += 1).GetDate());
+ aDate.AddDays(1);
+ CPPUNIT_ASSERT_EQUAL( aCE.GetDate(), aDate.GetDate());
aDate = aCE;
- CPPUNIT_ASSERT_EQUAL( aBCE.GetDate(), (aDate -= 1).GetDate());
+ aDate.AddDays(-1);
+ CPPUNIT_ASSERT_EQUAL( aBCE.GetDate(), aDate.GetDate());
// The entire BCE and CE ranges cover that many days. Day 0 is -0001-12-31
CPPUNIT_ASSERT_EQUAL( kMaxDays, aMax - aBCE);
@@ -49,13 +51,17 @@ void DateTest::testDate()
// Truncate at limits, not under-/overflow or wrap.
aDate = aMin;
- CPPUNIT_ASSERT_EQUAL( aMin.GetDate(), (aDate -= 1).GetDate());
+ aDate.AddDays(-1);
+ CPPUNIT_ASSERT_EQUAL( aMin.GetDate(), aDate.GetDate());
aDate = aMax;
- CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), (aDate += 1).GetDate());
+ aDate.AddDays(1);
+ CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), aDate.GetDate());
aDate = aBCE;
- CPPUNIT_ASSERT_EQUAL( aMin.GetDate(), (aDate += (kMinDays-10)).GetDate());
+ aDate.AddDays(kMinDays-10);
+ CPPUNIT_ASSERT_EQUAL( aMin.GetDate(), aDate.GetDate());
aDate = aBCE;
- CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), (aDate += (kMaxDays+10)).GetDate());
+ aDate.AddDays(kMaxDays+10);
+ CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), aDate.GetDate());
aDate = aMax;
aDate.SetDay(32);
aDate.Normalize();
@@ -109,14 +115,18 @@ void DateTest::testDate()
// Year -1 is a leap year.
aDate = Date(28,2,-1);
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-1).GetDate(), (aDate += 1).GetDate());
+ aDate.AddDays(1);
+ CPPUNIT_ASSERT_EQUAL( Date(29,2,-1).GetDate(), aDate.GetDate());
aDate = Date(1,3,-1);
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-1).GetDate(), (aDate -= 1).GetDate());
+ aDate.AddDays(-1);
+ CPPUNIT_ASSERT_EQUAL( Date(29,2,-1).GetDate(), aDate.GetDate());
// Year -5 is a leap year.
aDate = Date(28,2,-5);
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-5).GetDate(), (aDate += 1).GetDate());
+ aDate.AddDays(1);
+ CPPUNIT_ASSERT_EQUAL( Date(29,2,-5).GetDate(), aDate.GetDate());
aDate = Date(1,3,-5);
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-5).GetDate(), (aDate -= 1).GetDate());
+ aDate.AddDays(-1);
+ CPPUNIT_ASSERT_EQUAL( Date(29,2,-5).GetDate(), aDate.GetDate());
}
CPPUNIT_TEST_SUITE_REGISTRATION(DateTest);