| 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/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/sys_byteorder.h" | 8 #include "base/sys_byteorder.h" |
| 9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
| 10 #include "net/base/sys_addrinfo.h" | 10 #include "net/base/sys_addrinfo.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 ai[i].ai_addrlen = storage[i].addr_len; | 61 ai[i].ai_addrlen = storage[i].addr_len; |
| 62 ai[i].ai_addr = storage[i].addr; | 62 ai[i].ai_addr = storage[i].addr; |
| 63 if (i + 1 < kNumElements) | 63 if (i + 1 < kNumElements) |
| 64 ai[i].ai_next = &ai[i + 1]; | 64 ai[i].ai_next = &ai[i + 1]; |
| 65 } | 65 } |
| 66 | 66 |
| 67 AddressList list = AddressList::CreateFromAddrinfo(&ai[0]); | 67 AddressList list = AddressList::CreateFromAddrinfo(&ai[0]); |
| 68 | 68 |
| 69 ASSERT_EQ(kNumElements, list.size()); | 69 ASSERT_EQ(kNumElements, list.size()); |
| 70 for (size_t i = 0; i < list.size(); ++i) { | 70 for (size_t i = 0; i < list.size(); ++i) { |
| 71 EXPECT_EQ(AF_INET, list[i].GetFamily()); | 71 EXPECT_EQ(ADDRESS_FAMILY_IPV4, list[i].GetFamily()); |
| 72 // Only check the first byte of the address. | 72 // Only check the first byte of the address. |
| 73 EXPECT_EQ(i, list[i].address()[0]); | 73 EXPECT_EQ(i, list[i].address()[0]); |
| 74 EXPECT_EQ(static_cast<int>(i << 2), list[i].port()); | 74 EXPECT_EQ(static_cast<int>(i << 2), list[i].port()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Check if operator= works. | 77 // Check if operator= works. |
| 78 AddressList copy; | 78 AddressList copy; |
| 79 copy = list; | 79 copy = list; |
| 80 ASSERT_EQ(kNumElements, copy.size()); | 80 ASSERT_EQ(kNumElements, copy.size()); |
| 81 | 81 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 AddressList test_list = AddressList::CreateFromIPAddressList(ip_list, | 130 AddressList test_list = AddressList::CreateFromIPAddressList(ip_list, |
| 131 kCanonicalName); | 131 kCanonicalName); |
| 132 std::string canonical_name; | 132 std::string canonical_name; |
| 133 EXPECT_EQ(kCanonicalName, test_list.canonical_name()); | 133 EXPECT_EQ(kCanonicalName, test_list.canonical_name()); |
| 134 EXPECT_EQ(ARRAYSIZE_UNSAFE(tests), test_list.size()); | 134 EXPECT_EQ(ARRAYSIZE_UNSAFE(tests), test_list.size()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace | 137 } // namespace |
| 138 } // namespace net | 138 } // namespace net |
| OLD | NEW |