Fix incorrect use of setlocale() in wxLocale::IsAvailable().
The return value of setlocale() was used incorrectly in this code: it represents the newly set locale and not the previously active one so we didn't actually restore the original locale before. Fix the code and check that we do actually restore the locale in a new unit test for it. See #13117. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,12 +43,14 @@ private:
|
||||
CPPUNIT_TEST( Headers );
|
||||
CPPUNIT_TEST( DateTimeFmtFrench );
|
||||
CPPUNIT_TEST( DateTimeFmtC );
|
||||
CPPUNIT_TEST( IsAvailable );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Domain();
|
||||
void Headers();
|
||||
void DateTimeFmtFrench();
|
||||
void DateTimeFmtC();
|
||||
void IsAvailable();
|
||||
|
||||
wxLocale *m_locale;
|
||||
|
||||
@@ -204,4 +206,14 @@ void IntlTestCase::DateTimeFmtC()
|
||||
m_locale->GetInfo(wxLOCALE_TIME_FMT) );
|
||||
}
|
||||
|
||||
void IntlTestCase::IsAvailable()
|
||||
{
|
||||
const wxString origLocale(setlocale(LC_ALL, NULL));
|
||||
|
||||
// Calling IsAvailable() shouldn't change the locale.
|
||||
wxLocale::IsAvailable(wxLANGUAGE_ENGLISH);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( origLocale, setlocale(LC_ALL, NULL) );
|
||||
}
|
||||
|
||||
#endif // wxUSE_INTL
|
||||
|
Reference in New Issue
Block a user