X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4c2deb19e0fe659e8f239d86612f3c866731ac22..b75c49d1e64c770d5e4a73ba9cc246a2e6ebd776:/tests/filename/filenametest.cpp diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index 1a495e7add..0e9681ee43 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -11,7 +11,7 @@ // headers // ---------------------------------------------------------------------------- -#include "wx/wxprec.h" +#include "testprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -21,8 +21,7 @@ #endif // WX_PRECOMP #include "wx/filename.h" - -#include "wx/cppunit.h" +#include "wx/filefn.h" // ---------------------------------------------------------------------------- // test data @@ -89,11 +88,13 @@ private: CPPUNIT_TEST( TestConstruction ); CPPUNIT_TEST( TestSplit ); CPPUNIT_TEST( TestSetPath ); + CPPUNIT_TEST( TestStrip ); CPPUNIT_TEST_SUITE_END(); void TestConstruction(); void TestSplit(); void TestSetPath(); + void TestStrip(); DECLARE_NO_COPY_CLASS(FileNameTestCase) }; @@ -147,6 +148,10 @@ void FileNameTestCase::TestSplit() CPPUNIT_ASSERT( name == fni.name ); CPPUNIT_ASSERT( ext == fni.ext ); } + + // special case of empty extension + wxFileName fn(_T("foo.")); + CPPUNIT_ASSERT( fn.GetFullPath() == _T("foo.") ); } void FileNameTestCase::TestSetPath() @@ -160,3 +165,20 @@ void FileNameTestCase::TestSetPath() CPPUNIT_ASSERT( fn.SameAs(wxFileName(_T("/usr/local/bin/ls"), wxPATH_UNIX)) ); } +wxString wxTestStripExtension(wxString szFile) +{ + wxStripExtension(szFile); + return szFile; +} + +void FileNameTestCase::TestStrip() +{ + //test a crash + CPPUNIT_ASSERT( wxTestStripExtension( _T("") ) == _T("") ); + + //others + CPPUNIT_ASSERT( wxTestStripExtension( _T(".") ) == _T("") ); + CPPUNIT_ASSERT( wxTestStripExtension( _T(".wav") ) == _T("") ); + CPPUNIT_ASSERT( wxTestStripExtension( _T("good.wav") ) == _T("good") ); + CPPUNIT_ASSERT( wxTestStripExtension( _T("good.wav.wav") ) == _T("good.wav") ); +}