Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: net/base/net_util_unittest.cc

Issue 1230313005: split port_util.h off of net_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove garbage that got added Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/net_util.cc ('k') | net/base/port_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 }; 433 };
434 for (size_t i = 0; i < arraysize(tests); ++i) { 434 for (size_t i = 0; i < arraysize(tests); ++i) {
435 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 435 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
436 tests[i].input_url)); 436 tests[i].input_url));
437 GURL input_url(GURL(tests[i].input_url)); 437 GURL input_url(GURL(tests[i].input_url));
438 GURL expected_url(GURL(tests[i].expected_simplified_url)); 438 GURL expected_url(GURL(tests[i].expected_simplified_url));
439 EXPECT_EQ(expected_url, SimplifyUrlForRequest(input_url)); 439 EXPECT_EQ(expected_url, SimplifyUrlForRequest(input_url));
440 } 440 }
441 } 441 }
442 442
443 TEST(NetUtilTest, SetExplicitlyAllowedPortsTest) {
444 std::string invalid[] = { "1,2,a", "'1','2'", "1, 2, 3", "1 0,11,12" };
445 std::string valid[] = { "", "1", "1,2", "1,2,3", "10,11,12,13" };
446
447 for (size_t i = 0; i < arraysize(invalid); ++i) {
448 SetExplicitlyAllowedPorts(invalid[i]);
449 EXPECT_EQ(0, static_cast<int>(GetCountOfExplicitlyAllowedPorts()));
450 }
451
452 for (size_t i = 0; i < arraysize(valid); ++i) {
453 SetExplicitlyAllowedPorts(valid[i]);
454 EXPECT_EQ(i, GetCountOfExplicitlyAllowedPorts());
455 }
456 }
457
458 TEST(NetUtilTest, GetHostOrSpecFromURL) { 443 TEST(NetUtilTest, GetHostOrSpecFromURL) {
459 EXPECT_EQ("example.com", 444 EXPECT_EQ("example.com",
460 GetHostOrSpecFromURL(GURL("http://example.com/test"))); 445 GetHostOrSpecFromURL(GURL("http://example.com/test")));
461 EXPECT_EQ("example.com", 446 EXPECT_EQ("example.com",
462 GetHostOrSpecFromURL(GURL("http://example.com./test"))); 447 GetHostOrSpecFromURL(GURL("http://example.com./test")));
463 EXPECT_EQ("file:///tmp/test.html", 448 EXPECT_EQ("file:///tmp/test.html",
464 GetHostOrSpecFromURL(GURL("file:///tmp/test.html"))); 449 GetHostOrSpecFromURL(GURL("file:///tmp/test.html")));
465 } 450 }
466 451
467 TEST(NetUtilTest, GetAddressFamily) { 452 TEST(NetUtilTest, GetAddressFamily) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { 676 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) {
692 const NonUniqueNameTestData& test_data = GetParam(); 677 const NonUniqueNameTestData& test_data = GetParam();
693 678
694 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); 679 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname));
695 } 680 }
696 681
697 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, 682 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest,
698 testing::ValuesIn(kNonUniqueNameTestData)); 683 testing::ValuesIn(kNonUniqueNameTestData));
699 684
700 } // namespace net 685 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.cc ('k') | net/base/port_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698