X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9807f995059c9049505a67c1ba3535e6c43362d1..09b86e698cbe7a7d0663aceac0b2b9ea29a040f1:/tests/datetime/datetimetest.cpp diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 8f9971c4c4..db64b5c53e 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -191,6 +191,7 @@ private: CPPUNIT_TEST( TestDateParse ); CPPUNIT_TEST( TestTimeArithmetics ); CPPUNIT_TEST( TestDSTBug ); + CPPUNIT_TEST( TestDateOnly ); CPPUNIT_TEST_SUITE_END(); void TestLeapYears(); @@ -206,6 +207,7 @@ private: void TestDateParse(); void TestTimeArithmetics(); void TestDSTBug(); + void TestDateOnly(); DECLARE_NO_COPY_CLASS(DateTimeTestCase) }; @@ -671,6 +673,10 @@ void DateTimeTestCase::TestTimeFormat() case CompareTime: CPPUNIT_ASSERT( dt.IsSameTime(dt2) ); break; + + case CompareNone: + wxFAIL_MSG( _T("unexpected") ); + break; } } } @@ -686,9 +692,18 @@ void DateTimeTestCase::TestTimeSpanFormat() const wxChar *result; } testSpans[] = { - { 12, 34, 56, 789, _T("%H:%M:%S.%l"), _T("12:34:56.789") }, - { 1, 2, 3, 0, _T("%H:%M:%S"), _T("01:02:03") }, - { 1, 2, 3, 0, _T("%S"), _T("3723") }, + { 12, 34, 56, 789, _T("%H:%M:%S.%l"), _T("12:34:56.789") }, + { 1, 2, 3, 0, _T("%H:%M:%S"), _T("01:02:03") }, + { 1, 2, 3, 0, _T("%S"), _T("3723") }, + { -1, -2, -3, 0, _T("%S"), _T("-3723") }, + { -1, -2, -3, 0, _T("%H:%M:%S"), _T("-01:02:03") }, + { 26, 0, 0, 0, _T("%H"), _T("26") }, + { 26, 0, 0, 0, _T("%D, %H"), _T("1, 02") }, + { -26, 0, 0, 0, _T("%H"), _T("-26") }, + { -26, 0, 0, 0, _T("%D, %H"), _T("-1, 02") }, + { 219, 0, 0, 0, _T("%H"), _T("219") }, + { 219, 0, 0, 0, _T("%D, %H"), _T("9, 03") }, + { 219, 0, 0, 0, _T("%E, %D, %H"), _T("1, 2, 03") }, }; for ( size_t n = 0; n < WXSIZEOF(testSpans); n++ ) @@ -907,4 +922,20 @@ void DateTimeTestCase::TestDSTBug() #endif // CHANGE_SYSTEM_DATE } +void DateTimeTestCase::TestDateOnly() +{ + wxDateTime dt(19, wxDateTime::Jan, 2007, 15, 01, 00); + + static const wxDateTime::wxDateTime_t DATE_ZERO = 0; + CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetHour() ); + CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetMinute() ); + CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetSecond() ); + CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetMillisecond() ); + + dt.ResetTime(); + CPPUNIT_ASSERT_EQUAL( wxDateTime(19, wxDateTime::Jan, 2007), dt ); + + CPPUNIT_ASSERT_EQUAL( wxDateTime::Today(), wxDateTime::Now().GetDateOnly() ); +} + #endif // wxUSE_DATETIME