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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <errno.h> 5 #include <errno.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/third_party/mozilla/url_parse.h" 10 #include "url/third_party/mozilla/url_parse.h"
(...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed); 2166 ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed);
2167 repl_output.Complete(); 2167 repl_output.Complete();
2168 2168
2169 // Generate the expected string and check. 2169 // Generate the expected string and check.
2170 std::string expected("file:///foo?"); 2170 std::string expected("file:///foo?");
2171 for (size_t i = 0; i < new_query.length(); i++) 2171 for (size_t i = 0; i < new_query.length(); i++)
2172 expected.push_back('a'); 2172 expected.push_back('a');
2173 EXPECT_TRUE(expected == repl_str); 2173 EXPECT_TRUE(expected == repl_str);
2174 } 2174 }
2175 2175
2176 TEST(URLCanonTest, DefaultPortForScheme) {
2177 struct TestCases {
2178 const char* scheme;
2179 const int expected_port;
2180 } cases[]{
2181 {"http", 80},
2182 {"https", 443},
2183 {"ftp", 21},
2184 {"ws", 80},
2185 {"wss", 443},
2186 {"gopher", 70},
2187 {"fake-scheme", PORT_UNSPECIFIED},
2188 {"HTTP", PORT_UNSPECIFIED},
2189 {"HTTPS", PORT_UNSPECIFIED},
2190 {"FTP", PORT_UNSPECIFIED},
2191 {"WS", PORT_UNSPECIFIED},
2192 {"WSS", PORT_UNSPECIFIED},
2193 {"GOPHER", PORT_UNSPECIFIED},
2194 };
2195
2196 for (auto& test_case : cases) {
2197 SCOPED_TRACE(test_case.scheme);
2198 EXPECT_EQ(test_case.expected_port,
2199 DefaultPortForScheme(test_case.scheme, strlen(test_case.scheme)));
2200 }
2201 }
2202
2176 } // namespace url 2203 } // namespace url
OLDNEW
« 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