Test for wxXLocale availability directly in the unit test

Apparently a locale can be available at MSW level, so that
wxLocale::IsAvailable() returns true, but not supported by the MSVC CRT,
so that constructing the corresponding wxXLocale fails, which resulted
in wxXLocale unit test failures.

Fix them by checking that wxXLocale can be constructed directly instead
of using wxLocale::IsAvailable() as a proxy.

This is not ideal and perhaps wxLocale::IsAvailable() should check that
the locale is supported in wxXLocale too, but should at least allow unit
tests to pass on AppVeyor for now.
This commit is contained in:
Vadim Zeitlin
2017-11-25 12:11:40 +01:00
parent 62f9438ad3
commit 01cd702ee3

View File

@@ -225,17 +225,20 @@ void XLocaleTestCase::TestStdlibFunctionsWith(const wxXLocale& loc)
void XLocaleTestCase::TestCtypeFunctions()
{
SECTION("C")
{
TestCtypeFunctionsWith(wxCLocale);
}
#ifdef wxHAS_XLOCALE_SUPPORT
// french
if (!wxLocale::IsAvailable(wxLANGUAGE_FRENCH))
return; // you should have french support installed to continue this test!
SECTION("French")
{
wxXLocale locFR(wxLANGUAGE_FRENCH);
CPPUNIT_ASSERT( locFR.IsOk() ); // doesn't make sense to continue otherwise
if ( !locFR.IsOk() )
{
// Not an error, not all systems have French locale support.
return;
}
TestCtypeFunctionsWith(locFR);
@@ -246,25 +249,26 @@ void XLocaleTestCase::TestCtypeFunctions()
CPPUNIT_ASSERT( wxIsalpha_l(wxT('\xe7'), locFR) );
CPPUNIT_ASSERT( wxIslower_l(wxT('\xe7'), locFR) );
CPPUNIT_ASSERT( wxIsupper_l(wxT('\xc7'), locFR) );
}
// italian
if (!wxLocale::IsAvailable(wxLANGUAGE_ITALIAN))
return; // you should have italian support installed to continue this test!
SECTION("Italian")
{
wxXLocale locIT(wxLANGUAGE_ITALIAN);
CPPUNIT_ASSERT( locIT.IsOk() ); // doesn't make sense to continue otherwise
if ( !locIT.IsOk() )
return;
TestCtypeFunctionsWith(locIT);
CPPUNIT_ASSERT( wxIsalpha_l(wxT('\xe1'), locIT) );
CPPUNIT_ASSERT( wxIslower_l(wxT('\xe1'), locIT) );
#endif
}
#endif // wxHAS_XLOCALE_SUPPORT
}
void XLocaleTestCase::TestStdlibFunctions()
{
SECTION("C")
{
TestStdlibFunctionsWith(wxCLocale);
#if wxUSE_UNICODE
@@ -280,16 +284,14 @@ void XLocaleTestCase::TestStdlibFunctions()
CPPUNIT_ASSERT_EQUAL( -1.234E-5, wxStrtod_l(wxT("-1.234E-5"), NULL, wxCLocale) );
CPPUNIT_ASSERT_EQUAL( 365.24, wxStrtod_l(wxT("365.24 29.53"), &endptr, wxCLocale) );
CPPUNIT_ASSERT_EQUAL( 29.53, wxStrtod_l(endptr, NULL, wxCLocale) );
}
#ifdef wxHAS_XLOCALE_SUPPORT
// french
if (!wxLocale::IsAvailable(wxLANGUAGE_FRENCH))
return; // you should have french support installed to continue this test!
SECTION("French")
{
wxXLocale locFR(wxLANGUAGE_FRENCH);
CPPUNIT_ASSERT( locFR.IsOk() ); // doesn't make sense to continue otherwise
if ( !locFR.IsOk() )
return;
TestCtypeFunctionsWith(locFR);
@@ -298,15 +300,14 @@ void XLocaleTestCase::TestStdlibFunctions()
// space as thousands separator is not recognized by wxStrtod_l():
CPPUNIT_ASSERT( 1234.5 != wxStrtod_l(wxT("1 234,5"), NULL, locFR) );
}
// italian
if (!wxLocale::IsAvailable(wxLANGUAGE_ITALIAN))
return; // you should have italian support installed to continue this test!
SECTION("Italian")
{
wxXLocale locIT(wxLANGUAGE_ITALIAN);
CPPUNIT_ASSERT( locIT.IsOk() ); // doesn't make sense to continue otherwise
if ( !locIT.IsOk() )
return;
TestStdlibFunctionsWith(locIT);
@@ -315,7 +316,8 @@ void XLocaleTestCase::TestStdlibFunctions()
// dot as thousands separator is not recognized by wxStrtod_l():
CPPUNIT_ASSERT( 1234.5 != wxStrtod_l(wxT("1.234,5"), NULL, locIT) );
#endif
}
#endif // wxHAS_XLOCALE_SUPPORT
}
#endif // wxUSE_XLOCALE