]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/uris/uris.cpp
reverted DEBUG_INFO change
[wxWidgets.git] / tests / uris / uris.cpp
index 2bc61ae3cb6aa8f343fd20747ff8a1fe5d3321bc..959c3e2928f73716078872290340aa9f5a09e55b 100644 (file)
@@ -11,7 +11,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
-#include "wx/wxprec.h"
+#include "testprec.h"
 
 #ifdef __BORLANDC__
     #pragma hdrstop
 
 #ifdef __BORLANDC__
     #pragma hdrstop
 #endif // WX_PRECOMP
 
 #include "wx/uri.h"
 #endif // WX_PRECOMP
 
 #include "wx/uri.h"
-
-#include "wx/cppunit.h"
+#include "wx/url.h"
 
 // Test wxURL & wxURI compat?
 
 // Test wxURL & wxURI compat?
-#define TEST_URL 1
+#define TEST_URL ( 1 && wxUSE_URL )
 
 // ----------------------------------------------------------------------------
 // test class
 
 // ----------------------------------------------------------------------------
 // test class
@@ -51,6 +50,9 @@ private:
         CPPUNIT_TEST( Comparison );
 #if TEST_URL
         CPPUNIT_TEST( URLCompat );
         CPPUNIT_TEST( Comparison );
 #if TEST_URL
         CPPUNIT_TEST( URLCompat );
+#if wxUSE_PROTOCOL_HTTP
+        CPPUNIT_TEST( URLProxy  );
+#endif
 #endif
     CPPUNIT_TEST_SUITE_END();
 
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -67,6 +69,7 @@ private:
 
 #if TEST_URL
     void URLCompat();
 
 #if TEST_URL
     void URLCompat();
+    void URLProxy();
 #endif
 
     DECLARE_NO_COPY_CLASS(URITestCase)
 #endif
 
     DECLARE_NO_COPY_CLASS(URITestCase)
@@ -102,7 +105,7 @@ void URITestCase::IPv4()
     wxURI* uri;
 
 
     wxURI* uri;
 
 
-    URI_TEST("http://user:password@192.168.1.100:5050/path", 
+    URI_TEST("http://user:password@192.168.1.100:5050/path",
             uri->GetHostType() == wxURI_IPV4ADDRESS);
 
     URI_TEST("http://user:password@192.255.1.100:5050/path",
             uri->GetHostType() == wxURI_IPV4ADDRESS);
 
     URI_TEST("http://user:password@192.255.1.100:5050/path",
@@ -127,17 +130,17 @@ void URITestCase::IPv6()
     //               / [ *5( h16 ":" ) h16 ] "::"              h16
     //               / [ *6( h16 ":" ) h16 ] "::"
     // ls32          = ( h16 ":" h16 ) / IPv4address
     //               / [ *5( h16 ":" ) h16 ] "::"              h16
     //               / [ *6( h16 ":" ) h16 ] "::"
     // ls32          = ( h16 ":" h16 ) / IPv4address
-    
-    URI_TEST("http://user:password@[aa:aa:aa:aa:aa:aa:192.168.1.100]:5050/path", 
+
+    URI_TEST("http://user:password@[aa:aa:aa:aa:aa:aa:192.168.1.100]:5050/path",
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 
-    URI_TEST("http://user:password@[aa:aa:aa:aa:aa:aa:aa:aa]:5050/path", 
+    URI_TEST("http://user:password@[aa:aa:aa:aa:aa:aa:aa:aa]:5050/path",
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 
-    URI_TEST("http://user:password@[aa:aa:aa:aa::192.168.1.100]:5050/path", 
+    URI_TEST("http://user:password@[aa:aa:aa:aa::192.168.1.100]:5050/path",
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 
-    URI_TEST("http://user:password@[aa:aa:aa:aa::aa:aa]:5050/path", 
+    URI_TEST("http://user:password@[aa:aa:aa:aa::aa:aa]:5050/path",
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 }
 
                 uri->GetHostType() == wxURI_IPV6ADDRESS);
 }
 
@@ -146,19 +149,19 @@ void URITestCase::Paths()
     wxURI* uri;
 
     //path tests
     wxURI* uri;
 
     //path tests
-    URI_TEST("http://user:password@192.256.1.100:5050/../path", 
+    URI_TEST("http://user:password@192.256.1.100:5050/../path",
         uri->GetPath() == wxT("/path"));
 
         uri->GetPath() == wxT("/path"));
 
-    URI_TEST("http://user:password@192.256.1.100:5050/path/../", 
+    URI_TEST("http://user:password@192.256.1.100:5050/path/../",
         uri->GetPath() == wxT("/"));
 
         uri->GetPath() == wxT("/"));
 
-    URI_TEST("http://user:password@192.256.1.100:5050/path/.", 
+    URI_TEST("http://user:password@192.256.1.100:5050/path/.",
         uri->GetPath() == wxT("/path/"));
 
         uri->GetPath() == wxT("/path/"));
 
-    URI_TEST("http://user:password@192.256.1.100:5050/path/./", 
+    URI_TEST("http://user:password@192.256.1.100:5050/path/./",
         uri->GetPath() == wxT("/path/"));
         uri->GetPath() == wxT("/path/"));
-    URI_TEST("path/john/../../../joe", 
+
+    URI_TEST("path/john/../../../joe",
         uri->BuildURI() == wxT("../joe"));
 }
 #undef URI_TEST
         uri->BuildURI() == wxT("../joe"));
 }
 #undef URI_TEST
@@ -179,31 +182,31 @@ void URITestCase::NormalResolving()
 {
     wxURI masteruri(wxT("http://a/b/c/d;p?q"));
     wxURI* uri;
 {
     wxURI masteruri(wxT("http://a/b/c/d;p?q"));
     wxURI* uri;
-    
+
     URI_TEST("g:h"  ,"g:h")
     URI_TEST("g:h"  ,"g:h")
-   URI_TEST("g"    ,"http://a/b/c/g")
-   URI_TEST("./g"  ,"http://a/b/c/g")
-   URI_TEST("g/"   ,"http://a/b/c/g/")
-   URI_TEST("/g"   ,"http://a/g")
-   URI_TEST("//g"  ,"http://g")
-   URI_TEST("?y"   ,"http://a/b/c/d;p?y")
+    URI_TEST("g"    ,"http://a/b/c/g")
+    URI_TEST("./g"  ,"http://a/b/c/g")
+    URI_TEST("g/"   ,"http://a/b/c/g/")
+    URI_TEST("/g"   ,"http://a/g")
+    URI_TEST("//g"  ,"http://g")
+    URI_TEST("?y"   ,"http://a/b/c/d;p?y")
     URI_TEST("g?y"  ,"http://a/b/c/g?y")
     URI_TEST("g?y"  ,"http://a/b/c/g?y")
-  URI_TEST("#s"   ,"http://a/b/c/d;p?q#s")
-       URI_TEST("g#s"  ,"http://a/b/c/g#s")
-   URI_TEST("g?y#s","http://a/b/c/g?y#s")
-   URI_TEST(";x"   ,"http://a/b/c/;x")
-   URI_TEST("g;x"  ,"http://a/b/c/g;x")
-  URI_TEST("g;x?y#s","http://a/b/c/g;x?y#s")
-
-   URI_TEST(""     ,"http://a/b/c/d;p?q")
-   URI_TEST("."    ,"http://a/b/c/")
-   URI_TEST("./"   ,"http://a/b/c/")
-   URI_TEST(".."   ,"http://a/b/")
-   URI_TEST("../"  ,"http://a/b/")
-   URI_TEST("../g" ,"http://a/b/g")
-   URI_TEST("../..","http://a/")
-   URI_TEST("../../"        ,  "http://a/")
-   URI_TEST("../../g"       ,  "http://a/g")
+    URI_TEST("#s"   ,"http://a/b/c/d;p?q#s")
+    URI_TEST("g#s"  ,"http://a/b/c/g#s")
+    URI_TEST("g?y#s","http://a/b/c/g?y#s")
+    URI_TEST(";x"   ,"http://a/b/c/;x")
+    URI_TEST("g;x"  ,"http://a/b/c/g;x")
+    URI_TEST("g;x?y#s","http://a/b/c/g;x?y#s")
+
+    URI_TEST(""     ,"http://a/b/c/d;p?q")
+    URI_TEST("."    ,"http://a/b/c/")
+    URI_TEST("./"   ,"http://a/b/c/")
+    URI_TEST(".."   ,"http://a/b/")
+    URI_TEST("../"  ,"http://a/b/")
+    URI_TEST("../g" ,"http://a/b/g")
+    URI_TEST("../..","http://a/")
+    URI_TEST("../../"        ,  "http://a/")
+    URI_TEST("../../g"       ,  "http://a/g")
 }
 
 void URITestCase::ComplexResolving()
 }
 
 void URITestCase::ComplexResolving()
@@ -212,12 +215,12 @@ void URITestCase::ComplexResolving()
     wxURI* uri;
 
     //odd path examples
     wxURI* uri;
 
     //odd path examples
-   URI_TEST("/./g"   ,"http://a/g")
-   URI_TEST("/../g"  ,"http://a/g")
-   URI_TEST("g."     ,"http://a/b/c/g.")
-   URI_TEST(".g"     ,"http://a/b/c/.g")
-   URI_TEST("g.."    ,"http://a/b/c/g..")
-   URI_TEST("..g"    ,"http://a/b/c/..g")
+    URI_TEST("/./g"   ,"http://a/g")
+    URI_TEST("/../g"  ,"http://a/g")
+    URI_TEST("g."     ,"http://a/b/c/g.")
+    URI_TEST(".g"     ,"http://a/b/c/.g")
+    URI_TEST("g.."    ,"http://a/b/c/g..")
+    URI_TEST("..g"    ,"http://a/b/c/..g")
 }
    //Should Fail
    //"../../../g"    =  "http://a/g"
 }
    //Should Fail
    //"../../../g"    =  "http://a/g"
@@ -229,12 +232,12 @@ void URITestCase::ReallyComplexResolving()
     wxURI* uri;
 
     //even more odder path examples
     wxURI* uri;
 
     //even more odder path examples
-   URI_TEST("./../g" ,"http://a/b/g")
-   URI_TEST("./g/."  ,"http://a/b/c/g/")
-   URI_TEST("g/./h"  ,"http://a/b/c/g/h")
-   URI_TEST("g/../h" ,"http://a/b/c/h")
-   URI_TEST("g;x=1/./y"     ,  "http://a/b/c/g;x=1/y")
-   URI_TEST("g;x=1/../y"    ,  "http://a/b/c/y")
+    URI_TEST("./../g" ,"http://a/b/g")
+    URI_TEST("./g/."  ,"http://a/b/c/g/")
+    URI_TEST("g/./h"  ,"http://a/b/c/g/h")
+    URI_TEST("g/../h" ,"http://a/b/c/h")
+    URI_TEST("g;x=1/./y"     ,  "http://a/b/c/g;x=1/y")
+    URI_TEST("g;x=1/../y"    ,  "http://a/b/c/y")
 }
 
 void URITestCase::QueryFragmentResolving()
 }
 
 void URITestCase::QueryFragmentResolving()
@@ -242,11 +245,11 @@ void URITestCase::QueryFragmentResolving()
     wxURI masteruri(wxT("http://a/b/c/d;p?q"));
     wxURI* uri;
 
     wxURI masteruri(wxT("http://a/b/c/d;p?q"));
     wxURI* uri;
 
-   //query/fragment ambigiousness
-   URI_TEST("g?y/./x","http://a/b/c/g?y/./x")
-   URI_TEST("g?y/../x"      ,  "http://a/b/c/g?y/../x")
-   URI_TEST("g#s/./x","http://a/b/c/g#s/./x")
-   URI_TEST("g#s/../x"      ,  "http://a/b/c/g#s/../x")
+    //query/fragment ambigiousness
+    URI_TEST("g?y/./x","http://a/b/c/g?y/./x")
+    URI_TEST("g?y/../x"      ,  "http://a/b/c/g?y/../x")
+    URI_TEST("g#s/./x","http://a/b/c/g#s/./x")
+    URI_TEST("g#s/../x"      ,  "http://a/b/c/g#s/../x")
 }
 
 void URITestCase::BackwardsResolving()
 }
 
 void URITestCase::BackwardsResolving()
@@ -254,10 +257,10 @@ void URITestCase::BackwardsResolving()
     wxURI masteruri(wxT("http://a/b/c/d;p?q"));
     wxURI* uri;
 
     wxURI masteruri(wxT("http://a/b/c/d;p?q"));
     wxURI* uri;
 
-   //"NEW" 
-   URI_TEST("http:g" ,  "http:g")         //strict
-   //bw compat
-   URI_TEST_RESOLVE("http:g", "http://a/b/c/g", false); 
+    //"NEW"
+    URI_TEST("http:g" ,  "http:g")         //strict
+    //bw compat
+    URI_TEST_RESOLVE("http:g", "http://a/b/c/g", false);
 }
 
 void URITestCase::Assignment()
 }
 
 void URITestCase::Assignment()
@@ -284,7 +287,7 @@ void URITestCase::URLCompat()
     wxURL url(wxT("http://user:password@wxwidgets.org"));
 
     CPPUNIT_ASSERT(url.GetError() == wxURL_NOERR);
     wxURL url(wxT("http://user:password@wxwidgets.org"));
 
     CPPUNIT_ASSERT(url.GetError() == wxURL_NOERR);
-    
+
     wxInputStream* pInput = url.GetInputStream();
 
     CPPUNIT_ASSERT( pInput != NULL );
     wxInputStream* pInput = url.GetInputStream();
 
     CPPUNIT_ASSERT( pInput != NULL );
@@ -308,6 +311,21 @@ void URITestCase::URLCompat()
 #if WXWIN_COMPATIBILITY_2_4
     CPPUNIT_ASSERT( wxURL::ConvertFromURI(wxT("%20%41%20")) == wxT(" A ") );
 #endif
 #if WXWIN_COMPATIBILITY_2_4
     CPPUNIT_ASSERT( wxURL::ConvertFromURI(wxT("%20%41%20")) == wxT(" A ") );
 #endif
+    CPPUNIT_ASSERT( wxURI::Unescape(wxT("%20%41%20")) == wxT(" A ") );
+
+    wxURI test(wxT("file:\"myf\"ile.txt"));
+
+    CPPUNIT_ASSERT( test.BuildURI() == wxT("file:%22myf%22ile.txt") );
+    CPPUNIT_ASSERT( test.GetScheme() == wxT("file") );
+    CPPUNIT_ASSERT( test.GetPath() == wxT("%22myf%22ile.txt") );
 }
 
 }
 
+#if wxUSE_PROTOCOL_HTTP
+void URITestCase::URLProxy()
+{
+    wxURL url(wxT("http://www.asite.com/index.html"));
+    url.SetProxy(wxT("pserv:3122"));
+}
+#endif // wxUSE_PROTOCOL_HTTP
 #endif
 #endif
+