|
@@ -15,14 +15,20 @@
|
|
|
#include <config.h>
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
+#include <boost/shared_ptr.hpp>
|
|
|
+
|
|
|
#include <asiolink/io_endpoint.h>
|
|
|
#include <asiolink/io_error.h>
|
|
|
|
|
|
+using boost::shared_ptr;
|
|
|
using namespace isc::asiolink;
|
|
|
|
|
|
+namespace {
|
|
|
+typedef shared_ptr<const IOEndpoint> ConstIOEndpointPtr;
|
|
|
+
|
|
|
TEST(IOEndpointTest, createUDPv4) {
|
|
|
- const IOEndpoint* ep;
|
|
|
- ep = IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 53210);
|
|
|
+ ConstIOEndpointPtr ep(IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("192.0.2.1"), 53210));
|
|
|
EXPECT_EQ("192.0.2.1", ep->getAddress().toText());
|
|
|
EXPECT_EQ(53210, ep->getPort());
|
|
|
EXPECT_EQ(AF_INET, ep->getFamily());
|
|
@@ -31,8 +37,8 @@ TEST(IOEndpointTest, createUDPv4) {
|
|
|
}
|
|
|
|
|
|
TEST(IOEndpointTest, createTCPv4) {
|
|
|
- const IOEndpoint* ep;
|
|
|
- ep = IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.1"), 5301);
|
|
|
+ ConstIOEndpointPtr ep(IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("192.0.2.1"), 5301));
|
|
|
EXPECT_EQ("192.0.2.1", ep->getAddress().toText());
|
|
|
EXPECT_EQ(5301, ep->getPort());
|
|
|
EXPECT_EQ(AF_INET, ep->getFamily());
|
|
@@ -41,8 +47,9 @@ TEST(IOEndpointTest, createTCPv4) {
|
|
|
}
|
|
|
|
|
|
TEST(IOEndpointTest, createUDPv6) {
|
|
|
- const IOEndpoint* ep;
|
|
|
- ep = IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1234"), 5302);
|
|
|
+ ConstIOEndpointPtr ep(IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1234"),
|
|
|
+ 5302));
|
|
|
EXPECT_EQ("2001:db8::1234", ep->getAddress().toText());
|
|
|
EXPECT_EQ(5302, ep->getPort());
|
|
|
EXPECT_EQ(AF_INET6, ep->getFamily());
|
|
@@ -51,8 +58,9 @@ TEST(IOEndpointTest, createUDPv6) {
|
|
|
}
|
|
|
|
|
|
TEST(IOEndpointTest, createTCPv6) {
|
|
|
- const IOEndpoint* ep;
|
|
|
- ep = IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1234"), 5303);
|
|
|
+ ConstIOEndpointPtr ep(IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1234"),
|
|
|
+ 5303));
|
|
|
EXPECT_EQ("2001:db8::1234", ep->getAddress().toText());
|
|
|
EXPECT_EQ(5303, ep->getPort());
|
|
|
EXPECT_EQ(AF_INET6, ep->getFamily());
|
|
@@ -61,23 +69,55 @@ TEST(IOEndpointTest, createTCPv6) {
|
|
|
}
|
|
|
|
|
|
TEST(IOEndpointTest, equality) {
|
|
|
- std::vector<const IOEndpoint *> epv;
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1234"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1234"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1234"), 5304));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1234"), 5304));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1235"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1235"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1235"), 5304));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1235"), 5304));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.1"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.1"), 5304));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 5304));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.2"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.2"), 5303));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.2"), 5304));
|
|
|
- epv.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.2"), 5304));
|
|
|
+ std::vector<ConstIOEndpointPtr> epv;
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1234"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1234"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1234"), 5304)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1234"), 5304)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1235"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1235"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1235"), 5304)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1235"), 5304)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("192.0.2.1"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("192.0.2.1"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("192.0.2.1"), 5304)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("192.0.2.1"), 5304)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("192.0.2.2"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("192.0.2.2"), 5303)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("192.0.2.2"), 5304)));
|
|
|
+ epv.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("192.0.2.2"), 5304)));
|
|
|
|
|
|
for (size_t i = 0; i < epv.size(); ++i) {
|
|
|
for (size_t j = 0; j < epv.size(); ++j) {
|
|
@@ -92,23 +132,55 @@ TEST(IOEndpointTest, equality) {
|
|
|
|
|
|
// Create a second array with exactly the same values. We use create()
|
|
|
// again to make sure we get different endpoints
|
|
|
- std::vector<const IOEndpoint *> epv2;
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1234"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1234"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1234"), 5304));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1234"), 5304));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1235"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1235"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("2001:db8::1235"), 5304));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("2001:db8::1235"), 5304));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.1"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.1"), 5304));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"), 5304));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.2"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.2"), 5303));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.2"), 5304));
|
|
|
- epv2.push_back(IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.2"), 5304));
|
|
|
+ std::vector<ConstIOEndpointPtr> epv2;
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1234"), 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1234"), 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1234"), 5304)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1234"), 5304)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1235"), 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1235"), 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("2001:db8::1235"), 5304)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("2001:db8::1235"), 5304)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP,
|
|
|
+ IOAddress("192.0.2.1"), 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP,
|
|
|
+ IOAddress("192.0.2.1"), 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.1"),
|
|
|
+ 5304)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.1"),
|
|
|
+ 5304)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.2"),
|
|
|
+ 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.2"),
|
|
|
+ 5303)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_TCP, IOAddress("192.0.2.2"),
|
|
|
+ 5304)));
|
|
|
+ epv2.push_back(ConstIOEndpointPtr(
|
|
|
+ IOEndpoint::create(IPPROTO_UDP, IOAddress("192.0.2.2"),
|
|
|
+ 5304)));
|
|
|
|
|
|
for (size_t i = 0; i < epv.size(); ++i) {
|
|
|
EXPECT_TRUE(*epv[i] == *epv2[i]);
|
|
@@ -122,3 +194,4 @@ TEST(IOEndpointTest, createIPProto) {
|
|
|
IOError);
|
|
|
}
|
|
|
|
|
|
+}
|