]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/filename/filenametest.cpp
Don't reset bullet number and outline number when applying style sheet.
[wxWidgets.git] / tests / filename / filenametest.cpp
index 175e41bc655d005ad706b2ed671b45761a53f451..dee7cd081ce378975b4de7d04379a551e84e180a 100644 (file)
@@ -503,26 +503,25 @@ void FileNameTestCase::TestGetHumanReadable()
         { "304 KB",    304351, 0, wxSIZE_CONV_SI          },
     };
 
+    CLocaleSetter loc;      // we want to use "C" locale for LC_NUMERIC
+                            // so that regardless of the system's locale
+                            // the decimal point used by GetHumanReadableSize()
+                            // is always '.'
     for ( unsigned n = 0; n < WXSIZEOF(testData); n++ )
     {
         const TestData& td = testData[n];
 
         // take care of using the decimal point for the current locale before
         // the actual comparison
-        wxString result_localized = wxString(td.result);
-        result_localized.Replace(".", wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER));
-
         CPPUNIT_ASSERT_EQUAL
         (
-            result_localized,
+            td.result,
             wxFileName::GetHumanReadableSize(td.size, "NA", td.prec, td.conv)
         );
     }
 
     // also test the default convention value
-    wxString result_localized = wxString("1.4 MB");
-    result_localized.Replace(".", wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER));
-    CPPUNIT_ASSERT_EQUAL( result_localized, wxFileName::GetHumanReadableSize(1512993, "") );
+    CPPUNIT_ASSERT_EQUAL( "1.4 MB", wxFileName::GetHumanReadableSize(1512993, "") );
 }
 
 void FileNameTestCase::TestStrip()
@@ -587,35 +586,46 @@ void FileNameTestCase::TestCreateTempFileName()
     {
         const char *prefix;
         const char *expectedFolder;
-        bool shouldFail;
+        bool shouldSucceed;
     } testData[] =
     {
-        { "", "$SYSTEM_TEMP", false },
-        { "foo", "$SYSTEM_TEMP", false },
-        { "..", "$SYSTEM_TEMP", false },
-        { "../bar", "..", false },
-        { "c:\\a\\place\\which\\does\\not\\exist", "", true },
-#ifdef __UNIX__
-        { "/tmp/foo", "/tmp", false },
-        { "/tmp/foo/bar", "", true },
+        { "", "$SYSTEM_TEMP", true },
+        { "foo", "$SYSTEM_TEMP", true },
+        { "..", "$SYSTEM_TEMP", true },
+        { "../bar", "..", true },
+#ifdef __WXMSW__
+        { "$USER_DOCS_DIR\\", "$USER_DOCS_DIR", true },
+        { "c:\\a\\directory\\which\\does\\not\\exist", "", false },
+#elif defined( __UNIX__ )
+        { "$USER_DOCS_DIR/", "$USER_DOCS_DIR", true },
+        { "/tmp/foo", "/tmp", true },
+        { "/tmp/a/directory/which/does/not/exist", "", false },
 #endif // __UNIX__
     };
 
     for ( size_t n = 0; n < WXSIZEOF(testData); n++ )
     {
-        wxString path = wxFileName::CreateTempFileName(testData[n].prefix);
-        CPPUNIT_ASSERT_EQUAL( path.empty(), testData[n].shouldFail );
+        wxString prefix = testData[n].prefix;
+        prefix.Replace("$USER_DOCS_DIR", wxStandardPaths::Get().GetDocumentsDir());
+
+        std::string errDesc = wxString::Format("failed on prefix '%s'", prefix).ToStdString();
+
+        wxString path = wxFileName::CreateTempFileName(prefix);
+        CPPUNIT_ASSERT_EQUAL_MESSAGE( errDesc, !testData[n].shouldSucceed, path.empty() );
 
-        if (!testData[n].shouldFail)
+        if (testData[n].shouldSucceed)
         {
+            errDesc += "; path is " + path.ToStdString();
+        
             // test the place where the temp file has been created
             wxString expected = testData[n].expectedFolder;
             expected.Replace("$SYSTEM_TEMP", wxStandardPaths::Get().GetTempDir());
-            CPPUNIT_ASSERT_EQUAL(expected, wxFileName(path).GetPath());
+            expected.Replace("$USER_DOCS_DIR", wxStandardPaths::Get().GetDocumentsDir());
+            CPPUNIT_ASSERT_EQUAL_MESSAGE( errDesc, expected, wxFileName(path).GetPath() );
 
             // the temporary file is created with full permissions for the current process
             // so we should always be able to remove it:
-            CPPUNIT_ASSERT( wxRemoveFile(path) );
+            CPPUNIT_ASSERT_MESSAGE( errDesc, wxRemoveFile(path) );
         }
     }
 }