SF 3538780 SocketAddress needs operator < function

This commit is contained in:
Aleksandar Fabijanic
2012-07-11 02:55:27 +00:00
parent bf4f148782
commit 1bd21292e7
4 changed files with 80 additions and 55 deletions

View File

@@ -12,14 +12,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@@ -61,11 +61,11 @@ void SocketAddressTest::testSocketAddress()
SocketAddress wild;
assert (wild.host().isWildcard());
assert (wild.port() == 0);
SocketAddress sa1("192.168.1.100", 100);
assert (sa1.host().toString() == "192.168.1.100");
assert (sa1.port() == 100);
SocketAddress sa2("192.168.1.100", "100");
assert (sa2.host().toString() == "192.168.1.100");
assert (sa2.port() == 100);
@@ -84,11 +84,11 @@ void SocketAddressTest::testSocketAddress()
catch (ServiceNotFoundException&)
{
}
SocketAddress sa4("www.appinf.com", 80);
assert (sa4.host().toString() == "50.57.108.29");
assert (sa4.port() == 80);
try
{
SocketAddress sa5("192.168.2.260", 80);
@@ -109,7 +109,7 @@ void SocketAddressTest::testSocketAddress()
catch (ServiceNotFoundException&)
{
}
SocketAddress sa7("192.168.2.120:88");
assert (sa7.host().toString() == "192.168.2.120");
assert (sa7.port() == 88);
@@ -117,7 +117,7 @@ void SocketAddressTest::testSocketAddress()
SocketAddress sa8("[192.168.2.120]:88");
assert (sa8.host().toString() == "192.168.2.120");
assert (sa8.port() == 88);
try
{
SocketAddress sa9("[192.168.2.260]");
@@ -138,6 +138,20 @@ void SocketAddressTest::testSocketAddress()
}
void SocketAddressTest::testSocketRelationals()
{
SocketAddress sa1("192.168.1.100", 100);
SocketAddress sa2("192.168.1.100:100");
assert (sa1 == sa2);
SocketAddress sa3("192.168.1.101", "99");
assert (sa2 < sa3);
SocketAddress sa4("192.168.1.100", "102");
assert (sa3 < sa4);
}
void SocketAddressTest::testSocketAddress6()
{
#ifdef POCO_HAVE_IPv6
@@ -160,6 +174,7 @@ CppUnit::Test* SocketAddressTest::suite()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SocketAddressTest");
CppUnit_addTest(pSuite, SocketAddressTest, testSocketAddress);
CppUnit_addTest(pSuite, SocketAddressTest, testSocketRelationals);
CppUnit_addTest(pSuite, SocketAddressTest, testSocketAddress6);
return pSuite;

View File

@@ -14,14 +14,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@@ -47,6 +47,7 @@ public:
~SocketAddressTest();
void testSocketAddress();
void testSocketRelationals();
void testSocketAddress6();
void setUp();