From c3a65218fb603686b0fa363f1f287a680d90a383 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 25 Sep 2008 14:08:01 +0000 Subject: [PATCH] introduced more convenient and readable URI_ASSERT_XXX_EQUAL() macros git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55863 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/uris/uris.cpp | 90 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 36 deletions(-) diff --git a/tests/uris/uris.cpp b/tests/uris/uris.cpp index 3948ef7..f3d22a2 100644 --- a/tests/uris/uris.cpp +++ b/tests/uris/uris.cpp @@ -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 -- 2.7.4