OLD | NEW |
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 "url/url_parse.h" | 5 #include "url/url_parse.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "url/url_parse.h" | 9 #include "url/url_parse.h" |
10 | 10 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 352 |
353 TEST(URLParser, PathURL) { | 353 TEST(URLParser, PathURL) { |
354 // Declared outside for loop to try to catch cases in init() where we forget | 354 // Declared outside for loop to try to catch cases in init() where we forget |
355 // to reset something that is reset by the construtor. | 355 // to reset something that is reset by the construtor. |
356 url_parse::Parsed parsed; | 356 url_parse::Parsed parsed; |
357 for (size_t i = 0; i < arraysize(path_cases); i++) { | 357 for (size_t i = 0; i < arraysize(path_cases); i++) { |
358 const char* url = path_cases[i].input; | 358 const char* url = path_cases[i].input; |
359 url_parse::ParsePathURL(url, static_cast<int>(strlen(url)), &parsed); | 359 url_parse::ParsePathURL(url, static_cast<int>(strlen(url)), &parsed); |
360 | 360 |
361 EXPECT_TRUE(ComponentMatches(url, path_cases[i].scheme, parsed.scheme)); | 361 EXPECT_TRUE(ComponentMatches(url, path_cases[i].scheme, parsed.scheme)); |
362 EXPECT_TRUE(ComponentMatches(url, path_cases[i].path, parsed.path)); | 362 EXPECT_TRUE(ComponentMatches(url, path_cases[i].path, parsed.GetContent())); |
363 | 363 |
364 // The remaining components are never used for path urls. | 364 // The remaining components are never used for path urls. |
365 ExpectInvalidComponent(parsed.username); | 365 ExpectInvalidComponent(parsed.username); |
366 ExpectInvalidComponent(parsed.password); | 366 ExpectInvalidComponent(parsed.password); |
367 ExpectInvalidComponent(parsed.host); | 367 ExpectInvalidComponent(parsed.host); |
368 ExpectInvalidComponent(parsed.port); | 368 ExpectInvalidComponent(parsed.port); |
369 ExpectInvalidComponent(parsed.query); | |
370 ExpectInvalidComponent(parsed.ref); | |
371 } | 369 } |
372 } | 370 } |
373 | 371 |
374 // Various incarnations of file URLs. | 372 // Various incarnations of file URLs. |
375 static URLParseCase file_cases[] = { | 373 static URLParseCase file_cases[] = { |
376 #ifdef WIN32 | 374 #ifdef WIN32 |
377 {"file:server", "file", NULL, NULL, "server", -1, NULL, NU
LL, NULL}, | 375 {"file:server", "file", NULL, NULL, "server", -1, NULL, NU
LL, NULL}, |
378 {" file: server \t", "file", NULL, NULL, " server",-1, NULL, NU
LL, NULL}, | 376 {" file: server \t", "file", NULL, NULL, " server",-1, NULL, NU
LL, NULL}, |
379 {"FiLe:c|", "FiLe", NULL, NULL, NULL, -1, "c|", NU
LL, NULL}, | 377 {"FiLe:c|", "FiLe", NULL, NULL, NULL, -1, "c|", NU
LL, NULL}, |
380 {"FILE:/\\\\/server/file", "FILE", NULL, NULL, "server", -1, "/file", NU
LL, NULL}, | 378 {"FILE:/\\\\/server/file", "FILE", NULL, NULL, "server", -1, "/file", NU
LL, NULL}, |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 // The remaining components are never used for filesystem urls. | 679 // The remaining components are never used for filesystem urls. |
682 ExpectInvalidComponent(parsed.username); | 680 ExpectInvalidComponent(parsed.username); |
683 ExpectInvalidComponent(parsed.password); | 681 ExpectInvalidComponent(parsed.password); |
684 ExpectInvalidComponent(parsed.host); | 682 ExpectInvalidComponent(parsed.host); |
685 ExpectInvalidComponent(parsed.port); | 683 ExpectInvalidComponent(parsed.port); |
686 } | 684 } |
687 } | 685 } |
688 | 686 |
689 } // namespace | 687 } // namespace |
690 } // namespace url_parse | 688 } // namespace url_parse |
OLD | NEW |