Show more information if DateTimeTestCase::TestTimeFormat() fails

No real changes, just show the variable values if any checks fail and
also continue running the test for the other data points even if one of
them fails.
This commit is contained in:
Vadim Zeitlin
2017-11-29 23:19:01 +01:00
parent c7c30504c8
commit 4868ec0893

View File

@@ -665,6 +665,15 @@ void DateTimeTestCase::TestTimeFormat()
CompareTime // time only CompareTime // time only
}; };
const char* const compareKindStrings[] =
{
"nothing",
"both date and time",
"both date and time but without century",
"only dates",
"only times",
};
static const struct static const struct
{ {
CompareKind compareKind; CompareKind compareKind;
@@ -785,13 +794,16 @@ void DateTimeTestCase::TestTimeFormat()
if ( !strstr(fmt, "%z") && !isLocalTz ) if ( !strstr(fmt, "%z") && !isLocalTz )
dt2.MakeFromTimezone(tz); dt2.MakeFromTimezone(tz);
INFO("Comparing " << compareKindStrings[kind] << " for "
<< dt << " with " << dt2
<< " (format result=\"" << s << "\")");
switch ( kind ) switch ( kind )
{ {
case CompareYear: case CompareYear:
if ( dt2.GetCentury() != dt.GetCentury() ) if ( dt2.GetCentury() != dt.GetCentury() )
{ {
CPPUNIT_ASSERT_EQUAL(dt.GetYear() % 100, CHECK( dt.GetYear() % 100 == dt2.GetYear() % 100);
dt2.GetYear() % 100);
dt2.SetYear(dt.GetYear()); dt2.SetYear(dt.GetYear());
} }
@@ -799,15 +811,15 @@ void DateTimeTestCase::TestTimeFormat()
wxFALLTHROUGH; wxFALLTHROUGH;
case CompareBoth: case CompareBoth:
CPPUNIT_ASSERT_EQUAL( dt, dt2 ); CHECK( dt == dt2 );
break; break;
case CompareDate: case CompareDate:
CPPUNIT_ASSERT( dt.IsSameDate(dt2) ); CHECK( dt.IsSameDate(dt2) );
break; break;
case CompareTime: case CompareTime:
CPPUNIT_ASSERT( dt.IsSameTime(dt2) ); CHECK( dt.IsSameTime(dt2) );
break; break;
case CompareNone: case CompareNone: