* Added a test to check several BNetworkAddress::SetTo() variants - all pass
now since the last revision. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40454 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,5 +6,5 @@ UnitTestLib libnetapitest.so :
|
|||||||
NetworkAddressTest.cpp
|
NetworkAddressTest.cpp
|
||||||
NetworkInterfaceTest.cpp
|
NetworkInterfaceTest.cpp
|
||||||
|
|
||||||
: bnetapi $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++)
|
: bnetapi network $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++)
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, Axel Dörfler, [email protected].
|
* Copyright 2010-2011, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "NetworkAddressTest.h"
|
#include "NetworkAddressTest.h"
|
||||||
|
|
||||||
|
#include <netinet6/in6.h>
|
||||||
|
|
||||||
#include <NetworkAddress.h>
|
#include <NetworkAddress.h>
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
|
|
||||||
@@ -40,6 +42,26 @@ NetworkAddressTest::TestUnset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
NetworkAddressTest::TestSetTo()
|
||||||
|
{
|
||||||
|
BNetworkAddress address;
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(address.SetTo("127.0.0.1") == B_OK);
|
||||||
|
CPPUNIT_ASSERT(address.Family() == AF_INET);
|
||||||
|
CPPUNIT_ASSERT(address == BNetworkAddress(INADDR_LOOPBACK));
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(address.SetTo("::1") == B_OK);
|
||||||
|
CPPUNIT_ASSERT(address.Family() == AF_INET6);
|
||||||
|
CPPUNIT_ASSERT(address == BNetworkAddress(in6addr_loopback));
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(address.SetTo(AF_INET, "::1") != B_OK);
|
||||||
|
CPPUNIT_ASSERT(address.SetTo(AF_INET6, "127.0.0.1") != B_OK);
|
||||||
|
CPPUNIT_ASSERT(address.SetTo(AF_INET, "127.0.0.1") == B_OK);
|
||||||
|
CPPUNIT_ASSERT(address.SetTo(AF_INET6, "::1") == B_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NetworkAddressTest::TestWildcard()
|
NetworkAddressTest::TestWildcard()
|
||||||
{
|
{
|
||||||
@@ -101,6 +123,8 @@ NetworkAddressTest::AddTests(BTestSuite& parent)
|
|||||||
|
|
||||||
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
|
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
|
||||||
"NetworkAddressTest::TestUnset", &NetworkAddressTest::TestUnset));
|
"NetworkAddressTest::TestUnset", &NetworkAddressTest::TestUnset));
|
||||||
|
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
|
||||||
|
"NetworkAddressTest::TestSetTo", &NetworkAddressTest::TestSetTo));
|
||||||
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
|
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
|
||||||
"NetworkAddressTest::TestWildcard", &NetworkAddressTest::TestWildcard));
|
"NetworkAddressTest::TestWildcard", &NetworkAddressTest::TestWildcard));
|
||||||
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
|
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, Axel Dörfler, [email protected].
|
* Copyright 2010-2011, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef NETWORK_ADDRESS_TEST_H
|
#ifndef NETWORK_ADDRESS_TEST_H
|
||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
virtual ~NetworkAddressTest();
|
virtual ~NetworkAddressTest();
|
||||||
|
|
||||||
void TestUnset();
|
void TestUnset();
|
||||||
|
void TestSetTo();
|
||||||
void TestWildcard();
|
void TestWildcard();
|
||||||
void TestIsLocal();
|
void TestIsLocal();
|
||||||
void TestFlatten();
|
void TestFlatten();
|
||||||
|
|||||||
Reference in New Issue
Block a user