| OLD | NEW |
| 1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 // Raw file paths on Windows aren't handled by the parser. | 303 // Raw file paths on Windows aren't handled by the parser. |
| 304 {"c:/foo", "c", NULL, NULL, "foo",
-1, NULL, NULL, NULL}, | 304 {"c:/foo", "c", NULL, NULL, "foo",
-1, NULL, NULL, NULL}, |
| 305 {"//foo/bar", NULL, NULL, NULL, "foo",
-1, "/bar", NULL, NULL}, | 305 {"//foo/bar", NULL, NULL, NULL, "foo",
-1, "/bar", NULL, NULL}, |
| 306 | 306 |
| 307 // Use the first question mark for the query and the ref. | 307 // Use the first question mark for the query and the ref. |
| 308 {"http://foo/path;a??e#f#g", "http", NULL, NULL, "foo",
-1, "/path;a", "?e", "f#g"}, | 308 {"http://foo/path;a??e#f#g", "http", NULL, NULL, "foo",
-1, "/path;a", "?e", "f#g"}, |
| 309 {"http://foo/abcd?efgh?ijkl", "http", NULL, NULL, "foo",
-1, "/abcd", "efgh?ijkl", NULL}, | 309 {"http://foo/abcd?efgh?ijkl", "http", NULL, NULL, "foo",
-1, "/abcd", "efgh?ijkl", NULL}, |
| 310 {"http://foo/abcd#foo?bar", "http", NULL, NULL, "foo",
-1, "/abcd", NULL, "foo?bar"}, | 310 {"http://foo/abcd#foo?bar", "http", NULL, NULL, "foo",
-1, "/abcd", NULL, "foo?bar"}, |
| 311 | 311 |
| 312 // IPV6, check also interesting uses of colons. | 312 // IPv6, check also interesting uses of colons. |
| 313 {"[61:24:74]:98", "[61", NULL, NULL, "24:74]",
98, NULL, NULL, NULL}, | 313 {"[61:24:74]:98", "[61", NULL, NULL, "24:74]",
98, NULL, NULL, NULL}, |
| 314 {"http://[61:27]:98", "http", NULL, NULL, "[61:27]",
98, NULL, NULL, NULL}, | 314 {"http://[61:27]:98", "http", NULL, NULL, "[61:27]",
98, NULL, NULL, NULL}, |
| 315 {"http:[61:27]/:foo", "http", NULL, NULL, "[61:27]",
-1, "/:foo", NULL, NULL}, | 315 {"http:[61:27]/:foo", "http", NULL, NULL, "[61:27]",
-1, "/:foo", NULL, NULL}, |
| 316 {"http://[1::2]:3:4", "http", NULL, NULL, "[1::2]:3",
4, NULL, NULL, NULL}, |
| 317 |
| 318 // Partially-complete IPv6 literals, and related cases. |
| 319 {"http://2001::1", "http", NULL, NULL, "2001:",
1, NULL, NULL, NULL}, |
| 320 {"http://[2001::1", "http", NULL, NULL, "[2001::1",
-1, NULL, NULL, NULL}, |
| 321 {"http://2001::1]", "http", NULL, NULL, "2001::1]",
-1, NULL, NULL, NULL}, |
| 322 {"http://2001::1]:80", "http", NULL, NULL, "2001::1]",
80, NULL, NULL, NULL}, |
| 323 {"http://[2001::1]", "http", NULL, NULL, "[2001::1]",
-1, NULL, NULL, NULL}, |
| 324 {"http://[2001::1]:80", "http", NULL, NULL, "[2001::1]",
80, NULL, NULL, NULL}, |
| 325 {"http://[[::]]", "http", NULL, NULL, "[[::]]",
-1, NULL, NULL, NULL}, |
| 316 | 326 |
| 317 }; | 327 }; |
| 318 | 328 |
| 319 TEST(URLParser, Standard) { | 329 TEST(URLParser, Standard) { |
| 320 // Declared outside for loop to try to catch cases in init() where we forget | 330 // Declared outside for loop to try to catch cases in init() where we forget |
| 321 // to reset something that is reset by the construtor. | 331 // to reset something that is reset by the construtor. |
| 322 url_parse::Parsed parsed; | 332 url_parse::Parsed parsed; |
| 323 for (size_t i = 0; i < arraysize(cases); i++) { | 333 for (size_t i = 0; i < arraysize(cases); i++) { |
| 324 const char* url = cases[i].input; | 334 const char* url = cases[i].input; |
| 325 url_parse::ParseStandardURL(url, static_cast<int>(strlen(url)), &parsed); | 335 url_parse::ParseStandardURL(url, static_cast<int>(strlen(url)), &parsed); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 EXPECT_TRUE(ComponentMatches(url, mailto_cases[i].query, parsed.query)); | 574 EXPECT_TRUE(ComponentMatches(url, mailto_cases[i].query, parsed.query)); |
| 565 EXPECT_EQ(url_parse::PORT_UNSPECIFIED, port); | 575 EXPECT_EQ(url_parse::PORT_UNSPECIFIED, port); |
| 566 | 576 |
| 567 // The remaining components are never used for mailto urls. | 577 // The remaining components are never used for mailto urls. |
| 568 ExpectInvalidComponent(parsed.username); | 578 ExpectInvalidComponent(parsed.username); |
| 569 ExpectInvalidComponent(parsed.password); | 579 ExpectInvalidComponent(parsed.password); |
| 570 ExpectInvalidComponent(parsed.port); | 580 ExpectInvalidComponent(parsed.port); |
| 571 ExpectInvalidComponent(parsed.ref); | 581 ExpectInvalidComponent(parsed.ref); |
| 572 } | 582 } |
| 573 } | 583 } |
| OLD | NEW |