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/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <ostream> | 9 #include <ostream> |
10 | 10 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 EXPECT_TRUE(net::IsLocalhost("localhost6")); | 796 EXPECT_TRUE(net::IsLocalhost("localhost6")); |
797 EXPECT_TRUE(net::IsLocalhost("localhost6.localdomain6")); | 797 EXPECT_TRUE(net::IsLocalhost("localhost6.localdomain6")); |
798 EXPECT_TRUE(net::IsLocalhost("127.0.0.1")); | 798 EXPECT_TRUE(net::IsLocalhost("127.0.0.1")); |
799 EXPECT_TRUE(net::IsLocalhost("127.0.1.0")); | 799 EXPECT_TRUE(net::IsLocalhost("127.0.1.0")); |
800 EXPECT_TRUE(net::IsLocalhost("127.1.0.0")); | 800 EXPECT_TRUE(net::IsLocalhost("127.1.0.0")); |
801 EXPECT_TRUE(net::IsLocalhost("127.0.0.255")); | 801 EXPECT_TRUE(net::IsLocalhost("127.0.0.255")); |
802 EXPECT_TRUE(net::IsLocalhost("127.0.255.0")); | 802 EXPECT_TRUE(net::IsLocalhost("127.0.255.0")); |
803 EXPECT_TRUE(net::IsLocalhost("127.255.0.0")); | 803 EXPECT_TRUE(net::IsLocalhost("127.255.0.0")); |
804 EXPECT_TRUE(net::IsLocalhost("::1")); | 804 EXPECT_TRUE(net::IsLocalhost("::1")); |
805 EXPECT_TRUE(net::IsLocalhost("0:0:0:0:0:0:0:1")); | 805 EXPECT_TRUE(net::IsLocalhost("0:0:0:0:0:0:0:1")); |
| 806 EXPECT_TRUE(net::IsLocalhost("foo.localhost")); |
806 | 807 |
807 EXPECT_FALSE(net::IsLocalhost("localhostx")); | 808 EXPECT_FALSE(net::IsLocalhost("localhostx")); |
808 EXPECT_FALSE(net::IsLocalhost("foo.localdomain")); | 809 EXPECT_FALSE(net::IsLocalhost("foo.localdomain")); |
809 EXPECT_FALSE(net::IsLocalhost("localhost6x")); | 810 EXPECT_FALSE(net::IsLocalhost("localhost6x")); |
810 EXPECT_FALSE(net::IsLocalhost("localhost.localdomain6")); | 811 EXPECT_FALSE(net::IsLocalhost("localhost.localdomain6")); |
811 EXPECT_FALSE(net::IsLocalhost("localhost6.localdomain")); | 812 EXPECT_FALSE(net::IsLocalhost("localhost6.localdomain")); |
812 EXPECT_FALSE(net::IsLocalhost("127.0.0.1.1")); | 813 EXPECT_FALSE(net::IsLocalhost("127.0.0.1.1")); |
813 EXPECT_FALSE(net::IsLocalhost(".127.0.0.255")); | 814 EXPECT_FALSE(net::IsLocalhost(".127.0.0.255")); |
814 EXPECT_FALSE(net::IsLocalhost("::2")); | 815 EXPECT_FALSE(net::IsLocalhost("::2")); |
815 EXPECT_FALSE(net::IsLocalhost("::1:1")); | 816 EXPECT_FALSE(net::IsLocalhost("::1:1")); |
816 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1")); | 817 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1")); |
817 EXPECT_FALSE(net::IsLocalhost("::1:1")); | 818 EXPECT_FALSE(net::IsLocalhost("::1:1")); |
818 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1")); | 819 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1")); |
| 820 EXPECT_FALSE(net::IsLocalhost("foo.localhost.com")); |
| 821 } |
| 822 |
| 823 TEST(NetUtilTest, IsLocalhostTLD) { |
| 824 EXPECT_TRUE(net::IsLocalhostTLD("foo.localhost")); |
| 825 EXPECT_TRUE(net::IsLocalhostTLD("foo.localhost.")); |
| 826 EXPECT_FALSE(net::IsLocalhostTLD("foo.localhos")); |
| 827 EXPECT_FALSE(net::IsLocalhostTLD("foo.localhost.com")); |
819 } | 828 } |
820 | 829 |
821 // Verify GetNetworkList(). | 830 // Verify GetNetworkList(). |
822 TEST(NetUtilTest, GetNetworkList) { | 831 TEST(NetUtilTest, GetNetworkList) { |
823 NetworkInterfaceList list; | 832 NetworkInterfaceList list; |
824 ASSERT_TRUE(GetNetworkList(&list, INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)); | 833 ASSERT_TRUE(GetNetworkList(&list, INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)); |
825 for (NetworkInterfaceList::iterator it = list.begin(); | 834 for (NetworkInterfaceList::iterator it = list.begin(); |
826 it != list.end(); ++it) { | 835 it != list.end(); ++it) { |
827 // Verify that the names are not empty. | 836 // Verify that the names are not empty. |
828 EXPECT_FALSE(it->name.empty()); | 837 EXPECT_FALSE(it->name.empty()); |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { | 1557 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { |
1549 const NonUniqueNameTestData& test_data = GetParam(); | 1558 const NonUniqueNameTestData& test_data = GetParam(); |
1550 | 1559 |
1551 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); | 1560 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); |
1552 } | 1561 } |
1553 | 1562 |
1554 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, | 1563 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, |
1555 testing::ValuesIn(kNonUniqueNameTestData)); | 1564 testing::ValuesIn(kNonUniqueNameTestData)); |
1556 | 1565 |
1557 } // namespace net | 1566 } // namespace net |
OLD | NEW |