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

Unified Diff: url/url_canon_unittest.cc

Issue 2419083002: Add unit test for DefaultSchemeHostPort (Closed)
Patch Set: 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..77196bd46b0850da9a19198525e83dea4702399d 100644
--- a/url/url_canon_unittest.cc
+++ b/url/url_canon_unittest.cc
@@ -2173,4 +2173,32 @@ TEST(URLCanonTest, ReplacementOverflow) {
EXPECT_TRUE(expected == repl_str);
}
+TEST(URLCanonTest, DefaultPortForScheme) {
+ struct TestCases {
+ const std::string scheme;
Mike West 2016/10/14 14:32:26 Nit: If you make this `const char[]`, then you won
jww 2016/10/14 14:39:22 Done.
+ 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.c_str(),
+ test_case.scheme.size()));
+ }
+}
+
} // 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