Net::Route (windows compile)

Net::Route (windows compile only)
This commit is contained in:
aleks-f
2012-11-04 23:25:57 -06:00
parent eb8c662c4c
commit 325a98a91f
13 changed files with 1983 additions and 432 deletions

View 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;
}