]> git.saurik.com Git - wxWidgets.git/commitdiff
give better error messages when tests fail
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Mar 2009 23:22:37 +0000 (23:22 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Mar 2009 23:22:37 +0000 (23:22 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/datetime/datetimetest.cpp

index 8fed158607ab5e77f44823adf537030bece163d8..1712c1f1c2954abe99dcec69924628d4958c4c0b 100644 (file)
@@ -649,7 +649,7 @@ void DateTimeTestCase::TestTimeFormat()
         for ( size_t n = 0; n < WXSIZEOF(formatTestFormats); n++ )
         {
             const char *fmt = formatTestFormats[n].format;
         for ( size_t n = 0; n < WXSIZEOF(formatTestFormats); n++ )
         {
             const char *fmt = formatTestFormats[n].format;
-            
+
             // skip the check with %p for those locales which have empty AM/PM strings:
             // for those locales it's impossible to pass the test with %p...
             wxString am, pm;
             // skip the check with %p for those locales which have empty AM/PM strings:
             // for those locales it's impossible to pass the test with %p...
             wxString am, pm;
@@ -674,7 +674,7 @@ void DateTimeTestCase::TestTimeFormat()
             {
                 // ParseFormat() should have parsed the entire string or left
                 // some final useless strings (e.g. with Italian locale the
             {
                 // ParseFormat() should have parsed the entire string or left
                 // some final useless strings (e.g. with Italian locale the
-                // 's' string for the first test date looks like 
+                // 's' string for the first test date looks like
                 //      "---> sab 29 mag 1976 18:30:00 CET"
                 // so we just need to ignore CET)
                 CPPUNIT_ASSERT( !*result || strcmp(result, "CET") == 0 );
                 //      "---> sab 29 mag 1976 18:30:00 CET"
                 // so we just need to ignore CET)
                 CPPUNIT_ASSERT( !*result || strcmp(result, "CET") == 0 );
@@ -907,15 +907,24 @@ void DateTimeTestCase::TestDateParse()
 
     for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
     {
 
     for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
     {
-        if ( dt.ParseDate(parseTestDates[n].str) )
+        const char * const datestr = parseTestDates[n].str;
+
+        const char * const end = dt.ParseDate(datestr);
+        if ( end && !*end )
         {
         {
-            CPPUNIT_ASSERT( parseTestDates[n].good );
+            WX_ASSERT_MESSAGE(
+                ("Erroneously parsed \"%s\"", datestr),
+                parseTestDates[n].good
+            );
 
             CPPUNIT_ASSERT_EQUAL( parseTestDates[n].date.DT(), dt );
         }
         else // failed to parse
         {
 
             CPPUNIT_ASSERT_EQUAL( parseTestDates[n].date.DT(), dt );
         }
         else // failed to parse
         {
-            CPPUNIT_ASSERT( !parseTestDates[n].good );
+            WX_ASSERT_MESSAGE(
+                ("Failed to parse \"%s\"", datestr),
+                !parseTestDates[n].good
+            );
         }
     }
 }
         }
     }
 }
@@ -1011,14 +1020,24 @@ void DateTimeTestCase::TestDateTimeParse()
     wxDateTime dt;
     for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
     {
     wxDateTime dt;
     for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
     {
-        if ( dt.ParseDateTime(parseTestDates[n].str) )
+        const char * const datestr = parseTestDates[n].str;
+
+        if ( dt.ParseDateTime(datestr) )
         {
         {
-            CPPUNIT_ASSERT( parseTestDates[n].good );
+            WX_ASSERT_MESSAGE(
+                ("Erroneously parsed \"%s\"", datestr),
+                parseTestDates[n].good
+            );
 
             CPPUNIT_ASSERT_EQUAL( parseTestDates[n].date.DT(), dt );
         }
         else // failed to parse
         {
 
             CPPUNIT_ASSERT_EQUAL( parseTestDates[n].date.DT(), dt );
         }
         else // failed to parse
         {
+            WX_ASSERT_MESSAGE(
+                ("Failed to parse \"%s\"", datestr),
+                !parseTestDates[n].good
+            );
+
             CPPUNIT_ASSERT( !parseTestDates[n].good );
         }
     }
             CPPUNIT_ASSERT( !parseTestDates[n].good );
         }
     }