* 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:
Axel Dörfler
2011-02-11 22:50:13 +00:00
parent 448e9976cf
commit e06c0a1d50
3 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -6,5 +6,5 @@ UnitTestLib libnetapitest.so :
NetworkAddressTest.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.
*/
#include "NetworkAddressTest.h"
#include <netinet6/in6.h>
#include <NetworkAddress.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
NetworkAddressTest::TestWildcard()
{
@@ -101,6 +123,8 @@ NetworkAddressTest::AddTests(BTestSuite& parent)
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
"NetworkAddressTest::TestUnset", &NetworkAddressTest::TestUnset));
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
"NetworkAddressTest::TestSetTo", &NetworkAddressTest::TestSetTo));
suite.addTest(new CppUnit::TestCaller<NetworkAddressTest>(
"NetworkAddressTest::TestWildcard", &NetworkAddressTest::TestWildcard));
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.
*/
#ifndef NETWORK_ADDRESS_TEST_H
@@ -16,6 +16,7 @@ public:
virtual ~NetworkAddressTest();
void TestUnset();
void TestSetTo();
void TestWildcard();
void TestIsLocal();
void TestFlatten();