| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/address_list.h" | 5 #include "net/base/address_list.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/sys_byteorder.h" | 8 #include "base/sys_byteorder.h" |
| 9 #include "net/base/ip_address.h" |
| 9 #include "net/base/sockaddr_storage.h" | 10 #include "net/base/sockaddr_storage.h" |
| 10 #include "net/base/sys_addrinfo.h" | 11 #include "net/base/sys_addrinfo.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 const char kCanonicalHostname[] = "canonical.bar.com"; | 17 const char kCanonicalHostname[] = "canonical.bar.com"; |
| 17 | 18 |
| 18 TEST(AddressListTest, Canonical) { | 19 TEST(AddressListTest, Canonical) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 sizeof(struct sockaddr_in), | 116 sizeof(struct sockaddr_in), |
| 116 offsetof(struct sockaddr_in, sin_addr), | 117 offsetof(struct sockaddr_in, sin_addr), |
| 117 sizeof(struct in_addr), | 118 sizeof(struct in_addr), |
| 118 }, | 119 }, |
| 119 }; | 120 }; |
| 120 const std::string kCanonicalName = "canonical.example.com"; | 121 const std::string kCanonicalName = "canonical.example.com"; |
| 121 | 122 |
| 122 // Construct a list of ip addresses. | 123 // Construct a list of ip addresses. |
| 123 IPAddressList ip_list; | 124 IPAddressList ip_list; |
| 124 for (size_t i = 0; i < arraysize(tests); ++i) { | 125 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 125 IPAddressNumber ip_number; | 126 IPAddress ip_address; |
| 126 ASSERT_TRUE(ParseIPLiteralToNumber(tests[i].ip_address, &ip_number)); | 127 ASSERT_TRUE(ip_address.AssignFromIPLiteral(tests[i].ip_address)); |
| 127 ip_list.push_back(ip_number); | 128 ip_list.push_back(ip_address); |
| 128 } | 129 } |
| 129 | 130 |
| 130 AddressList test_list = AddressList::CreateFromIPAddressList(ip_list, | 131 AddressList test_list = AddressList::CreateFromIPAddressList(ip_list, |
| 131 kCanonicalName); | 132 kCanonicalName); |
| 132 std::string canonical_name; | 133 std::string canonical_name; |
| 133 EXPECT_EQ(kCanonicalName, test_list.canonical_name()); | 134 EXPECT_EQ(kCanonicalName, test_list.canonical_name()); |
| 134 EXPECT_EQ(arraysize(tests), test_list.size()); | 135 EXPECT_EQ(arraysize(tests), test_list.size()); |
| 135 } | 136 } |
| 136 | 137 |
| 137 } // namespace | 138 } // namespace |
| 138 } // namespace net | 139 } // namespace net |
| OLD | NEW |