From f280bcdb5881f4f3cf1893ac9bba0031ae34c548 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Mar 2022 16:16:11 +0100 Subject: [PATCH] Improve error reporting in wxDateTime unit tests Simply use INFO() to give all the information we want to see in case of failure once instead of doing it in multiple WX_ASSERT_MESSAGE() in a more ugly way with extra parentheses. Also use FAIL_CHECK() to keep running the test after the first failure. --- tests/datetime/datetimetest.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 654fe325d5..064575bfb7 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -780,16 +780,19 @@ void DateTimeTestCase::TestTimeFormat() if ( s != dt.ToTimezone(tz).Format(fmt) ) continue; + INFO("Test #" << n << " using format \"" << fmt << "\"" + << ", format result=\"" << s << "\""); + // convert back wxDateTime dt2; const char *result = dt2.ParseFormat(s, fmt); if ( !result ) { // conversion failed - should it have? - WX_ASSERT_MESSAGE( - ("Test #%u failed: failed to parse \"%s\"", n, s), - kind == CompareNone - ); + if ( kind != CompareNone ) + { + FAIL_CHECK("Parsing formatted string failed"); + } } else // conversion succeeded { @@ -800,11 +803,12 @@ void DateTimeTestCase::TestTimeFormat() while ( *result && (*result >= 'A' && *result <= 'Z') ) result++; - WX_ASSERT_MESSAGE( - ("Test #%u failed: \"%s\" was left unparsed in \"%s\"", - n, result, s), - !*result - ); + if ( *result ) + { + INFO("Left unparsed: \"" << result << "\""); + FAIL_CHECK("Parsing didn't consume the entire string"); + continue; + } // Without "%z" we can't recover the time zone used in the // call to Format() so we need to call MakeFromTimezone()