From 891159af72653f37ca9f8cbe7c2403a06095dbb6 Mon Sep 17 00:00:00 2001 From: Praveen Arimbrathodiyil Date: Thu, 15 Jan 2009 04:06:41 -0800 Subject: Added tests to check corner cases (leap year start) --- .../kde/kdelibs/kdecore/tests/kcalendartest.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'calendar') diff --git a/calendar/kde/kdelibs/kdecore/tests/kcalendartest.cpp b/calendar/kde/kdelibs/kdecore/tests/kcalendartest.cpp index 8175b5c..87c390e 100644 --- a/calendar/kde/kdelibs/kdecore/tests/kcalendartest.cpp +++ b/calendar/kde/kdelibs/kdecore/tests/kcalendartest.cpp @@ -152,8 +152,35 @@ void KCalendarTest::testIndic() QDate myDate(2009, 1, 11); QVERIFY( calendar->setDate( myDate, 1938, 1, 7) ); myDate = calendar->addMonths( myDate, -1 ); + QCOMPARE( myDate.year(), 2016 ); QCOMPARE( calendar->year( myDate ), 1937 ); QCOMPARE( calendar->month( myDate ), 12 ); + + myDate = QDate::QDate(2009, 3, 22); + QCOMPARE( calendar->year( myDate ), 1931 ); + QCOMPARE( calendar->month( myDate ), 1 ); + QCOMPARE( calendar->day( myDate ), 1 ); + + myDate = QDate::QDate(2009, 3, 21); + QCOMPARE( calendar->year( myDate ), 1930 ); + QCOMPARE( calendar->month( myDate ), 12 ); + QCOMPARE( calendar->day( myDate ), 30 ); + + myDate = QDate::QDate(2008, 3, 22); + QCOMPARE( calendar->year( myDate ), 1930 ); + QCOMPARE( calendar->month( myDate ), 1 ); + QCOMPARE( calendar->day( myDate ), 2 ); + + myDate = QDate::QDate(2008, 3, 21); + QCOMPARE( calendar->year( myDate ), 1930 ); + QCOMPARE( calendar->month( myDate ), 1 ); + QCOMPARE( calendar->day( myDate ), 1 ); + + myDate = QDate::QDate(2008, 3, 20); + QCOMPARE( calendar->year( myDate ), 1929 ); + QCOMPARE( calendar->month( myDate ), 12 ); + QCOMPARE( calendar->day( myDate ), 30 ); + } -- cgit