]> git.saurik.com Git - wxWidgets.git/commitdiff
introduced more convenient and readable URI_ASSERT_XXX_EQUAL() macros
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 25 Sep 2008 14:08:01 +0000 (14:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 25 Sep 2008 14:08:01 +0000 (14:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55863 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/uris/uris.cpp

index 3948ef784ea55b71282964d66b71f2dc26c4fdb5..f3d22a2098660d13eb0a6f174c6d5e0e2c0ebdee 100644 (file)
@@ -97,18 +97,24 @@ 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_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 +132,47 @@ 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_TEST_EQUAL("http://user:password@[aa:aa:aa:aa::aa:aa]: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
+    );
 }
 
 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 +318,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