]> git.saurik.com Git - wxWidgets.git/commitdiff
added WX_ASSERT_MESSAGE macro to simply using CPPUNIT_ASSERT_MESSAGE with wxString...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Jan 2008 22:57:09 +0000 (22:57 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Jan 2008 22:57:09 +0000 (22:57 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cppunit.h
tests/datetime/datetimetest.cpp

index 7f1923332a5ac120d83daa703a86c38f8aa7e8ca..9ccc2a93c391d0e016492394f0ef0a0a27c06c12 100644 (file)
 // Use this macro to compare a size_t with a literal integer
 #define WX_ASSERT_SIZET_EQUAL(n, m) CPPUNIT_ASSERT_EQUAL(((size_t)n), m)
 
+
+// Use this macro to assert with the given formatted message (it should contain
+// the format string and arguments in a separate pair of parentheses)
+#define WX_ASSERT_MESSAGE(msg, cond) \
+    CPPUNIT_ASSERT_MESSAGE(std::string(wxString::Format msg .mb_str()), (cond))
+
 ///////////////////////////////////////////////////////////////////////////////
 // define stream inserter for wxString if it's not defined in the main library,
 // we need it to output the test failures involving wxString
index d5e57251a2bb5c61743425dbc25d56abcdaae786..bd297c4ceaebbf93bb0962c00c99fa1da7cf1ea0 100644 (file)
@@ -771,19 +771,27 @@ void DateTimeTestCase::TestParceRFC822()
         },
     };
 
-    for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
+    for ( unsigned n = 0; n < WXSIZEOF(parseTestDates); n++ )
     {
+        const wxChar * const datestr = parseTestDates[n].rfc822;
+
         wxDateTime dt;
-        if ( dt.ParseRfc822Date(parseTestDates[n].rfc822) )
+        if ( dt.ParseRfc822Date(datestr) )
         {
-            CPPUNIT_ASSERT( parseTestDates[n].good );
+            WX_ASSERT_MESSAGE(
+                ("Erroneously parsed \"%s\"", datestr),
+                parseTestDates[n].good
+            );
 
             wxDateTime dtReal = parseTestDates[n].date.DT().FromUTC();
             CPPUNIT_ASSERT_EQUAL( dtReal, dt );
         }
         else // failed to parse
         {
-            CPPUNIT_ASSERT( !parseTestDates[n].good );
+            WX_ASSERT_MESSAGE(
+                ("Failed to parse \"%s\"", datestr),
+                !parseTestDates[n].good
+            );
         }
     }
 }