Chromium Code Reviews| Index: net/base/net_util_unittest.cc |
| diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc |
| index caf64b500948239555ce87f176c146fbd184df56..3364af4203e9c49191a092443ba5f39449ab23fe 100644 |
| --- a/net/base/net_util_unittest.cc |
| +++ b/net/base/net_util_unittest.cc |
| @@ -19,7 +19,6 @@ |
| #include "base/time.h" |
| #include "base/utf_string_conversions.h" |
| #include "googleurl/src/gurl.h" |
| -#include "net/base/sys_addrinfo.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace net { |
| @@ -405,54 +404,6 @@ struct UrlTestData { |
| size_t prefix_len; |
| }; |
| -// Returns an addrinfo for the given 32-bit address (IPv4.) |
| -// The result lives in static storage, so don't delete it. |
| -// |bytes| should be an array of length 4. |
| -const struct addrinfo* GetIPv4Address(const uint8* bytes, int port) { |
| - static struct addrinfo static_ai; |
| - static struct sockaddr_in static_addr4; |
| - |
| - struct addrinfo* ai = &static_ai; |
| - ai->ai_socktype = SOCK_STREAM; |
| - memset(ai, 0, sizeof(static_ai)); |
| - |
| - ai->ai_family = AF_INET; |
| - ai->ai_addrlen = sizeof(static_addr4); |
| - |
| - struct sockaddr_in* addr4 = &static_addr4; |
| - memset(addr4, 0, sizeof(static_addr4)); |
| - addr4->sin_port = base::HostToNet16(port); |
| - addr4->sin_family = ai->ai_family; |
| - memcpy(&addr4->sin_addr, bytes, 4); |
| - |
| - ai->ai_addr = (sockaddr*)addr4; |
| - return ai; |
| -} |
| - |
| -// Returns a addrinfo for the given 128-bit address (IPv6.) |
| -// The result lives in static storage, so don't delete it. |
| -// |bytes| should be an array of length 16. |
| -const struct addrinfo* GetIPv6Address(const uint8* bytes, int port) { |
| - static struct addrinfo static_ai; |
| - static struct sockaddr_in6 static_addr6; |
| - |
| - struct addrinfo* ai = &static_ai; |
| - ai->ai_socktype = SOCK_STREAM; |
| - memset(ai, 0, sizeof(static_ai)); |
| - |
| - ai->ai_family = AF_INET6; |
| - ai->ai_addrlen = sizeof(static_addr6); |
| - |
| - struct sockaddr_in6* addr6 = &static_addr6; |
| - memset(addr6, 0, sizeof(static_addr6)); |
| - addr6->sin6_port = base::HostToNet16(port); |
| - addr6->sin6_family = ai->ai_family; |
| - memcpy(&addr6->sin6_addr, bytes, 16); |
| - |
| - ai->ai_addr = (sockaddr*)addr6; |
| - return ai; |
| -} |
| - |
| // A helper for IDN*{Fast,Slow}. |
| // Append "::<language list>" to |expected| and |actual| to make it |
| // easy to tell which sub-case fails without debugging. |
| @@ -2258,64 +2209,6 @@ TEST(NetUtilTest, GetHostAndOptionalPort) { |
| } |
| } |
| - |
| -TEST(NetUtilTest, NetAddressToString_IPv4) { |
|
eroman
2012/05/04 01:08:41
IMPORTANT: Why are all these tests being removed?
szym
2012/05/04 02:38:29
Agreed. I didn't notice that NetAddressToString(st
|
| - const struct { |
| - uint8 addr[4]; |
| - const char* result; |
| - } tests[] = { |
| - {{0, 0, 0, 0}, "0.0.0.0"}, |
| - {{127, 0, 0, 1}, "127.0.0.1"}, |
| - {{192, 168, 0, 1}, "192.168.0.1"}, |
| - }; |
| - |
| - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| - const addrinfo* ai = GetIPv4Address(tests[i].addr, 80); |
| - std::string result = NetAddressToString(ai); |
| - EXPECT_EQ(std::string(tests[i].result), result); |
| - } |
| -} |
| - |
| -TEST(NetUtilTest, NetAddressToString_IPv6) { |
| - const struct { |
| - uint8 addr[16]; |
| - const char* result; |
| - } tests[] = { |
| - {{0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0xFE, 0xDC, 0xBA, |
| - 0x98, 0x76, 0x54, 0x32, 0x10}, |
| - "fedc:ba98:7654:3210:fedc:ba98:7654:3210"}, |
| - }; |
| - |
| - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| - const addrinfo* ai = GetIPv6Address(tests[i].addr, 80); |
| - std::string result = NetAddressToString(ai); |
| - // Allow NetAddressToString() to fail, in case the system doesn't |
| - // support IPv6. |
| - if (!result.empty()) |
| - EXPECT_EQ(std::string(tests[i].result), result); |
| - } |
| -} |
| - |
| -TEST(NetUtilTest, NetAddressToStringWithPort_IPv4) { |
| - uint8 addr[] = {127, 0, 0, 1}; |
| - const addrinfo* ai = GetIPv4Address(addr, 166); |
| - std::string result = NetAddressToStringWithPort(ai); |
| - EXPECT_EQ("127.0.0.1:166", result); |
| -} |
| - |
| -TEST(NetUtilTest, NetAddressToStringWithPort_IPv6) { |
| - uint8 addr[] = { |
| - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0xFE, 0xDC, 0xBA, |
| - 0x98, 0x76, 0x54, 0x32, 0x10 |
| - }; |
| - const addrinfo* ai = GetIPv6Address(addr, 361); |
| - std::string result = NetAddressToStringWithPort(ai); |
| - |
| - // May fail on systems that don't support IPv6. |
| - if (!result.empty()) |
| - EXPECT_EQ("[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:361", result); |
| -} |
| - |
| TEST(NetUtilTest, GetHostName) { |
| // We can't check the result of GetHostName() directly, since the result |
| // will differ across machines. Our goal here is to simply exercise the |