diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-08-27 17:51:17 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-08-30 19:42:40 +0100 |
commit | 30855e66639dfb36f3f5d41df44c836f07638cc2 (patch) | |
tree | 8a3e870fe83d09415a43de8bccae277d32bcf668 /Tests | |
parent | 29f76ef7c863726a705434d363e3b74fdcd0f2eb (diff) | |
download | serenity-30855e66639dfb36f3f5d41df44c836f07638cc2.zip |
LibUnicode: Parse locale private use extensions
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibUnicode/TestUnicodeLocale.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/LibUnicode/TestUnicodeLocale.cpp b/Tests/LibUnicode/TestUnicodeLocale.cpp index dc0aa45974..80b7ee8ba1 100644 --- a/Tests/LibUnicode/TestUnicodeLocale.cpp +++ b/Tests/LibUnicode/TestUnicodeLocale.cpp @@ -246,6 +246,30 @@ TEST_CASE(parse_unicode_locale_id_with_other_extension) pass("en-z-aa-bbb-cccccccc", { 'z', { "aa"sv, "bbb"sv, "cccccccc"sv } }); } +TEST_CASE(parse_unicode_locale_id_with_private_use_extension) +{ + auto fail = [](StringView locale) { + auto locale_id = Unicode::parse_unicode_locale_id(locale); + EXPECT(!locale_id.has_value()); + }; + auto pass = [](StringView locale, Vector<StringView> const& expected_extension) { + auto locale_id = Unicode::parse_unicode_locale_id(locale); + VERIFY(locale_id.has_value()); + EXPECT_EQ(locale_id->private_use_extensions, expected_extension); + }; + + fail("en-x"sv); + fail("en-x-"sv); + fail("en-x-aaaaaaaaa"sv); + fail("en-x-aaa-"sv); + fail("en-x-aaa-aaaaaaaaa"sv); + + pass("en-x-a", { "a"sv }); + pass("en-x-aaaaaaaa", { "aaaaaaaa"sv }); + pass("en-x-aaa-bbb", { "aaa"sv, "bbb"sv }); + pass("en-x-aaa-x-bbb", { "aaa"sv, "x"sv, "bbb"sv }); +} + TEST_CASE(canonicalize_unicode_locale_id) { auto test = [](StringView locale, StringView expected_canonical_locale) { |