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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 EXPECT_TRUE(net::IsLocalhost("localhost6")); | 787 EXPECT_TRUE(net::IsLocalhost("localhost6")); |
788 EXPECT_TRUE(net::IsLocalhost("localhost6.localdomain6")); | 788 EXPECT_TRUE(net::IsLocalhost("localhost6.localdomain6")); |
789 EXPECT_TRUE(net::IsLocalhost("127.0.0.1")); | 789 EXPECT_TRUE(net::IsLocalhost("127.0.0.1")); |
790 EXPECT_TRUE(net::IsLocalhost("127.0.1.0")); | 790 EXPECT_TRUE(net::IsLocalhost("127.0.1.0")); |
791 EXPECT_TRUE(net::IsLocalhost("127.1.0.0")); | 791 EXPECT_TRUE(net::IsLocalhost("127.1.0.0")); |
792 EXPECT_TRUE(net::IsLocalhost("127.0.0.255")); | 792 EXPECT_TRUE(net::IsLocalhost("127.0.0.255")); |
793 EXPECT_TRUE(net::IsLocalhost("127.0.255.0")); | 793 EXPECT_TRUE(net::IsLocalhost("127.0.255.0")); |
794 EXPECT_TRUE(net::IsLocalhost("127.255.0.0")); | 794 EXPECT_TRUE(net::IsLocalhost("127.255.0.0")); |
795 EXPECT_TRUE(net::IsLocalhost("::1")); | 795 EXPECT_TRUE(net::IsLocalhost("::1")); |
796 EXPECT_TRUE(net::IsLocalhost("0:0:0:0:0:0:0:1")); | 796 EXPECT_TRUE(net::IsLocalhost("0:0:0:0:0:0:0:1")); |
| 797 EXPECT_TRUE(net::IsLocalhost("foo.localhost")); |
797 | 798 |
798 EXPECT_FALSE(net::IsLocalhost("localhostx")); | 799 EXPECT_FALSE(net::IsLocalhost("localhostx")); |
799 EXPECT_FALSE(net::IsLocalhost("foo.localdomain")); | 800 EXPECT_FALSE(net::IsLocalhost("foo.localdomain")); |
800 EXPECT_FALSE(net::IsLocalhost("localhost6x")); | 801 EXPECT_FALSE(net::IsLocalhost("localhost6x")); |
801 EXPECT_FALSE(net::IsLocalhost("localhost.localdomain6")); | 802 EXPECT_FALSE(net::IsLocalhost("localhost.localdomain6")); |
802 EXPECT_FALSE(net::IsLocalhost("localhost6.localdomain")); | 803 EXPECT_FALSE(net::IsLocalhost("localhost6.localdomain")); |
803 EXPECT_FALSE(net::IsLocalhost("127.0.0.1.1")); | 804 EXPECT_FALSE(net::IsLocalhost("127.0.0.1.1")); |
804 EXPECT_FALSE(net::IsLocalhost(".127.0.0.255")); | 805 EXPECT_FALSE(net::IsLocalhost(".127.0.0.255")); |
805 EXPECT_FALSE(net::IsLocalhost("::2")); | 806 EXPECT_FALSE(net::IsLocalhost("::2")); |
806 EXPECT_FALSE(net::IsLocalhost("::1:1")); | 807 EXPECT_FALSE(net::IsLocalhost("::1:1")); |
807 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1")); | 808 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1")); |
808 EXPECT_FALSE(net::IsLocalhost("::1:1")); | 809 EXPECT_FALSE(net::IsLocalhost("::1:1")); |
809 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1")); | 810 EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1")); |
| 811 EXPECT_FALSE(net::IsLocalhost("foo.localhost.com")); |
| 812 } |
| 813 |
| 814 TEST(NetUtilTest, IsLocalhostTLD) { |
| 815 EXPECT_TRUE(net::IsLocalhostTLD("foo.localhost")); |
| 816 EXPECT_TRUE(net::IsLocalhostTLD("foo.localhost.")); |
| 817 EXPECT_FALSE(net::IsLocalhostTLD("foo.localhos")); |
| 818 EXPECT_FALSE(net::IsLocalhostTLD("foo.localhost.com")); |
810 } | 819 } |
811 | 820 |
812 // Verify GetNetworkList(). | 821 // Verify GetNetworkList(). |
813 TEST(NetUtilTest, GetNetworkList) { | 822 TEST(NetUtilTest, GetNetworkList) { |
814 NetworkInterfaceList list; | 823 NetworkInterfaceList list; |
815 ASSERT_TRUE(GetNetworkList(&list, INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)); | 824 ASSERT_TRUE(GetNetworkList(&list, INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)); |
816 for (NetworkInterfaceList::iterator it = list.begin(); | 825 for (NetworkInterfaceList::iterator it = list.begin(); |
817 it != list.end(); ++it) { | 826 it != list.end(); ++it) { |
818 // Verify that the names are not empty. | 827 // Verify that the names are not empty. |
819 EXPECT_FALSE(it->name.empty()); | 828 EXPECT_FALSE(it->name.empty()); |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { | 1498 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { |
1490 const NonUniqueNameTestData& test_data = GetParam(); | 1499 const NonUniqueNameTestData& test_data = GetParam(); |
1491 | 1500 |
1492 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); | 1501 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); |
1493 } | 1502 } |
1494 | 1503 |
1495 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, | 1504 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, |
1496 testing::ValuesIn(kNonUniqueNameTestData)); | 1505 testing::ValuesIn(kNonUniqueNameTestData)); |
1497 | 1506 |
1498 } // namespace net | 1507 } // namespace net |
OLD | NEW |