From 34d4d2864cb9b142734fa1f2d8dfd2efe16f2109 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 23 Mar 2009 23:29:10 +0000 Subject: [PATCH] enforce "C" locale for tests which can't work in any other (because test data is in English) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59797 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/datetime/datetimetest.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 1712c1f..4e1ac7f 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -83,6 +83,19 @@ private: #endif // CHANGE_SYSTEM_DATE +// helper class setting the locale to "C" for its lifetime +class CLocaleSetter +{ +public: + CLocaleSetter() : m_locOld(setlocale(LC_ALL, "C")) { } + ~CLocaleSetter() { setlocale(LC_ALL, m_locOld); } + +private: + const char * const m_locOld; + + wxDECLARE_NO_COPY_CLASS(CLocaleSetter); +}; + // ---------------------------------------------------------------------------- // broken down date representation used for testing // ---------------------------------------------------------------------------- @@ -905,6 +918,10 @@ void DateTimeTestCase::TestDateParse() CPPUNIT_ASSERT( dt.ParseDate(_T("today")) ); CPPUNIT_ASSERT_EQUAL( wxDateTime::Today(), dt ); + // the other test strings use "C" locale so set it for the duration of this + // test + CLocaleSetter cloc; + for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ ) { const char * const datestr = parseTestDates[n].str; @@ -1016,7 +1033,9 @@ void DateTimeTestCase::TestDateTimeParse() { 22, wxDateTime::Nov, 2007, 19, 40, 0}, true }, }; - // special cases + // the test strings use "C" locale so set it for the duration of this test + CLocaleSetter cloc; + wxDateTime dt; for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ ) { -- 2.7.4