]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/uris/uris.cpp
Added workaround for wxGTK tab traversal problem
[wxWidgets.git] / tests / uris / uris.cpp
index 3948ef784ea55b71282964d66b71f2dc26c4fdb5..e4920fcec65df1b7c8aa2ede45a691167f8add08 100644 (file)
@@ -45,6 +45,7 @@ private:
     CPPUNIT_TEST_SUITE( URITestCase );
         CPPUNIT_TEST( IPv4 );
         CPPUNIT_TEST( IPv6 );
+        CPPUNIT_TEST( Server );
         CPPUNIT_TEST( Paths );
         CPPUNIT_TEST( NormalResolving );
         CPPUNIT_TEST( ComplexResolving );
@@ -65,6 +66,7 @@ private:
 
     void IPv4();
     void IPv6();
+    void Server();
     void Paths();
     void NormalResolving();
     void ComplexResolving();
@@ -97,18 +99,27 @@ URITestCase::URITestCase()
 }
 
 // apply the given accessor to the URI, check that the result is as expected
-#define URI_TEST_EQUAL(uri, expected, accessor) \
+#define URI_ASSERT_PART_EQUAL(uri, expected, accessor) \
     CPPUNIT_ASSERT_EQUAL(expected, wxURI(uri).accessor)
 
+#define URI_ASSERT_HOSTTYPE_EQUAL(uri, expected) \
+    URI_ASSERT_PART_EQUAL((uri), (expected), GetHostType())
+
+#define URI_ASSERT_SERVER_EQUAL(uri, expected) \
+    URI_ASSERT_PART_EQUAL((uri), (expected), GetServer())
+
+#define URI_ASSERT_PATH_EQUAL(uri, expected) \
+    URI_ASSERT_PART_EQUAL((uri), (expected), GetPath())
+
 void URITestCase::IPv4()
 {
-    URI_TEST_EQUAL("http://user:password@192.168.1.100:5050/path",
-                   wxURI_IPV4ADDRESS, GetHostType());
+    URI_ASSERT_HOSTTYPE_EQUAL("http://user:password@192.168.1.100:5050/path",
+                            wxURI_IPV4ADDRESS);
 
-    URI_TEST_EQUAL("http://user:password@192.255.1.100:5050/path",
-                   wxURI_IPV4ADDRESS, GetHostType());
+    URI_ASSERT_HOSTTYPE_EQUAL("http://user:password@192.255.1.100:5050/path",
+                            wxURI_IPV4ADDRESS);
 
-    //bogus ipv4
+    // bogus ipv4
     CPPUNIT_ASSERT( wxURI("http://user:password@192.256.1.100:5050/path").
                     GetHostType() != wxURI_IPV4ADDRESS);
 }
@@ -126,35 +137,59 @@ void URITestCase::IPv6()
     //               / [ *6( h16 ":" ) h16 ] "::"
     // ls32          = ( h16 ":" h16 ) / IPv4address
 
-    URI_TEST_EQUAL("http://user:password@[aa:aa:aa:aa:aa:aa:192.168.1.100]:5050/path",
-                   wxURI_IPV6ADDRESS, GetHostType());
-
-    URI_TEST_EQUAL("http://user:password@[aa:aa:aa:aa:aa:aa:aa:aa]:5050/path",
-                   wxURI_IPV6ADDRESS, GetHostType());
-
-    URI_TEST_EQUAL("http://user:password@[aa:aa:aa:aa::192.168.1.100]:5050/path",
-                   wxURI_IPV6ADDRESS, GetHostType());
+    URI_ASSERT_HOSTTYPE_EQUAL
+    (
+        "http://user:password@[aa:aa:aa:aa:aa:aa:192.168.1.100]:5050/path",
+        wxURI_IPV6ADDRESS
+    );
+
+    URI_ASSERT_HOSTTYPE_EQUAL
+    (
+        "http://user:password@[aa:aa:aa:aa:aa:aa:aa:aa]:5050/path",
+        wxURI_IPV6ADDRESS
+    );
+
+    URI_ASSERT_HOSTTYPE_EQUAL
+    (
+        "http://user:password@[aa:aa:aa:aa::192.168.1.100]:5050/path",
+        wxURI_IPV6ADDRESS
+    );
+
+    URI_ASSERT_HOSTTYPE_EQUAL
+    (
+        "http://user:password@[aa:aa:aa:aa::aa:aa]:5050/path",
+        wxURI_IPV6ADDRESS
+    );
+}
 
-    URI_TEST_EQUAL("http://user:password@[aa:aa:aa:aa::aa:aa]:5050/path",
-                   wxURI_IPV6ADDRESS, GetHostType());
+void URITestCase::Server()
+{
+    URI_ASSERT_SERVER_EQUAL("http://foo/", "foo");
+    URI_ASSERT_SERVER_EQUAL("http://foo-bar/", "foo-bar");
+    URI_ASSERT_SERVER_EQUAL("http://foo/bar/", "foo");
+    URI_ASSERT_SERVER_EQUAL("http://192.168.1.0/", "192.168.1.0");
+    URI_ASSERT_SERVER_EQUAL("http://192.168.1.17/", "192.168.1.17");
+    URI_ASSERT_SERVER_EQUAL("http://192.168.1.255/", "192.168.1.255");
+    URI_ASSERT_SERVER_EQUAL("http://192.168.1.1/index.html", "192.168.1.1");
+    URI_ASSERT_SERVER_EQUAL("http://[aa:aa:aa:aa::aa:aa]/foo", "aa:aa:aa:aa::aa:aa");
 }
 
 void URITestCase::Paths()
 {
-    URI_TEST_EQUAL("http://user:password@192.256.1.100:5050/../path",
-                   "/path", GetPath());
+    URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/../path",
+                          "/path");
 
-    URI_TEST_EQUAL("http://user:password@192.256.1.100:5050/path/../",
-                   "/", GetPath());
+    URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/path/../",
+                          "/");
 
-    URI_TEST_EQUAL("http://user:password@192.256.1.100:5050/path/.",
-                   "/path/", GetPath());
+    URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/path/.",
+                          "/path/");
 
-    URI_TEST_EQUAL("http://user:password@192.256.1.100:5050/path/./",
-                   "/path/", GetPath());
+    URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/path/./",
+                          "/path/");
 
-    URI_TEST_EQUAL("path/john/../../../joe",
-                   "../joe", BuildURI());
+    URI_ASSERT_PART_EQUAL("path/john/../../../joe",
+                          "../joe", BuildURI());
 }
 
 #define URI_TEST_RESOLVE_IMPL(string, eq, strict) \
@@ -300,21 +335,21 @@ void URITestCase::Unescaping()
 
 void URITestCase::FileScheme()
 {
-    //file:// variety (NOT CONFORMANT TO THE RFC)
-    URI_TEST_EQUAL( "file://e:/wxcode/script1.xml",
-                    "e:/wxcode/script1.xml", GetPath() );
+    //file:// variety (NOT CONFORMING TO THE RFC)
+    URI_ASSERT_PATH_EQUAL( "file://e:/wxcode/script1.xml",
+                    "e:/wxcode/script1.xml" );
 
     //file:/// variety
-    URI_TEST_EQUAL( "file:///e:/wxcode/script1.xml",
-                    "/e:/wxcode/script1.xml", GetPath() );
+    URI_ASSERT_PATH_EQUAL( "file:///e:/wxcode/script1.xml",
+                    "/e:/wxcode/script1.xml" );
 
     //file:/ variety
-    URI_TEST_EQUAL( "file:/e:/wxcode/script1.xml",
-                    "/e:/wxcode/script1.xml", GetPath() );
+    URI_ASSERT_PATH_EQUAL( "file:/e:/wxcode/script1.xml",
+                    "/e:/wxcode/script1.xml" );
 
     //file: variety
-    URI_TEST_EQUAL( "file:e:/wxcode/script1.xml",
-                    "e:/wxcode/script1.xml", GetPath() );
+    URI_ASSERT_PATH_EQUAL( "file:e:/wxcode/script1.xml",
+                    "e:/wxcode/script1.xml" );
 }
 
 #if TEST_URL