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

Side by Side Diff: url/gurl_unittest.cc

Issue 2378213002: Mark URLs with empty schemes as invalid. (Closed)
Patch Set: Comments 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 | « components/url_formatter/url_fixer_unittest.cc ('k') | url/url_canon_etc.cc » ('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 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 #include "url/url_canon.h" 10 #include "url/url_canon.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 "http://google.com", 225 "http://google.com",
226 "unknown://google.com", 226 "unknown://google.com",
227 "http://user:pass@google.com", 227 "http://user:pass@google.com",
228 "http://google.com:12345", 228 "http://google.com:12345",
229 "http://google.com/path", 229 "http://google.com/path",
230 "http://google.com//path", 230 "http://google.com//path",
231 "http://google.com?k=v#fragment", 231 "http://google.com?k=v#fragment",
232 "http://user:pass@google.com:12345/path?k=v#fragment", 232 "http://user:pass@google.com:12345/path?k=v#fragment",
233 "http:/path", 233 "http:/path",
234 "http:path", 234 "http:path",
235 "://google.com",
236 }; 235 };
237 for (size_t i = 0; i < arraysize(valid_cases); i++) { 236 for (size_t i = 0; i < arraysize(valid_cases); i++) {
238 EXPECT_TRUE(GURL(valid_cases[i]).is_valid()) 237 EXPECT_TRUE(GURL(valid_cases[i]).is_valid())
239 << "Case: " << valid_cases[i]; 238 << "Case: " << valid_cases[i];
240 } 239 }
241 240
242 const char* invalid_cases[] = { 241 const char* invalid_cases[] = {
243 "http://?k=v", 242 "http://?k=v",
244 "http:://google.com", 243 "http:://google.com",
245 "http//google.com", 244 "http//google.com",
246 "http://google.com:12three45", 245 "http://google.com:12three45",
246 "://google.com",
247 "path", 247 "path",
248 }; 248 };
249 for (size_t i = 0; i < arraysize(invalid_cases); i++) { 249 for (size_t i = 0; i < arraysize(invalid_cases); i++) {
250 EXPECT_FALSE(GURL(invalid_cases[i]).is_valid()) 250 EXPECT_FALSE(GURL(invalid_cases[i]).is_valid())
251 << "Case: " << invalid_cases[i]; 251 << "Case: " << invalid_cases[i];
252 } 252 }
253 } 253 }
254 254
255 TEST(GURLTest, ExtraSlashesBeforeAuthority) { 255 TEST(GURLTest, ExtraSlashesBeforeAuthority) {
256 // According to RFC3986, the hierarchical part for URI with an authority 256 // According to RFC3986, the hierarchical part for URI with an authority
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 }; 702 };
703 703
704 for (const auto& test : cases) { 704 for (const auto& test : cases) {
705 GURL url(test.url); 705 GURL url(test.url);
706 EXPECT_EQ(test.expected, url.path()) << test.url; 706 EXPECT_EQ(test.expected, url.path()) << test.url;
707 EXPECT_EQ(test.expected, url.GetContent()) << test.url; 707 EXPECT_EQ(test.expected, url.GetContent()) << test.url;
708 } 708 }
709 } 709 }
710 710
711 } // namespace url 711 } // namespace url
OLDNEW
« no previous file with comments | « components/url_formatter/url_fixer_unittest.cc ('k') | url/url_canon_etc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698