Chromium Code Reviews| Index: components/url_formatter/url_formatter_unittest.cc |
| diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc |
| index c0fe9509a6d4ac21a85ed744678e9468412c3155..128c4c3f80d13b4f206bb62a10dcd8a9f72cb15d 100644 |
| --- a/components/url_formatter/url_formatter_unittest.cc |
| +++ b/components/url_formatter/url_formatter_unittest.cc |
| @@ -27,11 +27,28 @@ using base::ASCIIToUTF16; |
| const size_t kNpos = base::string16::npos; |
| struct IDNTestCase { |
| + // The IDNA/Punycode version of the domain (plain ASCII). |
| const char* const input; |
| + // The equivalent Unicode version of the domain. Even if we expect the domain |
| + // to be displayed in Punycode, this should still contain the Unicode |
| + // equivalent (see |unicode_allowed|). |
| const wchar_t* unicode_output; |
| + // Whether we expect the domain to be displayed decoded as a Unicode string |
| + // (true) or in its Punycode form (false). |
| const bool unicode_allowed; |
| }; |
| +// These cases can be generated with the following simple Python function: |
| +// import codecs |
| +// def make_case(case_name, unicode_domain, unicode_allowed=True): |
| +// idna_input = codecs.encode(unicode_domain, 'idna').decode('ascii') |
| +// unicode_output = 'L' + (ascii(unicode_domain) |
| +// .replace("'", '"') |
| +// .replace('\\u', '\\x')) |
| +// print(' // %s' % case_name) |
| +// print(' {"%s", %s, %s},' % |
| +// (idna_input, unicode_output, repr(unicode_allowed).lower())) |
|
Peter Kasting
2017/02/06 21:54:14
You said this didn't warrant a separate tool, but
|
| + |
| const IDNTestCase idn_cases[] = { |
| // No IDN |
| {"www.google.com", L"www.google.com", true}, |