]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/xlocale/xlocale.cpp
wxRTC: save and load the 'shown' status in case there's a situation where layout...
[wxWidgets.git] / tests / xlocale / xlocale.cpp
index 9feddf9a2ccae83e6b21aea955d312467b488690..d2e8b68bb163aa06ad9ad11410777598ddef2599 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     wxXLocale & related unit test
 // Author:      Brian Vanderburg II, Vadim Zeitlin
 // Created:     2008-01-16
-// RCS-ID:      $Id$
 // Copyright:   (c) 2008 Brian Vanderburg II
 //                  2008 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
@@ -39,11 +38,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 +57,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 +74,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 +82,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)
 {