+ CPPUNIT_ASSERT(wxURI("http://mysite.com") == wxURI("http://mysite.com"));
+}
+
+void URITestCase::Unescaping()
+{
+ wxString escaped,
+ unescaped;
+
+ escaped = "http://test.com/of/file%3A%2F%2FC%3A%5Curi%5C"
+ "escaping%5Cthat%5Cseems%5Cbroken%5Csadly%5B1%5D.rss";
+
+ unescaped = wxURI(escaped).BuildUnescapedURI();
+
+ CPPUNIT_ASSERT_EQUAL( "http://test.com/of/file://C:\\uri\\"
+ "escaping\\that\\seems\\broken\\sadly[1].rss",
+ unescaped );
+
+ CPPUNIT_ASSERT_EQUAL( unescaped, wxURI::Unescape(escaped) );
+
+
+ escaped = "http://ru.wikipedia.org/wiki/"
+ "%D0%A6%D0%B5%D0%BB%D0%BE%D0%B5_%D1%87%D0%B8%D1%81%D0%BB%D0%BE";
+
+ unescaped = wxURI::Unescape(escaped);
+
+ CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(
+ "http://ru.wikipedia.org/wiki/"
+ "\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5_"
+ "\xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE"
+ ),
+ unescaped );
+}
+
+void URITestCase::FileScheme()
+{
+ //file:// variety (NOT CONFORMING TO THE RFC)
+ URI_ASSERT_PATH_EQUAL( "file://e:/wxcode/script1.xml",
+ "e:/wxcode/script1.xml" );
+
+ //file:/// variety
+ URI_ASSERT_PATH_EQUAL( "file:///e:/wxcode/script1.xml",
+ "/e:/wxcode/script1.xml" );
+
+ //file:/ variety
+ URI_ASSERT_PATH_EQUAL( "file:/e:/wxcode/script1.xml",
+ "/e:/wxcode/script1.xml" );
+
+ //file: variety
+ URI_ASSERT_PATH_EQUAL( "file:e:/wxcode/script1.xml",
+ "e:/wxcode/script1.xml" );
+}
+
+#if TEST_URL
+
+#include "wx/url.h"
+#include "wx/file.h"
+
+void URITestCase::URLCompat()
+{
+ wxURL url("http://user:password@wxwidgets.org");
+
+ CPPUNIT_ASSERT(url.GetError() == wxURL_NOERR);
+
+#if TEST_NETWORK
+ wxInputStream* pInput = url.GetInputStream();
+
+ CPPUNIT_ASSERT( pInput != NULL );
+#endif
+
+ CPPUNIT_ASSERT( url == wxURL("http://user:password@wxwidgets.org") );
+
+ wxURI uri("http://user:password@wxwidgets.org");
+
+ CPPUNIT_ASSERT( url == uri );
+
+ wxURL urlcopy(uri);
+
+ CPPUNIT_ASSERT( urlcopy == url );
+ CPPUNIT_ASSERT( urlcopy == uri );
+
+ wxURI uricopy(url);
+
+ CPPUNIT_ASSERT( uricopy == url );
+ CPPUNIT_ASSERT( uricopy == urlcopy );
+ CPPUNIT_ASSERT( uricopy == uri );
+ CPPUNIT_ASSERT_EQUAL( " A ", wxURI::Unescape("%20%41%20") );
+
+ wxURI test("file:\"myf\"ile.txt");
+
+ CPPUNIT_ASSERT_EQUAL( "file:%22myf%22ile.txt" , test.BuildURI() );
+ CPPUNIT_ASSERT_EQUAL( "file", test.GetScheme() );
+ CPPUNIT_ASSERT_EQUAL( "%22myf%22ile.txt", test.GetPath() );
+
+ // these could be put under a named registry since they take some
+ // time to complete
+#if 0
+ // Test problem urls (reported not to work some time ago by a user...)
+ const wxChar* pszProblemUrls[] = { "http://www.csdn.net",
+ "http://www.163.com",
+ "http://www.sina.com.cn" };
+
+ for ( size_t i = 0; i < WXSIZEOF(pszProblemUrls); ++i )
+ {
+ wxURL urlProblem(pszProblemUrls[i]);
+ CPPUNIT_ASSERT(urlProblem.GetError() == wxURL_NOERR);
+
+ wxInputStream* is = urlProblem.GetInputStream();
+ CPPUNIT_ASSERT(is != NULL);
+
+ wxFile fOut(_T("test.html"), wxFile::write);
+ wxASSERT(fOut.IsOpened());
+
+ char buf[1001];
+ for( ;; )
+ {
+ is->Read(buf, 1000);
+ size_t n = is->LastRead();
+ if ( n == 0 )
+ break;
+ buf[n] = 0;
+ fOut.Write(buf, n);
+ }
+
+ delete is;
+ }
+#endif