better DirTestCase::DirExists test;
fix test cases /usr//bin and /usr///bin: they succeed because wxDir::Exists does not care about redundant path separator (and this holds also for non-Unix platforms); add some more test case git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
d6609db5a7
commit
10dee2ae3f
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "wx/dir.h"
|
#include "wx/dir.h"
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
|
#include "wx/stdpaths.h"
|
||||||
|
|
||||||
#define DIRTEST_FOLDER wxString("dirTest_folder")
|
#define DIRTEST_FOLDER wxString("dirTest_folder")
|
||||||
#define SEP wxFileName::GetPathSeparator()
|
#define SEP wxFileName::GetPathSeparator()
|
||||||
@ -176,38 +177,41 @@ void DirTestCase::DirExists()
|
|||||||
{
|
{
|
||||||
{ ".", true },
|
{ ".", true },
|
||||||
{ "..", true },
|
{ "..", true },
|
||||||
|
{ "$USER_DOCS_DIR", true },
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
|
{ "$USER_DOCS_DIR\\", true },
|
||||||
|
{ "$USER_DOCS_DIR\\\\", true },
|
||||||
{ "..\\..", true },
|
{ "..\\..", true },
|
||||||
{ "..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..", true },
|
|
||||||
{ "c:", true },
|
{ "c:", true },
|
||||||
{ "c:\\", true },
|
{ "c:\\", true },
|
||||||
{ "c:\\\\", true },
|
{ "c:\\\\", true },
|
||||||
{ "\\\\share\\file", false },
|
{ "\\\\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 },
|
{ "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!
|
{ "test.exe", false } // not a directory!
|
||||||
#elif defined(__UNIX__)
|
#elif defined(__UNIX__)
|
||||||
{ "../..", true },
|
{ "../..", true },
|
||||||
{ "../../../../../../../../../../../../../../../../../../../..", true },
|
|
||||||
{ "/", true },
|
{ "/", true },
|
||||||
{ "//", true },
|
{ "//", true },
|
||||||
{ "/usr/bin", true },
|
{ "/usr/bin", true },
|
||||||
{ "/usr//bin", false },
|
{ "/usr//bin", true },
|
||||||
{ "/usr///bin", false }
|
{ "/usr///bin", true },
|
||||||
|
{ "/tmp/a/directory/which/does/not/exist", false },
|
||||||
|
{ "/bin/ls", false } // not a directory!
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
for ( size_t n = 0; n < WXSIZEOF(testData); n++ )
|
for ( size_t n = 0; n < WXSIZEOF(testData); n++ )
|
||||||
{
|
{
|
||||||
wxString errDesc = wxString::Format("failed on directory '%s'", testData[n].dirname);
|
wxString dirname = testData[n].dirname;
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(errDesc.ToStdString(), testData[n].shouldExist, wxDir::Exists(testData[n].dirname));
|
dirname.Replace("$USER_DOCS_DIR", wxStandardPaths::Get().GetDocumentsDir());
|
||||||
|
|
||||||
if (!testData[n].shouldExist)
|
std::string errDesc = wxString::Format("failed on directory '%s'", dirname).ToStdString();
|
||||||
{
|
CPPUNIT_ASSERT_EQUAL_MESSAGE(errDesc, testData[n].shouldExist, wxDir::Exists(dirname));
|
||||||
wxDir d(testData[n].dirname);
|
|
||||||
CPPUNIT_ASSERT(!d.IsOpened());
|
wxDir d(dirname);
|
||||||
}
|
CPPUNIT_ASSERT_EQUAL(testData[n].shouldExist, d.IsOpened());
|
||||||
}
|
}
|
||||||
|
|
||||||
CPPUNIT_ASSERT( wxDir::Exists(wxGetCwd()) );
|
CPPUNIT_ASSERT( wxDir::Exists(wxGetCwd()) );
|
||||||
|
Loading…
Reference in New Issue
Block a user