Author: axeld Date: 2011-02-11 23:50:13 +0100 (Fri, 11 Feb 2011) New Revision: 40454 Changeset: http://dev.haiku-os.org/changeset/40454 Modified: haiku/trunk/src/tests/kits/net/libnetapi/Jamfile haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.cpp haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.h Log: * Added a test to check several BNetworkAddress::SetTo() variants - all pass now since the last revision. Modified: haiku/trunk/src/tests/kits/net/libnetapi/Jamfile =================================================================== --- haiku/trunk/src/tests/kits/net/libnetapi/Jamfile 2011-02-11 22:49:07 UTC (rev 40453) +++ haiku/trunk/src/tests/kits/net/libnetapi/Jamfile 2011-02-11 22:50:13 UTC (rev 40454) @@ -6,5 +6,5 @@ NetworkAddressTest.cpp NetworkInterfaceTest.cpp - : bnetapi $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) + : bnetapi network $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ; Modified: haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.cpp =================================================================== --- haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.cpp 2011-02-11 22:49:07 UTC (rev 40453) +++ haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.cpp 2011-02-11 22:50:13 UTC (rev 40454) @@ -1,11 +1,13 @@ /* - * Copyright 2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx + * Copyright 2010-2011, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. */ #include "NetworkAddressTest.h" +#include <netinet6/in6.h> + #include <NetworkAddress.h> #include <TypeConstants.h> @@ -41,6 +43,26 @@ 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() { BNetworkAddress wildcard; @@ -102,6 +124,8 @@ 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>( "NetworkAddressTest::TestIsLocal", &NetworkAddressTest::TestIsLocal)); Modified: haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.h =================================================================== --- haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.h 2011-02-11 22:49:07 UTC (rev 40453) +++ haiku/trunk/src/tests/kits/net/libnetapi/NetworkAddressTest.h 2011-02-11 22:50:13 UTC (rev 40454) @@ -1,5 +1,5 @@ /* - * Copyright 2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx + * Copyright 2010-2011, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. */ #ifndef NETWORK_ADDRESS_TEST_H @@ -16,6 +16,7 @@ virtual ~NetworkAddressTest(); void TestUnset(); + void TestSetTo(); void TestWildcard(); void TestIsLocal(); void TestFlatten();