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 <errno.h> | 5 #include <errno.h> |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "third_party/icu/source/common/unicode/ucnv.h" | 8 #include "third_party/icu/source/common/unicode/ucnv.h" |
9 #include "url/url_canon.h" | 9 #include "url/url_canon.h" |
10 #include "url/url_canon_icu.h" | 10 #include "url/url_canon_icu.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 {"GoOgLe.CoM", L"GoOgLe.CoM", "google.com", url_parse::Component(0, 10), Can
onHostInfo::NEUTRAL, -1, ""}, | 371 {"GoOgLe.CoM", L"GoOgLe.CoM", "google.com", url_parse::Component(0, 10), Can
onHostInfo::NEUTRAL, -1, ""}, |
372 // Spaces and some other characters should be escaped. | 372 // Spaces and some other characters should be escaped. |
373 {"Goo%20 goo%7C|.com", L"Goo%20 goo%7C|.com", "goo%20%20goo%7C%7C.com", url_
parse::Component(0, 22), CanonHostInfo::NEUTRAL, -1, ""}, | 373 {"Goo%20 goo%7C|.com", L"Goo%20 goo%7C|.com", "goo%20%20goo%7C%7C.com", url_
parse::Component(0, 22), CanonHostInfo::NEUTRAL, -1, ""}, |
374 // Exciting different types of spaces! | 374 // Exciting different types of spaces! |
375 {NULL, L"GOO\x00a0\x3000goo.com", "goo%20%20goo.com", url_parse::Component(0
, 16), CanonHostInfo::NEUTRAL, -1, ""}, | 375 {NULL, L"GOO\x00a0\x3000goo.com", "goo%20%20goo.com", url_parse::Component(0
, 16), CanonHostInfo::NEUTRAL, -1, ""}, |
376 // Other types of space (no-break, zero-width, zero-width-no-break) are | 376 // Other types of space (no-break, zero-width, zero-width-no-break) are |
377 // name-prepped away to nothing. | 377 // name-prepped away to nothing. |
378 {NULL, L"GOO\x200b\x2060\xfeffgoo.com", "googoo.com", url_parse::Component(0
, 10), CanonHostInfo::NEUTRAL, -1, ""}, | 378 {NULL, L"GOO\x200b\x2060\xfeffgoo.com", "googoo.com", url_parse::Component(0
, 10), CanonHostInfo::NEUTRAL, -1, ""}, |
379 // Ideographic full stop (full-width period for Chinese, etc.) should be | 379 // Ideographic full stop (full-width period for Chinese, etc.) should be |
380 // treated as a dot. | 380 // treated as a dot. |
381 {NULL, L"www.foo\x3002"L"bar.com", "www.foo.bar.com", url_parse::Component(0
, 15), CanonHostInfo::NEUTRAL, -1, ""}, | 381 {NULL, L"www.foo\x3002" L"bar.com", "www.foo.bar.com", url_parse::Component(
0, 15), CanonHostInfo::NEUTRAL, -1, ""}, |
382 // Invalid unicode characters should fail... | 382 // Invalid unicode characters should fail... |
383 // ...In wide input, ICU will barf and we'll end up with the input as | 383 // ...In wide input, ICU will barf and we'll end up with the input as |
384 // escaped UTF-8 (the invalid character should be replaced with the | 384 // escaped UTF-8 (the invalid character should be replaced with the |
385 // replacement character). | 385 // replacement character). |
386 {"\xef\xb7\x90zyx.com", L"\xfdd0zyx.com", "%EF%BF%BDzyx.com", url_parse::Com
ponent(0, 16), CanonHostInfo::BROKEN, -1, ""}, | 386 {"\xef\xb7\x90zyx.com", L"\xfdd0zyx.com", "%EF%BF%BDzyx.com", url_parse::Com
ponent(0, 16), CanonHostInfo::BROKEN, -1, ""}, |
387 // ...This is the same as previous but with with escaped. | 387 // ...This is the same as previous but with with escaped. |
388 {"%ef%b7%90zyx.com", L"%ef%b7%90zyx.com", "%EF%BF%BDzyx.com", url_parse::Com
ponent(0, 16), CanonHostInfo::BROKEN, -1, ""}, | 388 {"%ef%b7%90zyx.com", L"%ef%b7%90zyx.com", "%EF%BF%BDzyx.com", url_parse::Com
ponent(0, 16), CanonHostInfo::BROKEN, -1, ""}, |
389 // Test name prepping, fullwidth input should be converted to ASCII and NO
T | 389 // Test name prepping, fullwidth input should be converted to ASCII and NO
T |
390 // IDN-ized. This is "Go" in fullwidth UTF-8/UTF-16. | 390 // IDN-ized. This is "Go" in fullwidth UTF-8/UTF-16. |
391 {"\xef\xbc\xa7\xef\xbd\x8f.com", L"\xff27\xff4f.com", "go.com", url_parse::C
omponent(0, 6), CanonHostInfo::NEUTRAL, -1, ""}, | 391 {"\xef\xbc\xa7\xef\xbd\x8f.com", L"\xff27\xff4f.com", "go.com", url_parse::C
omponent(0, 6), CanonHostInfo::NEUTRAL, -1, ""}, |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2099 url_canon::StdStringCanonOutput repl_output(&repl_str); | 2099 url_canon::StdStringCanonOutput repl_output(&repl_str); |
2100 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed)
; | 2100 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed)
; |
2101 repl_output.Complete(); | 2101 repl_output.Complete(); |
2102 | 2102 |
2103 // Generate the expected string and check. | 2103 // Generate the expected string and check. |
2104 std::string expected("file:///foo?"); | 2104 std::string expected("file:///foo?"); |
2105 for (size_t i = 0; i < new_query.length(); i++) | 2105 for (size_t i = 0; i < new_query.length(); i++) |
2106 expected.push_back('a'); | 2106 expected.push_back('a'); |
2107 EXPECT_TRUE(expected == repl_str); | 2107 EXPECT_TRUE(expected == repl_str); |
2108 } | 2108 } |
OLD | NEW |