]> git.saurik.com Git - wxWidgets.git/commitdiff
minor change: use a "positive" logic: use shouldSucceed instead of shouldFail and...
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 21 Jun 2010 19:44:27 +0000 (19:44 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 21 Jun 2010 19:44:27 +0000 (19:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/filename/filenametest.cpp

index 69b7ae8202847ea2514082d96cd88f7d155f55df..a45a5db035182cdc92af6233e989d9905f5e3582 100644 (file)
@@ -586,36 +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 },
+        { "", "$SYSTEM_TEMP", true },
+        { "foo", "$SYSTEM_TEMP", true },
+        { "..", "$SYSTEM_TEMP", true },
+        { "../bar", "..", true },
 #ifdef __WXMSW__
-        { "c:\\a\\place\\which\\does\\not\\exist", "", true },
+        { "$USER_DOCS_DIR\\", "$USER_DOCS_DIR", true },
+        { "c:\\a\\directory\\which\\does\\not\\exist", "", false },
 #else if defined( __UNIX__ )
-        { "/tmp/foo", "/tmp", false },
-        { "/tmp/foo/bar", "", true },
+        { "$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());
 
-        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());
-            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) );
         }
     }
 }