From: Vadim Zeitlin <vadim@wxwidgets.org> Date: Sun, 3 Oct 2010 17:15:52 +0000 (+0000) Subject: Fix DirTestCase to run on the systems without "C:" drive. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/cb5eef9d872409bb78e48a6db355988e1263df18 Fix DirTestCase to run on the systems without "C:" drive. "C:" drive doesn't need to exist under Windows, rely on HOMEDRIVE environment variable defined in all recent Windows versions to get a valid drive letter (still fall back to "C:" if the variable is not defined -- we could have use wxFSVolume to find it then but this seems like an overkill). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65744 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/tests/file/dir.cpp b/tests/file/dir.cpp index 71e959cc57..c109213909 100644 --- a/tests/file/dir.cpp +++ b/tests/file/dir.cpp @@ -182,13 +182,13 @@ void DirTestCase::DirExists() { "$USER_DOCS_DIR\\", true }, { "$USER_DOCS_DIR\\\\", true }, { "..\\..", true }, - { "c:", true }, - { "c:\\", true }, - { "c:\\\\", true }, + { "$MSW_DRIVE", true }, + { "$MSW_DRIVE\\", true }, + { "$MSW_DRIVE\\\\", true }, { "\\\\non_existent_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 }, + { "$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 }, @@ -202,11 +202,21 @@ void DirTestCase::DirExists() #endif }; +#ifdef __WXMSW__ + wxString homedrive = wxGetenv("HOMEDRIVE"); + if ( homedrive.empty() ) + homedrive = "c:"; +#endif // __WXMSW__ + for ( size_t n = 0; n < WXSIZEOF(testData); n++ ) { 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));