]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/filename/filenametest.cpp
Resolve ambiguity between GetClientXXX() methods in wxOSX wxComboBox.
[wxWidgets.git] / tests / filename / filenametest.cpp
index 69b7ae8202847ea2514082d96cd88f7d155f55df..a1ea735acde3f7d86e30bbd1054babe7294576a1 100644 (file)
@@ -158,7 +158,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( FileNameTestCase );
 
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( FileNameTestCase );
 
-// 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( FileNameTestCase, "FileNameTestCase" );
 
 void FileNameTestCase::TestConstruction()
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileNameTestCase, "FileNameTestCase" );
 
 void FileNameTestCase::TestConstruction()
@@ -322,8 +322,11 @@ void FileNameTestCase::TestNormalize()
 
         // test wxPATH_NORM_DOTS
         { "a/.././b/c/../../", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
 
         // test wxPATH_NORM_DOTS
         { "a/.././b/c/../../", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
-        { "./", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
-        { "b/../", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
+        { "", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
+        { "./foo", wxPATH_NORM_DOTS, "foo", wxPATH_UNIX },
+        { "b/../bar", wxPATH_NORM_DOTS, "bar", wxPATH_UNIX },
+        { "c/../../quux", wxPATH_NORM_DOTS, "../quux", wxPATH_UNIX },
+        { "/c/../../quux", wxPATH_NORM_DOTS, "/quux", wxPATH_UNIX },
 
         // test wxPATH_NORM_TILDE: notice that ~ is only interpreted specially
         // when it is the first character in the file name
 
         // test wxPATH_NORM_TILDE: notice that ~ is only interpreted specially
         // when it is the first character in the file name
@@ -586,36 +589,46 @@ void FileNameTestCase::TestCreateTempFileName()
     {
         const char *prefix;
         const char *expectedFolder;
     {
         const char *prefix;
         const char *expectedFolder;
-        bool shouldFail;
+        bool shouldSucceed;
     } testData[] =
     {
     } testData[] =
     {
-        { "", "$SYSTEM_TEMP", false },
-        { "foo", "$SYSTEM_TEMP", false },
-        { "..", "$SYSTEM_TEMP", false },
-        { "../bar", "..", false },
+        { "", "$SYSTEM_TEMP", true },
+        { "foo", "$SYSTEM_TEMP", true },
+        { "..", "$SYSTEM_TEMP", true },
+        { "../bar", "..", true },
 #ifdef __WXMSW__
 #ifdef __WXMSW__
-        { "c:\\a\\place\\which\\does\\not\\exist", "", true },
-#else if defined( __UNIX__ )
-        { "/tmp/foo", "/tmp", false },
-        { "/tmp/foo/bar", "", true },
+        { "$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++ )
     {
 #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());
 
 
-        if (!testData[n].shouldFail)
+        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].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());
             // 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:
 
             // 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) );
         }
     }
 }
         }
     }
 }