]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/filesys/filesystest.cpp
proper default for iphone
[wxWidgets.git] / tests / filesys / filesystest.cpp
index fa928db128d4c7f1c7aa1c9acc55a84f724625b4..36b5f975bebf1cd37952b43003757ec1ea979358 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     wxFileSystem unit test
 // Author:      Vaclav Slavik
 // Created:     2004-03-28
 // Purpose:     wxFileSystem unit test
 // Author:      Vaclav Slavik
 // Created:     2004-03-28
-// RCS-ID:      $Id$
 // Copyright:   (c) 2004 Vaclav Slavik
 ///////////////////////////////////////////////////////////////////////////////
 
 // Copyright:   (c) 2004 Vaclav Slavik
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -61,10 +60,12 @@ private:
     CPPUNIT_TEST_SUITE( FileSystemTestCase );
         CPPUNIT_TEST( UrlParsing );
         CPPUNIT_TEST( FileNameToUrlConversion );
     CPPUNIT_TEST_SUITE( FileSystemTestCase );
         CPPUNIT_TEST( UrlParsing );
         CPPUNIT_TEST( FileNameToUrlConversion );
+        CPPUNIT_TEST( UnicodeFileNameToUrlConversion );
     CPPUNIT_TEST_SUITE_END();
 
     void UrlParsing();
     void FileNameToUrlConversion();
     CPPUNIT_TEST_SUITE_END();
 
     void UrlParsing();
     void FileNameToUrlConversion();
+    void UnicodeFileNameToUrlConversion();
 
     DECLARE_NO_COPY_CLASS(FileSystemTestCase)
 };
 
     DECLARE_NO_COPY_CLASS(FileSystemTestCase)
 };
@@ -72,7 +73,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( FileSystemTestCase );
 
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( FileSystemTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileSystemTestCase, "FileSystemTestCase" );
 
 void FileSystemTestCase::UrlParsing()
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FileSystemTestCase, "FileSystemTestCase" );
 
 void FileSystemTestCase::UrlParsing()
@@ -84,20 +85,20 @@ void FileSystemTestCase::UrlParsing()
     } data[] =
     {
         // simple case:
     } data[] =
     {
         // simple case:
-        { _T("http://www.root.cz/index.html"),
-                _T("http"), _T(""), _T("//www.root.cz/index.html"), _T("")},
+        { wxT("http://www.root.cz/index.html"),
+                wxT("http"), wxT(""), wxT("//www.root.cz/index.html"), wxT("")},
         // anchors:
         // anchors:
-        { _T("http://www.root.cz/index.html#lbl"),
-                _T("http"), _T(""), _T("//www.root.cz/index.html"), _T("lbl")},
+        { wxT("http://www.root.cz/index.html#lbl"),
+                wxT("http"), wxT(""), wxT("//www.root.cz/index.html"), wxT("lbl")},
         // file is default protocol:
         // file is default protocol:
-        { _T("testfile.html"),
-                _T("file"), _T(""), _T("testfile.html"), _T("")},
+        { wxT("testfile.html"),
+                wxT("file"), wxT(""), wxT("testfile.html"), wxT("")},
         // stacked protocols:
         // stacked protocols:
-        { _T("file:myzipfile.zip#zip:index.htm"),
-                _T("zip"), _T("file:myzipfile.zip"), _T("index.htm"), _T("")},
+        { wxT("file:myzipfile.zip#zip:index.htm"),
+                wxT("zip"), wxT("file:myzipfile.zip"), wxT("index.htm"), wxT("")},
         // changes to ':' parsing often break things:
         // changes to ':' parsing often break things:
-        { _T("file:a#b:foo"),
-                _T("b"), _T("file:a"), _T("foo"), _T("")}
+        { wxT("file:a#b:foo"),
+                wxT("b"), wxT("file:a"), wxT("foo"), wxT("")}
     };
 
     UrlTester tst;
     };
 
     UrlTester tst;
@@ -110,15 +111,30 @@ void FileSystemTestCase::UrlParsing()
         CPPUNIT_ASSERT( tst.Anchor(d.url) == d.anchor );
     }
 }
         CPPUNIT_ASSERT( tst.Anchor(d.url) == d.anchor );
     }
 }
-    
+
 void FileSystemTestCase::FileNameToUrlConversion()
 {
 #ifdef __WINDOWS__
 void FileSystemTestCase::FileNameToUrlConversion()
 {
 #ifdef __WINDOWS__
-    wxFileName fn1(_T("\\\\server\\share\\path\\to\\file"));
+    wxFileName fn1(wxT("\\\\server\\share\\path\\to\\file"));
     wxString url1 = wxFileSystem::FileNameToURL(fn1);
     wxString url1 = wxFileSystem::FileNameToURL(fn1);
-   
+
     CPPUNIT_ASSERT( fn1.SameAs(wxFileSystem::URLToFileName(url1)) );
 #endif
 }
 
     CPPUNIT_ASSERT( fn1.SameAs(wxFileSystem::URLToFileName(url1)) );
 #endif
 }
 
+void FileSystemTestCase::UnicodeFileNameToUrlConversion()
+{
+    const unsigned char filename_utf8[] = {
+              0x4b, 0x72, 0xc3, 0xa1, 0x73, 0x79, 0x50, 0xc5,
+              0x99, 0xc3, 0xad, 0x72, 0x6f, 0x64, 0x79, 0x2e,
+              0x6a, 0x70, 0x67, 0x00
+              // KrásyPřírody.jpg
+        };
+    wxFileName filename(wxString::FromUTF8((const char*)filename_utf8));
+
+    wxString url = wxFileSystem::FileNameToURL(filename);
+
+    CPPUNIT_ASSERT( filename.SameAs(wxFileSystem::URLToFileName(url)) );
+}
+
 #endif // wxUSE_FILESYSTEM
 #endif // wxUSE_FILESYSTEM