From abd5e008f16b68a26f9830c10f072322dce63972 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 28 Mar 2010 15:41:29 +0000 Subject: [PATCH] Add test wxFileSystem::FileNameToURL,URLToFileName roundtrip with Unicode filenames. See #11491. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/filesys/filesystest.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/filesys/filesystest.cpp b/tests/filesys/filesystest.cpp index ee39285967..613e241c2f 100644 --- a/tests/filesys/filesystest.cpp +++ b/tests/filesys/filesystest.cpp @@ -61,10 +61,12 @@ private: CPPUNIT_TEST_SUITE( FileSystemTestCase ); CPPUNIT_TEST( UrlParsing ); CPPUNIT_TEST( FileNameToUrlConversion ); + CPPUNIT_TEST( UnicodeFileNameToUrlConversion ); CPPUNIT_TEST_SUITE_END(); void UrlParsing(); void FileNameToUrlConversion(); + void UnicodeFileNameToUrlConversion(); DECLARE_NO_COPY_CLASS(FileSystemTestCase) }; @@ -110,15 +112,30 @@ void FileSystemTestCase::UrlParsing() CPPUNIT_ASSERT( tst.Anchor(d.url) == d.anchor ); } } - + void FileSystemTestCase::FileNameToUrlConversion() { #ifdef __WINDOWS__ wxFileName fn1(wxT("\\\\server\\share\\path\\to\\file")); wxString url1 = wxFileSystem::FileNameToURL(fn1); - + CPPUNIT_ASSERT( fn1.SameAs(wxFileSystem::URLToFileName(url1)) ); #endif } +void FileSystemTestCase::UnicodeFileNameToUrlConversion() +{ + const 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(filename_utf8)); + + wxString url = wxFileSystem::FileNameToURL(filename); + + CPPUNIT_ASSERT( filename.SameAs(wxFileSystem::URLToFileName(url)) ); +} + #endif // wxUSE_FILESYSTEM -- 2.45.2