]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/datetime/datetimetest.cpp
fixing unicode compile
[wxWidgets.git] / tests / datetime / datetimetest.cpp
index e9e430998ed3a2d0b11c2e0953b65d3d930c8cd4..8caa1e71c42495b5170c9bdf45fed509f9834608 100644 (file)
@@ -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)
 };
@@ -637,7 +639,7 @@ void DateTimeTestCase::TestTimeFormat()
 
             // convert back
             wxDateTime dt2;
-            const wxChar *result = dt2.ParseFormat(s, fmt);
+            const wxChar *result = dt2.ParseFormat(s.c_str(), fmt);
             if ( !result )
             {
                 // converion failed - should it have?
@@ -671,6 +673,10 @@ void DateTimeTestCase::TestTimeFormat()
                     case CompareTime:
                         CPPUNIT_ASSERT( dt.IsSameTime(dt2) );
                         break;
+
+                    case CompareNone:
+                        wxFAIL_MSG( _T("unexpected") );
+                        break;
                 }
             }
         }
@@ -848,11 +854,11 @@ void DateTimeTestCase::TestDSTBug()
 {
     /////////////////////////
     // Test GetEndDST()
-    wxDateTime dt = wxDateTime::GetEndDST(2004);
+    wxDateTime dt = wxDateTime::GetEndDST(2004, wxDateTime::France);
     CPPUNIT_ASSERT_EQUAL(31, (int)dt.GetDay());
     CPPUNIT_ASSERT_EQUAL(wxDateTime::Oct, dt.GetMonth());
     CPPUNIT_ASSERT_EQUAL(2004, (int)dt.GetYear());
-    CPPUNIT_ASSERT_EQUAL(2, (int)dt.GetHour());
+    CPPUNIT_ASSERT_EQUAL(1, (int)dt.GetHour());
     CPPUNIT_ASSERT_EQUAL(0, (int)dt.GetMinute());
     CPPUNIT_ASSERT_EQUAL(0, (int)dt.GetSecond());
     CPPUNIT_ASSERT_EQUAL(0, (int)dt.GetMillisecond());
@@ -916,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