]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/strings/numformatter.cpp
Basque translations update from Xabier Aramendi.
[wxWidgets.git] / tests / strings / numformatter.cpp
index 7d5971901e17597ab750885d53929d87a24a9d0f..9a3b2c5e7b034838aa3d2427194b88592fb47451 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     wxNumberFormatter unit test
 // Author:      Vadim Zeitlin
 // Created:     2011-01-15
-// RCS-ID:      $Id$
 // Copyright:   (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
 ///////////////////////////////////////////////////////////////////////////////
 
 class NumFormatterTestCase : public CppUnit::TestCase
 {
 public:
-    NumFormatterTestCase()
+    NumFormatterTestCase() { m_locale = NULL; }
+
+    virtual void setUp()
     {
         // We need to use a locale with known decimal point and which uses the
         // thousands separator for the tests to make sense.
-        wxLanguage lang;
-        if ( wxLocale::IsAvailable(wxLANGUAGE_ENGLISH_US) )
-            lang = wxLANGUAGE_ENGLISH_US;
-        else if ( wxLocale::IsAvailable(wxLANGUAGE_ENGLISH_UK) )
-            lang = wxLANGUAGE_ENGLISH_UK;
-        else
-        {
-            m_locale = NULL;
-            return;
-        }
-
-        m_locale = new wxLocale(lang, wxLOCALE_DONT_LOAD_DEFAULT);
+        m_locale = new wxLocale(wxLANGUAGE_ENGLISH_UK,
+                                wxLOCALE_DONT_LOAD_DEFAULT);
+        if ( !m_locale->IsOk() )
+            tearDown();
     }
 
-    virtual ~NumFormatterTestCase()
+    virtual void tearDown()
     {
         delete m_locale;
+        m_locale = NULL;
     }
 
 private:
@@ -85,7 +79,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( NumFormatterTestCase );
 
-// 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( NumFormatterTestCase, "NumFormatterTestCase" );
 
 // ----------------------------------------------------------------------------
@@ -98,13 +92,21 @@ void NumFormatterTestCase::LongToString()
         return;
 
     CPPUNIT_ASSERT_EQUAL(          "1", wxNumberFormatter::ToString(         1L));
+    CPPUNIT_ASSERT_EQUAL(         "-1", wxNumberFormatter::ToString(        -1L));
     CPPUNIT_ASSERT_EQUAL(         "12", wxNumberFormatter::ToString(        12L));
+    CPPUNIT_ASSERT_EQUAL(        "-12", wxNumberFormatter::ToString(       -12L));
     CPPUNIT_ASSERT_EQUAL(        "123", wxNumberFormatter::ToString(       123L));
+    CPPUNIT_ASSERT_EQUAL(       "-123", wxNumberFormatter::ToString(      -123L));
     CPPUNIT_ASSERT_EQUAL(      "1,234", wxNumberFormatter::ToString(      1234L));
+    CPPUNIT_ASSERT_EQUAL(     "-1,234", wxNumberFormatter::ToString(     -1234L));
     CPPUNIT_ASSERT_EQUAL(     "12,345", wxNumberFormatter::ToString(     12345L));
+    CPPUNIT_ASSERT_EQUAL(    "-12,345", wxNumberFormatter::ToString(    -12345L));
     CPPUNIT_ASSERT_EQUAL(    "123,456", wxNumberFormatter::ToString(    123456L));
+    CPPUNIT_ASSERT_EQUAL(   "-123,456", wxNumberFormatter::ToString(   -123456L));
     CPPUNIT_ASSERT_EQUAL(  "1,234,567", wxNumberFormatter::ToString(   1234567L));
+    CPPUNIT_ASSERT_EQUAL( "-1,234,567", wxNumberFormatter::ToString(  -1234567L));
     CPPUNIT_ASSERT_EQUAL( "12,345,678", wxNumberFormatter::ToString(  12345678L));
+    CPPUNIT_ASSERT_EQUAL("-12,345,678", wxNumberFormatter::ToString( -12345678L));
     CPPUNIT_ASSERT_EQUAL("123,456,789", wxNumberFormatter::ToString( 123456789L));
 }