]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/filename/filenametest.cpp
Extend the hashmap tests to cover integer and pointer keys
[wxWidgets.git] / tests / filename / filenametest.cpp
index fe5667b5369c2343440da380a33bde047924a23e..27ad3ae8700f531b99bbdca0b995c0787963df6e 100644 (file)
@@ -89,12 +89,18 @@ private:
         CPPUNIT_TEST( TestSplit );
         CPPUNIT_TEST( TestSetPath );
         CPPUNIT_TEST( TestStrip );
+#ifdef __WINDOWS__
+        CPPUNIT_TEST( TestShortLongPath );
+#endif // __WINDOWS__
     CPPUNIT_TEST_SUITE_END();
 
     void TestConstruction();
     void TestSplit();
     void TestSetPath();
     void TestStrip();
+#ifdef __WINDOWS__
+    void TestShortLongPath();
+#endif // __WINDOWS__
 
     DECLARE_NO_COPY_CLASS(FileNameTestCase)
 };
@@ -148,6 +154,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()
@@ -161,7 +171,7 @@ void FileNameTestCase::TestSetPath()
     CPPUNIT_ASSERT( fn.SameAs(wxFileName(_T("/usr/local/bin/ls"), wxPATH_UNIX)) );
 }
 
-wxString wxGetRealFile(wxString szFile)
+wxString wxTestStripExtension(wxString szFile)
 {
     wxStripExtension(szFile);
     return szFile;
@@ -170,11 +180,25 @@ wxString wxGetRealFile(wxString szFile)
 void FileNameTestCase::TestStrip()
 {
     //test a crash
-    CPPUNIT_ASSERT( wxGetRealFile( _T("") ) == _T("") );
+    CPPUNIT_ASSERT( wxTestStripExtension( _T("") ) == _T("") );
 
     //others
-    CPPUNIT_ASSERT( wxGetRealFile( _T(".") ) == _T("") );
-    CPPUNIT_ASSERT( wxGetRealFile( _T(".wav") ) == _T("") );
-    CPPUNIT_ASSERT( wxGetRealFile( _T("good.wav") ) == _T("good") );
-    CPPUNIT_ASSERT( wxGetRealFile( _T("good.wav.wav") ) == _T("good.wav") );
-}
\ No newline at end of file
+    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") );
+}
+
+#ifdef __WINDOWS__
+
+void FileNameTestCase::TestShortLongPath()
+{
+    wxFileName fn(_T("C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"));
+
+    // incredibly enough, GetLongPath() used to return different results during
+    // the first and subsequent runs, test for this
+    CPPUNIT_ASSERT_EQUAL( fn.GetLongPath(), fn.GetLongPath() );
+    CPPUNIT_ASSERT_EQUAL( fn.GetShortPath(), fn.GetShortPath() );
+}
+
+#endif // __WINDOWS__