From fec33079edf65529217d86a0e0e38e7f2b92f483 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Oct 2020 21:14:27 +0200 Subject: [PATCH] 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. --- tests/intl/intltest.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/intl/intltest.cpp b/tests/intl/intltest.cpp index 57cfb44096..a7e90e71bb 100644 --- a/tests/intl/intltest.cpp +++ b/tests/intl/intltest.cpp @@ -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",