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

Unified Diff: url/url_canon_unittest.cc

Issue 2419083002: Add unit test for DefaultSchemeHostPort (Closed)
Patch Set: Nit Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_canon_unittest.cc
diff --git a/url/url_canon_unittest.cc b/url/url_canon_unittest.cc
index dfb3dfe1c4dd63ac05fab67cfac244bfcfc0e952..8f71a911188f4bd2031a3686f09d3b2d91447b4f 100644
--- a/url/url_canon_unittest.cc
+++ b/url/url_canon_unittest.cc
@@ -2173,4 +2173,31 @@ TEST(URLCanonTest, ReplacementOverflow) {
EXPECT_TRUE(expected == repl_str);
}
+TEST(URLCanonTest, DefaultPortForScheme) {
+ struct TestCases {
+ const char* scheme;
+ const int expected_port;
+ } cases[]{
+ {"http", 80},
+ {"https", 443},
+ {"ftp", 21},
+ {"ws", 80},
+ {"wss", 443},
+ {"gopher", 70},
+ {"fake-scheme", PORT_UNSPECIFIED},
+ {"HTTP", PORT_UNSPECIFIED},
+ {"HTTPS", PORT_UNSPECIFIED},
+ {"FTP", PORT_UNSPECIFIED},
+ {"WS", PORT_UNSPECIFIED},
+ {"WSS", PORT_UNSPECIFIED},
+ {"GOPHER", PORT_UNSPECIFIED},
+ };
+
+ for (auto& test_case : cases) {
+ SCOPED_TRACE(test_case.scheme);
+ EXPECT_EQ(test_case.expected_port,
+ DefaultPortForScheme(test_case.scheme, strlen(test_case.scheme)));
+ }
+}
+
} // namespace url
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698