mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 12:18:01 +01:00
Net::Route (windows compile)
Net::Route (windows compile only)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "SocketAddressTest.h"
|
||||
#include "DNSTest.h"
|
||||
#include "NetworkInterfaceTest.h"
|
||||
#include "RouteTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* NetCoreTestSuite::suite()
|
||||
@@ -45,6 +46,7 @@ CppUnit::Test* NetCoreTestSuite::suite()
|
||||
pSuite->addTest(SocketAddressTest::suite());
|
||||
pSuite->addTest(DNSTest::suite());
|
||||
pSuite->addTest(NetworkInterfaceTest::suite());
|
||||
pSuite->addTest(RouteTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
119
Net/testsuite/src/RouteTest.cpp
Normal file
119
Net/testsuite/src/RouteTest.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// RouteTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Net/testsuite/src/RouteTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// 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
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "RouteTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Net/IPAddress.h"
|
||||
#include "Poco/Net/Route.h"
|
||||
#include "Poco/Net/NetException.h"
|
||||
|
||||
|
||||
using Poco::Net::IPAddress;
|
||||
using Poco::Net::Route;
|
||||
using Poco::Net::InvalidAddressException;
|
||||
|
||||
|
||||
RouteTest::RouteTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RouteTest::~RouteTest()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// we should have on most systems at least 3 routes: one for the local subnet,
|
||||
// one for the loopback subnet, and a default route.
|
||||
//
|
||||
// we should have at least one default route (possibly more on a multi-homed
|
||||
// system).
|
||||
//
|
||||
// we should have at least 2 multicast all-hosts routes: one for the local subnet,
|
||||
// and one for the loopback subnet.
|
||||
//
|
||||
// if we wish to do more sanity checking than this, we'd need to correlate it
|
||||
// with results we get back from NetworkInterface::list().
|
||||
//
|
||||
|
||||
void RouteTest::testDefaultRoute()
|
||||
{
|
||||
Route::RouteList routes = Route::list(IPAddress::IPv4);
|
||||
assert(routes.size() >= 3);
|
||||
}
|
||||
|
||||
|
||||
void RouteTest::testAllRoutes()
|
||||
{
|
||||
Route::RouteList defaults = Route::defaults(IPAddress::IPv4);
|
||||
assert(defaults.size() >= 1);
|
||||
}
|
||||
|
||||
|
||||
void RouteTest::testAllHostsRoutes()
|
||||
{
|
||||
IPAddress target("224.0.0.1");
|
||||
Route::RouteList targets = Route::match(target);
|
||||
assert(targets.size() >= 2);
|
||||
}
|
||||
|
||||
|
||||
void RouteTest::testLoopbackRoute()
|
||||
{
|
||||
IPAddress target("127.0.0.1");
|
||||
Route::RouteList targets = Route::match(target);
|
||||
assert(targets.size() >= 1);
|
||||
}
|
||||
|
||||
|
||||
void RouteTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RouteTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* RouteTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("RouteTest");
|
||||
|
||||
CppUnit_addTest(pSuite, RouteTest, testDefaultRoute);
|
||||
CppUnit_addTest(pSuite, RouteTest, testAllRoutes);
|
||||
// CppUnit_addTest(pSuite, RouteTest, testAllHostsRoutes);
|
||||
CppUnit_addTest(pSuite, RouteTest, testLoopbackRoute);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
63
Net/testsuite/src/RouteTest.h
Normal file
63
Net/testsuite/src/RouteTest.h
Normal file
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// RouteTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/Net/testsuite/src/RouteTest.h#1 $
|
||||
//
|
||||
// Definition of the RouteTest class.
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// 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
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef RouteTest_INCLUDED
|
||||
#define RouteTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Net/Net.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class RouteTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
RouteTest(const std::string& name);
|
||||
~RouteTest();
|
||||
|
||||
void testDefaultRoute();
|
||||
void testAllRoutes();
|
||||
void testAllHostsRoutes();
|
||||
void testLoopbackRoute();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // RouteTest_INCLUDED
|
||||
Reference in New Issue
Block a user