| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 }; | 1839 }; |
| 1840 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 1840 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 1841 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].input_url)); | 1841 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].input_url)); |
| 1842 GURL input_url(GURL(tests[i].input_url)); | 1842 GURL input_url(GURL(tests[i].input_url)); |
| 1843 GURL expected_url(GURL(tests[i].expected_simplified_url)); | 1843 GURL expected_url(GURL(tests[i].expected_simplified_url)); |
| 1844 EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); | 1844 EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); |
| 1845 } | 1845 } |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 TEST(NetUtilTest, SetExplicitlyAllowedPortsTest) { | 1848 TEST(NetUtilTest, SetExplicitlyAllowedPortsTest) { |
| 1849 std::wstring invalid[] = { L"1,2,a", L"'1','2'", L"1, 2, 3", L"1 0,11,12" }; | 1849 std::string invalid[] = { "1,2,a", "'1','2'", "1, 2, 3", "1 0,11,12" }; |
| 1850 std::wstring valid[] = { L"", L"1", L"1,2", L"1,2,3", L"10,11,12,13" }; | 1850 std::string valid[] = { "", "1", "1,2", "1,2,3", "10,11,12,13" }; |
| 1851 | 1851 |
| 1852 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { | 1852 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { |
| 1853 net::SetExplicitlyAllowedPorts(invalid[i]); | 1853 net::SetExplicitlyAllowedPorts(invalid[i]); |
| 1854 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); | 1854 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { | 1857 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { |
| 1858 net::SetExplicitlyAllowedPorts(valid[i]); | 1858 net::SetExplicitlyAllowedPorts(valid[i]); |
| 1859 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); | 1859 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); |
| 1860 } | 1860 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 EXPECT_TRUE(net::ParseCIDRBlock(tests[i].cidr_literal, | 2022 EXPECT_TRUE(net::ParseCIDRBlock(tests[i].cidr_literal, |
| 2023 &ip_prefix, | 2023 &ip_prefix, |
| 2024 &prefix_length_in_bits)); | 2024 &prefix_length_in_bits)); |
| 2025 | 2025 |
| 2026 EXPECT_EQ(tests[i].expected_to_match, | 2026 EXPECT_EQ(tests[i].expected_to_match, |
| 2027 net::IPNumberMatchesPrefix(ip_number, | 2027 net::IPNumberMatchesPrefix(ip_number, |
| 2028 ip_prefix, | 2028 ip_prefix, |
| 2029 prefix_length_in_bits)); | 2029 prefix_length_in_bits)); |
| 2030 } | 2030 } |
| 2031 } | 2031 } |
| OLD | NEW |