]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/filename/filenametest.cpp
Document wxSL_MIN_MAX_LABELS and wxSL_VALUE_LABEL
[wxWidgets.git] / tests / filename / filenametest.cpp
index ee65dc83e38a46b706b63bb96db17e1000c3b23d..70d3dced98bc513760d4e0b082cbea4b17dc022a 100644 (file)
     #include "wx/msw/registry.h"
 #endif // __WXMSW__
 
     #include "wx/msw/registry.h"
 #endif // __WXMSW__
 
-// ----------------------------------------------------------------------------
-// local functions
-// ----------------------------------------------------------------------------
-
-// define stream inserter for wxFileName to use it in CPPUNIT_ASSERT_EQUAL()
-inline std::ostream& operator<<(std::ostream& o, const wxFileName& fn)
-{
-    return o << fn.GetFullPath();
-}
+#include "testfile.h"
 
 // ----------------------------------------------------------------------------
 // test data
 
 // ----------------------------------------------------------------------------
 // test data
@@ -65,6 +57,8 @@ static struct TestFileNameInfo
     { "../../foo", "", "../..", "foo", "", false, wxPATH_UNIX },
     { "foo.bar", "", "", "foo", "bar", false, wxPATH_UNIX },
     { "~/foo.bar", "", "~", "foo", "bar", true, wxPATH_UNIX },
     { "../../foo", "", "../..", "foo", "", false, wxPATH_UNIX },
     { "foo.bar", "", "", "foo", "bar", false, wxPATH_UNIX },
     { "~/foo.bar", "", "~", "foo", "bar", true, wxPATH_UNIX },
+    { "~user/foo.bar", "", "~user", "foo", "bar", true, wxPATH_UNIX },
+    { "~user/", "", "~user", "", "", true, wxPATH_UNIX },
     { "/foo", "", "/", "foo", "", true, wxPATH_UNIX },
     { "Mahogany-0.60/foo.bar", "", "Mahogany-0.60", "foo", "bar", false, wxPATH_UNIX },
     { "/tmp/wxwin.tar.bz", "", "/tmp", "wxwin.tar", "bz", true, wxPATH_UNIX },
     { "/foo", "", "/", "foo", "", true, wxPATH_UNIX },
     { "Mahogany-0.60/foo.bar", "", "Mahogany-0.60", "foo", "bar", false, wxPATH_UNIX },
     { "/tmp/wxwin.tar.bz", "", "/tmp", "wxwin.tar", "bz", true, wxPATH_UNIX },
@@ -130,6 +124,7 @@ private:
 #ifdef __WINDOWS__
         CPPUNIT_TEST( TestShortLongPath );
 #endif // __WINDOWS__
 #ifdef __WINDOWS__
         CPPUNIT_TEST( TestShortLongPath );
 #endif // __WINDOWS__
+        CPPUNIT_TEST( TestUNC );
     CPPUNIT_TEST_SUITE_END();
 
     void TestConstruction();
     CPPUNIT_TEST_SUITE_END();
 
     void TestConstruction();
@@ -142,6 +137,7 @@ private:
 #ifdef __WINDOWS__
     void TestShortLongPath();
 #endif // __WINDOWS__
 #ifdef __WINDOWS__
     void TestShortLongPath();
 #endif // __WINDOWS__
+    void TestUNC();
 
     DECLARE_NO_COPY_CLASS(FileNameTestCase)
 };
 
     DECLARE_NO_COPY_CLASS(FileNameTestCase)
 };
@@ -313,11 +309,13 @@ void FileNameTestCase::TestNormalize()
 
         // test wxPATH_NORM_DOTS
         { "a/.././b/c/../../", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
 
         // test wxPATH_NORM_DOTS
         { "a/.././b/c/../../", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
+        { "./", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
+        { "b/../", wxPATH_NORM_DOTS, "", wxPATH_UNIX },
 
 
-        // test wxPATH_NORM_TILDE
-        // NB: do the tilde expansion also under Windows to test if it works there too
+        // test wxPATH_NORM_TILDE: notice that ~ is only interpreted specially
+        // when it is the first character in the file name
         { "/a/b/~", wxPATH_NORM_TILDE, "/a/b/~", wxPATH_UNIX },
         { "/a/b/~", wxPATH_NORM_TILDE, "/a/b/~", wxPATH_UNIX },
-        { "/~/a/b", wxPATH_NORM_TILDE, "HOME/a/b", wxPATH_UNIX },
+        { "/~/a/b", wxPATH_NORM_TILDE, "/~/a/b", wxPATH_UNIX },
         { "~/a/b", wxPATH_NORM_TILDE, "HOME/a/b", wxPATH_UNIX },
 
         // test wxPATH_NORM_CASE
         { "~/a/b", wxPATH_NORM_TILDE, "HOME/a/b", wxPATH_UNIX },
 
         // test wxPATH_NORM_CASE
@@ -497,3 +495,15 @@ void FileNameTestCase::TestShortLongPath()
 }
 
 #endif // __WINDOWS__
 }
 
 #endif // __WINDOWS__
+
+void FileNameTestCase::TestUNC()
+{
+    wxFileName fn("//share/path/name.ext", wxPATH_DOS);
+    CPPUNIT_ASSERT_EQUAL( "share", fn.GetVolume() );
+    CPPUNIT_ASSERT_EQUAL( "\\path", fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) );
+
+    fn.Assign("\\\\share2\\path2\\name.ext", wxPATH_DOS);
+    CPPUNIT_ASSERT_EQUAL( "share2", fn.GetVolume() );
+    CPPUNIT_ASSERT_EQUAL( "\\path2", fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) );
+}
+