Relax French date/time locale unit test to ignore trailing "%Z"

The version of glibc used under Ubuntu 20.04 doesn't have "%Z" in the
French date-time locale, which broke the test there.

Instead of adding even more tests for glibc version, just ignore "%Z" if
it's present, we don't really care about it, we just want to check that
wxLocale::GetInfo() returns something recognizably different from C and
English locale here.
This commit is contained in:
Vadim Zeitlin 2020-10-19 21:14:27 +02:00
parent 035fc5eb37
commit fec33079ed

View File

@ -180,7 +180,7 @@ void IntlTestCase::DateTimeFmtFrench()
static const char *FRENCH_DATE_FMT = "%d.%m.%Y";
#endif
static const char *FRENCH_LONG_DATE_FMT = "%a %d %b %Y";
static const char *FRENCH_DATE_TIME_FMT = "%a %d %b %Y %H:%M:%S %Z";
static const char *FRENCH_DATE_TIME_FMT = "%a %d %b %Y %H:%M:%S";
#else
static const char *FRENCH_DATE_FMT = "%d/%m/%Y";
static const char *FRENCH_LONG_DATE_FMT = "%A %d %B %Y";
@ -192,15 +192,24 @@ void IntlTestCase::DateTimeFmtFrench()
WX_ASSERT_EQUAL_FORMAT( "French long date", FRENCH_LONG_DATE_FMT,
wxLocale::GetInfo(wxLOCALE_LONG_DATE_FMT) );
const wxString fmtDT = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT);
wxString fmtDT = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT);
INFO("French date and time format is \"" << fmtDT << "\"");
#ifdef __WXOSX__
// Things are difficult to test under macOS as the format keeps changing,
// e.g. at some time between 10.10 and 10.12 a new " à " string appeared in
// its middle, so test it piece-wise and hope it doesn't change too much.
INFO("French date and time format is \"" << fmtDT << "\"");
CHECK( fmtDT.StartsWith("%A %d %B %Y") );
CHECK( fmtDT.EndsWith("%H:%M:%S") );
#else
// Some glic versions have " %Z" at the end of the locale and some don't.
// The test is still useful if we just ignore this difference.
#ifdef __GLIBC__
wxString fmtDTWithoutTZ;
if ( fmtDT.EndsWith(" %Z", &fmtDTWithoutTZ) )
fmtDT.swap(fmtDTWithoutTZ);
#endif
WX_ASSERT_EQUAL_FORMAT( "French date and time", FRENCH_DATE_TIME_FMT, fmtDT );
#endif
WX_ASSERT_EQUAL_FORMAT( "French time", "%H:%M:%S",