| 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/net_util.h" | 9 #include "net/base/net_util.h" |
| 10 #include "net/base/sys_addrinfo.h" | 10 #include "net/base/sys_addrinfo.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 static const char* kCanonicalHostname = "canonical.bar.com"; | 16 const char kCanonicalHostname[] = "canonical.bar.com"; |
| 17 | 17 |
| 18 TEST(AddressListTest, Canonical) { | 18 TEST(AddressListTest, Canonical) { |
| 19 // Create an addrinfo with a canonical name. | 19 // Create an addrinfo with a canonical name. |
| 20 struct sockaddr_in address; | 20 struct sockaddr_in address; |
| 21 // The contents of address do not matter for this test, | 21 // The contents of address do not matter for this test, |
| 22 // so just zero-ing them out for consistency. | 22 // so just zero-ing them out for consistency. |
| 23 memset(&address, 0x0, sizeof(address)); | 23 memset(&address, 0x0, sizeof(address)); |
| 24 // But we need to set the family. | 24 // But we need to set the family. |
| 25 address.sin_family = AF_INET; | 25 address.sin_family = AF_INET; |
| 26 struct addrinfo ai; | 26 struct addrinfo ai; |
| (...skipping 102 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(tests), test_list.size()); | 134 EXPECT_EQ(arraysize(tests), test_list.size()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace | 137 } // namespace |
| 138 } // namespace net | 138 } // namespace net |
| OLD | NEW |