]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/xlocale/xlocale.cpp
Don't use GetThreadId() in wxMSW code.
[wxWidgets.git] / tests / xlocale / xlocale.cpp
index 9feddf9a2ccae83e6b21aea955d312467b488690..2b3474b96f51c5c671435e6b55749d5a64b55a8d 100644 (file)
@@ -39,11 +39,13 @@ public:
 private:
     CPPUNIT_TEST_SUITE( XLocaleTestCase );
         CPPUNIT_TEST( TestCtor );
+        CPPUNIT_TEST( PreserveLocale );
         CPPUNIT_TEST( TestCtypeFunctions );
         CPPUNIT_TEST( TestStdlibFunctions );
     CPPUNIT_TEST_SUITE_END();
 
     void TestCtor();
+    void PreserveLocale();
     void TestCtypeFunctions();
     void TestStdlibFunctions();
 
@@ -56,7 +58,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( XLocaleTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( XLocaleTestCase, "XLocaleTestCase" );
 
 
@@ -73,7 +75,7 @@ void XLocaleTestCase::TestCtor()
 
 #ifdef wxHAS_XLOCALE_SUPPORT
     CPPUNIT_ASSERT( wxXLocale(wxLANGUAGE_FRENCH).IsOk() );
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
     CPPUNIT_ASSERT( wxXLocale("french").IsOk() );
 #else
     CPPUNIT_ASSERT( wxXLocale("fr_FR").IsOk() );
@@ -81,6 +83,16 @@ void XLocaleTestCase::TestCtor()
 #endif
 }
 
+void XLocaleTestCase::PreserveLocale()
+{
+    // Test that using locale functions doesn't change the global C locale.
+    const wxString origLocale(setlocale(LC_ALL, NULL));
+
+    wxStrtod_l(wxT("1.234"), NULL, wxCLocale);
+
+    CPPUNIT_ASSERT_EQUAL( origLocale, setlocale(LC_ALL, NULL) );
+}
+
 // test the ctype functions with the given locale
 void XLocaleTestCase::TestCtypeFunctionsWith(const wxXLocale& loc)
 {