OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 "foobar://google.com:80/sup?yo", | 1306 "foobar://google.com:80/sup?yo", |
1307 }, | 1307 }, |
1308 }; | 1308 }; |
1309 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 1309 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
1310 SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, tests[i].input_url)); | 1310 SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, tests[i].input_url)); |
1311 GURL input_url(GURL(tests[i].input_url)); | 1311 GURL input_url(GURL(tests[i].input_url)); |
1312 GURL expected_url(GURL(tests[i].expected_simplified_url)); | 1312 GURL expected_url(GURL(tests[i].expected_simplified_url)); |
1313 EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); | 1313 EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); |
1314 } | 1314 } |
1315 } | 1315 } |
| 1316 |
| 1317 TEST(NetUtilTest, SetExplicitlyAllowedPortsTest) { |
| 1318 std::wstring invalid[] = { L"1,2,a", L"'1','2'", L"1, 2, 3", L"1 0,11,12" }; |
| 1319 std::wstring valid[] = { L"", L"1", L"1,2", L"1,2,3", L"10,11,12,13" }; |
| 1320 |
| 1321 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { |
| 1322 net::SetExplicitlyAllowedPorts(invalid[i]); |
| 1323 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); |
| 1324 } |
| 1325 |
| 1326 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { |
| 1327 net::SetExplicitlyAllowedPorts(valid[i]); |
| 1328 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); |
| 1329 } |
| 1330 } |
| 1331 |
OLD | NEW |