X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cb5eef9d872409bb78e48a6db355988e1263df18..87fcb4945a5a088143bed35c586d643ccc706eef:/tests/file/dir.cpp diff --git a/tests/file/dir.cpp b/tests/file/dir.cpp index c109213909..81d66ad53e 100644 --- a/tests/file/dir.cpp +++ b/tests/file/dir.cpp @@ -41,11 +41,13 @@ private: CPPUNIT_TEST( DirExists ); CPPUNIT_TEST( Traverse ); CPPUNIT_TEST( Enum ); + CPPUNIT_TEST( GetName ); CPPUNIT_TEST_SUITE_END(); void DirExists(); void Traverse(); void Enum(); + void GetName(); void CreateTempFile(const wxString& path); wxArrayString DirEnumHelper(wxDir& dir, @@ -178,7 +180,7 @@ void DirTestCase::DirExists() { ".", true }, { "..", true }, { "$USER_DOCS_DIR", true }, -#if defined(__WXMSW__) +#if defined(__WINDOWS__) { "$USER_DOCS_DIR\\", true }, { "$USER_DOCS_DIR\\\\", true }, { "..\\..", true }, @@ -202,20 +204,20 @@ void DirTestCase::DirExists() #endif }; -#ifdef __WXMSW__ +#ifdef __WINDOWS__ wxString homedrive = wxGetenv("HOMEDRIVE"); if ( homedrive.empty() ) homedrive = "c:"; -#endif // __WXMSW__ +#endif // __WINDOWS__ for ( size_t n = 0; n < WXSIZEOF(testData); n++ ) { wxString dirname = testData[n].dirname; dirname.Replace("$USER_DOCS_DIR", wxStandardPaths::Get().GetDocumentsDir()); -#ifdef __WXMSW__ +#ifdef __WINDOWS__ dirname.Replace("$MSW_DRIVE", homedrive); -#endif // __WXMSW__ +#endif // __WINDOWS__ std::string errDesc = wxString::Format("failed on directory '%s'", dirname).ToStdString(); CPPUNIT_ASSERT_EQUAL_MESSAGE(errDesc, testData[n].shouldExist, wxDir::Exists(dirname)); @@ -227,3 +229,19 @@ void DirTestCase::DirExists() CPPUNIT_ASSERT( wxDir::Exists(wxGetCwd()) ); } +void DirTestCase::GetName() +{ + wxDir d; + + CPPUNIT_ASSERT( d.Open(".") ); + CPPUNIT_ASSERT( d.GetName().Last() != wxFILE_SEP_PATH ); + CPPUNIT_ASSERT( d.GetNameWithSep().Last() == wxFILE_SEP_PATH ); + CPPUNIT_ASSERT_EQUAL( d.GetName() + wxFILE_SEP_PATH, + d.GetNameWithSep() ); + +#ifdef __UNIX__ + CPPUNIT_ASSERT( d.Open("/") ); + CPPUNIT_ASSERT_EQUAL( "/", d.GetName() ); + CPPUNIT_ASSERT_EQUAL( "/", d.GetNameWithSep() ); +#endif +}