From 3aa3163f66b4cc26b1f9a5ee6d4263b1a4d0092e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 23 Mar 2009 23:22:37 +0000 Subject: [PATCH] give better error messages when tests fail git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/datetime/datetimetest.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 8fed158..1712c1f 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -649,7 +649,7 @@ void DateTimeTestCase::TestTimeFormat() 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; @@ -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 - // '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 ); @@ -907,15 +907,24 @@ void DateTimeTestCase::TestDateParse() 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( !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++ ) { - 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 { + WX_ASSERT_MESSAGE( + ("Failed to parse \"%s\"", datestr), + !parseTestDates[n].good + ); + CPPUNIT_ASSERT( !parseTestDates[n].good ); } } -- 2.7.4