]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/file/dir.cpp
Use TAbs in debian/rules, not spaces, as it's a makefile.
[wxWidgets.git] / tests / file / dir.cpp
index 50b5b710520f3c30d88a864fe64cca24aa0a289d..c1092139092439dda3b03c8fee36dd5c73cb7f67 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "wx/dir.h"
 #include "wx/filename.h"
+#include "wx/stdpaths.h"
 
 #define DIRTEST_FOLDER      wxString("dirTest_folder")
 #define SEP                 wxFileName::GetPathSeparator()
@@ -176,39 +177,51 @@ void DirTestCase::DirExists()
     {
         { ".", true },
         { "..", true },
+        { "$USER_DOCS_DIR", true },
 #if defined(__WXMSW__)
+        { "$USER_DOCS_DIR\\", true },
+        { "$USER_DOCS_DIR\\\\", true },
         { "..\\..", true },
-        { "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..", /*false*/ true },
-                // FIXME: should fail but it doesn't... looks like a bug in GetFileAttributes() win API
-        { "c:", true },
-        { "c:\\", true },
-        { "c:\\\\", true },
-        { "\\\\share\\file", false },
-        { "c:\\a\\directory\\which\\does\\not\\exist", false },
-        { "c:\\a\\directory\\which\\does\\not\\exist\\", false },
-        { "c:\\a\\directory\\which\\does\\not\\exist\\\\", false },
-        { "test.exe", false }       // not a directory!
+        { "$MSW_DRIVE", true },
+        { "$MSW_DRIVE\\", true },
+        { "$MSW_DRIVE\\\\", true },
+        { "\\\\non_existent_share\\file", false },
+        { "$MSW_DRIVE\\a\\directory\\which\\does\\not\\exist", false },
+        { "$MSW_DRIVE\\a\\directory\\which\\does\\not\\exist\\", false },
+        { "$MSW_DRIVE\\a\\directory\\which\\does\\not\\exist\\\\", false },
+        { "test.exe", false }            // not a directory!
 #elif defined(__UNIX__)
         { "../..", true },
-        { "../../../../../../../../../../../../../../../../../../../..", false },
         { "/", true },
         { "//", true },
         { "/usr/bin", true },
-        { "/usr//bin", false },
-        { "/usr///bin", false }
+        { "/usr//bin", true },
+        { "/usr///bin", true },
+        { "/tmp/a/directory/which/does/not/exist", false },
+        { "/bin/ls", false }             // not a directory!
 #endif
     };
 
+#ifdef __WXMSW__
+    wxString homedrive = wxGetenv("HOMEDRIVE");
+    if ( homedrive.empty() )
+        homedrive = "c:";
+#endif // __WXMSW__
+
     for ( size_t n = 0; n < WXSIZEOF(testData); n++ )
     {
-        wxString errDesc = wxString::Format("failed on directory '%s'", testData[n].dirname);
-        CPPUNIT_ASSERT_EQUAL_MESSAGE(errDesc.ToStdString(), testData[n].shouldExist, wxDir::Exists(testData[n].dirname));
-
-        if (!testData[n].shouldExist)
-        {
-            wxDir d(testData[n].dirname);
-            CPPUNIT_ASSERT(!d.IsOpened());
-        }
+        wxString dirname = testData[n].dirname;
+        dirname.Replace("$USER_DOCS_DIR", wxStandardPaths::Get().GetDocumentsDir());
+
+#ifdef __WXMSW__
+        dirname.Replace("$MSW_DRIVE", homedrive);
+#endif // __WXMSW__
+
+        std::string errDesc = wxString::Format("failed on directory '%s'", dirname).ToStdString();
+        CPPUNIT_ASSERT_EQUAL_MESSAGE(errDesc, testData[n].shouldExist, wxDir::Exists(dirname));
+
+        wxDir d(dirname);
+        CPPUNIT_ASSERT_EQUAL(testData[n].shouldExist, d.IsOpened());
     }
 
     CPPUNIT_ASSERT( wxDir::Exists(wxGetCwd()) );