mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibUnicode+LibJS+LibWeb: Propagate OOM from Unicode case transformations
This commit is contained in:
parent
48474b0de6
commit
1ff29afc45
Notes:
sideshowbarker
2024-07-17 01:53:15 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/1ff29afc45 Pull-request: https://github.com/SerenityOS/serenity/pull/16909
@ -53,306 +53,306 @@ TEST_CASE(to_unicode_uppercase)
|
|||||||
TEST_CASE(to_unicode_lowercase_unconditional_special_casing)
|
TEST_CASE(to_unicode_lowercase_unconditional_special_casing)
|
||||||
{
|
{
|
||||||
// LATIN SMALL LETTER SHARP S
|
// LATIN SMALL LETTER SHARP S
|
||||||
auto result = Unicode::to_unicode_lowercase_full("\u00DF"sv);
|
auto result = MUST(Unicode::to_unicode_lowercase_full("\u00DF"sv));
|
||||||
EXPECT_EQ(result, "\u00DF");
|
EXPECT_EQ(result, "\u00DF");
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I WITH DOT ABOVE
|
// LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||||
result = Unicode::to_unicode_lowercase_full("\u0130"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u0130"sv));
|
||||||
EXPECT_EQ(result, "\u0069\u0307");
|
EXPECT_EQ(result, "\u0069\u0307");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FF
|
// LATIN SMALL LIGATURE FF
|
||||||
result = Unicode::to_unicode_lowercase_full("\uFB00"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\uFB00"sv));
|
||||||
EXPECT_EQ(result, "\uFB00");
|
EXPECT_EQ(result, "\uFB00");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FI
|
// LATIN SMALL LIGATURE FI
|
||||||
result = Unicode::to_unicode_lowercase_full("\uFB01"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\uFB01"sv));
|
||||||
EXPECT_EQ(result, "\uFB01");
|
EXPECT_EQ(result, "\uFB01");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FL
|
// LATIN SMALL LIGATURE FL
|
||||||
result = Unicode::to_unicode_lowercase_full("\uFB02"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\uFB02"sv));
|
||||||
EXPECT_EQ(result, "\uFB02");
|
EXPECT_EQ(result, "\uFB02");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FFI
|
// LATIN SMALL LIGATURE FFI
|
||||||
result = Unicode::to_unicode_lowercase_full("\uFB03"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\uFB03"sv));
|
||||||
EXPECT_EQ(result, "\uFB03");
|
EXPECT_EQ(result, "\uFB03");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FFL
|
// LATIN SMALL LIGATURE FFL
|
||||||
result = Unicode::to_unicode_lowercase_full("\uFB04"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\uFB04"sv));
|
||||||
EXPECT_EQ(result, "\uFB04");
|
EXPECT_EQ(result, "\uFB04");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE LONG S T
|
// LATIN SMALL LIGATURE LONG S T
|
||||||
result = Unicode::to_unicode_lowercase_full("\uFB05"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\uFB05"sv));
|
||||||
EXPECT_EQ(result, "\uFB05");
|
EXPECT_EQ(result, "\uFB05");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE ST
|
// LATIN SMALL LIGATURE ST
|
||||||
result = Unicode::to_unicode_lowercase_full("\uFB06"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\uFB06"sv));
|
||||||
EXPECT_EQ(result, "\uFB06");
|
EXPECT_EQ(result, "\uFB06");
|
||||||
|
|
||||||
// GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
|
// GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
|
||||||
result = Unicode::to_unicode_lowercase_full("\u1FB7"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u1FB7"sv));
|
||||||
EXPECT_EQ(result, "\u1FB7");
|
EXPECT_EQ(result, "\u1FB7");
|
||||||
|
|
||||||
// GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI
|
// GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI
|
||||||
result = Unicode::to_unicode_lowercase_full("\u1FC7"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u1FC7"sv));
|
||||||
EXPECT_EQ(result, "\u1FC7");
|
EXPECT_EQ(result, "\u1FC7");
|
||||||
|
|
||||||
// GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
|
// GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
|
||||||
result = Unicode::to_unicode_lowercase_full("\u1FF7"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u1FF7"sv));
|
||||||
EXPECT_EQ(result, "\u1FF7");
|
EXPECT_EQ(result, "\u1FF7");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(to_unicode_lowercase_special_casing_sigma)
|
TEST_CASE(to_unicode_lowercase_special_casing_sigma)
|
||||||
{
|
{
|
||||||
auto result = Unicode::to_unicode_lowercase_full("ABCI"sv);
|
auto result = MUST(Unicode::to_unicode_lowercase_full("ABCI"sv));
|
||||||
EXPECT_EQ(result, "abci");
|
EXPECT_EQ(result, "abci");
|
||||||
|
|
||||||
// Sigma preceded by A
|
// Sigma preceded by A
|
||||||
result = Unicode::to_unicode_lowercase_full("A\u03A3"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A\u03A3"sv));
|
||||||
EXPECT_EQ(result, "a\u03C2");
|
EXPECT_EQ(result, "a\u03C2");
|
||||||
|
|
||||||
// Sigma preceded by FEMININE ORDINAL INDICATOR
|
// Sigma preceded by FEMININE ORDINAL INDICATOR
|
||||||
result = Unicode::to_unicode_lowercase_full("\u00AA\u03A3"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u00AA\u03A3"sv));
|
||||||
EXPECT_EQ(result, "\u00AA\u03C2");
|
EXPECT_EQ(result, "\u00AA\u03C2");
|
||||||
|
|
||||||
// Sigma preceded by ROMAN NUMERAL ONE
|
// Sigma preceded by ROMAN NUMERAL ONE
|
||||||
result = Unicode::to_unicode_lowercase_full("\u2160\u03A3"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u2160\u03A3"sv));
|
||||||
EXPECT_EQ(result, "\u2170\u03C2");
|
EXPECT_EQ(result, "\u2170\u03C2");
|
||||||
|
|
||||||
// Sigma preceded by COMBINING GREEK YPOGEGRAMMENI
|
// Sigma preceded by COMBINING GREEK YPOGEGRAMMENI
|
||||||
result = Unicode::to_unicode_lowercase_full("\u0345\u03A3"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u0345\u03A3"sv));
|
||||||
EXPECT_EQ(result, "\u0345\u03C3");
|
EXPECT_EQ(result, "\u0345\u03C3");
|
||||||
|
|
||||||
// Sigma preceded by A and FULL STOP
|
// Sigma preceded by A and FULL STOP
|
||||||
result = Unicode::to_unicode_lowercase_full("A.\u03A3"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A.\u03A3"sv));
|
||||||
EXPECT_EQ(result, "a.\u03C2");
|
EXPECT_EQ(result, "a.\u03C2");
|
||||||
|
|
||||||
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR
|
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR
|
||||||
result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A\u180E\u03A3"sv));
|
||||||
EXPECT_EQ(result, "a\u180E\u03C2");
|
EXPECT_EQ(result, "a\u180E\u03C2");
|
||||||
|
|
||||||
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by B
|
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by B
|
||||||
result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3B"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A\u180E\u03A3B"sv));
|
||||||
EXPECT_EQ(result, "a\u180E\u03C3b");
|
EXPECT_EQ(result, "a\u180E\u03C3b");
|
||||||
|
|
||||||
// Sigma followed by A
|
// Sigma followed by A
|
||||||
result = Unicode::to_unicode_lowercase_full("\u03A3A"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u03A3A"sv));
|
||||||
EXPECT_EQ(result, "\u03C3a");
|
EXPECT_EQ(result, "\u03C3a");
|
||||||
|
|
||||||
// Sigma preceded by A, followed by MONGOLIAN VOWEL SEPARATOR
|
// Sigma preceded by A, followed by MONGOLIAN VOWEL SEPARATOR
|
||||||
result = Unicode::to_unicode_lowercase_full("A\u03A3\u180E"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A\u03A3\u180E"sv));
|
||||||
EXPECT_EQ(result, "a\u03C2\u180E");
|
EXPECT_EQ(result, "a\u03C2\u180E");
|
||||||
|
|
||||||
// Sigma preceded by A, followed by MONGOLIAN VOWEL SEPARATOR and B
|
// Sigma preceded by A, followed by MONGOLIAN VOWEL SEPARATOR and B
|
||||||
result = Unicode::to_unicode_lowercase_full("A\u03A3\u180EB"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A\u03A3\u180EB"sv));
|
||||||
EXPECT_EQ(result, "a\u03C3\u180Eb");
|
EXPECT_EQ(result, "a\u03C3\u180Eb");
|
||||||
|
|
||||||
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR
|
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR
|
||||||
result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3\u180E"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A\u180E\u03A3\u180E"sv));
|
||||||
EXPECT_EQ(result, "a\u180E\u03C2\u180E");
|
EXPECT_EQ(result, "a\u180E\u03C2\u180E");
|
||||||
|
|
||||||
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR and B
|
// Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR and B
|
||||||
result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3\u180EB"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("A\u180E\u03A3\u180EB"sv));
|
||||||
EXPECT_EQ(result, "a\u180E\u03C3\u180Eb");
|
EXPECT_EQ(result, "a\u180E\u03C3\u180Eb");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(to_unicode_lowercase_special_casing_i)
|
TEST_CASE(to_unicode_lowercase_special_casing_i)
|
||||||
{
|
{
|
||||||
// LATIN CAPITAL LETTER I
|
// LATIN CAPITAL LETTER I
|
||||||
auto result = Unicode::to_unicode_lowercase_full("I"sv, "en"sv);
|
auto result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I"sv, "az"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "az"sv));
|
||||||
EXPECT_EQ(result, "\u0131"sv);
|
EXPECT_EQ(result, "\u0131"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I"sv, "tr"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "tr"sv));
|
||||||
EXPECT_EQ(result, "\u0131"sv);
|
EXPECT_EQ(result, "\u0131"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I WITH DOT ABOVE
|
// LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||||
result = Unicode::to_unicode_lowercase_full("\u0130"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u0130"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "\u0069\u0307"sv);
|
EXPECT_EQ(result, "\u0069\u0307"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("\u0130"sv, "az"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u0130"sv, "az"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("\u0130"sv, "tr"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u0130"sv, "tr"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I followed by COMBINING DOT ABOVE
|
// LATIN CAPITAL LETTER I followed by COMBINING DOT ABOVE
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0307"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0307"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "i\u0307"sv);
|
EXPECT_EQ(result, "i\u0307"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0307"sv, "az"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0307"sv, "az"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0307"sv, "tr"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0307"sv, "tr"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I followed by combining class 0 and COMBINING DOT ABOVE
|
// LATIN CAPITAL LETTER I followed by combining class 0 and COMBINING DOT ABOVE
|
||||||
result = Unicode::to_unicode_lowercase_full("IA\u0307"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("IA\u0307"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "ia\u0307"sv);
|
EXPECT_EQ(result, "ia\u0307"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("IA\u0307"sv, "az"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("IA\u0307"sv, "az"sv));
|
||||||
EXPECT_EQ(result, "\u0131a\u0307"sv);
|
EXPECT_EQ(result, "\u0131a\u0307"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("IA\u0307"sv, "tr"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("IA\u0307"sv, "tr"sv));
|
||||||
EXPECT_EQ(result, "\u0131a\u0307"sv);
|
EXPECT_EQ(result, "\u0131a\u0307"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(to_unicode_lowercase_special_casing_more_above)
|
TEST_CASE(to_unicode_lowercase_special_casing_more_above)
|
||||||
{
|
{
|
||||||
// LATIN CAPITAL LETTER I
|
// LATIN CAPITAL LETTER I
|
||||||
auto result = Unicode::to_unicode_lowercase_full("I"sv, "en"sv);
|
auto result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER J
|
// LATIN CAPITAL LETTER J
|
||||||
result = Unicode::to_unicode_lowercase_full("J"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("J"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "j"sv);
|
EXPECT_EQ(result, "j"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("J"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("J"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "j"sv);
|
EXPECT_EQ(result, "j"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I WITH OGONEK
|
// LATIN CAPITAL LETTER I WITH OGONEK
|
||||||
result = Unicode::to_unicode_lowercase_full("\u012e"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u012e"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "\u012f"sv);
|
EXPECT_EQ(result, "\u012f"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("\u012e"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u012e"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "\u012f"sv);
|
EXPECT_EQ(result, "\u012f"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I followed by COMBINING GRAVE ACCENT
|
// LATIN CAPITAL LETTER I followed by COMBINING GRAVE ACCENT
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0300"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0300"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "i\u0300"sv);
|
EXPECT_EQ(result, "i\u0300"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0300"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0300"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "i\u0307\u0300"sv);
|
EXPECT_EQ(result, "i\u0307\u0300"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER J followed by COMBINING GRAVE ACCENT
|
// LATIN CAPITAL LETTER J followed by COMBINING GRAVE ACCENT
|
||||||
result = Unicode::to_unicode_lowercase_full("J\u0300"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("J\u0300"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "j\u0300"sv);
|
EXPECT_EQ(result, "j\u0300"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("J\u0300"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("J\u0300"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "j\u0307\u0300"sv);
|
EXPECT_EQ(result, "j\u0307\u0300"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I WITH OGONEK followed by COMBINING GRAVE ACCENT
|
// LATIN CAPITAL LETTER I WITH OGONEK followed by COMBINING GRAVE ACCENT
|
||||||
result = Unicode::to_unicode_lowercase_full("\u012e\u0300"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u012e\u0300"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "\u012f\u0300"sv);
|
EXPECT_EQ(result, "\u012f\u0300"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("\u012e\u0300"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("\u012e\u0300"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "\u012f\u0307\u0300"sv);
|
EXPECT_EQ(result, "\u012f\u0307\u0300"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(to_unicode_lowercase_special_casing_not_before_dot)
|
TEST_CASE(to_unicode_lowercase_special_casing_not_before_dot)
|
||||||
{
|
{
|
||||||
// LATIN CAPITAL LETTER I
|
// LATIN CAPITAL LETTER I
|
||||||
auto result = Unicode::to_unicode_lowercase_full("I"sv, "en"sv);
|
auto result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I"sv, "az"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "az"sv));
|
||||||
EXPECT_EQ(result, "\u0131"sv);
|
EXPECT_EQ(result, "\u0131"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I"sv, "tr"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I"sv, "tr"sv));
|
||||||
EXPECT_EQ(result, "\u0131"sv);
|
EXPECT_EQ(result, "\u0131"sv);
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I followed by COMBINING DOT ABOVE
|
// LATIN CAPITAL LETTER I followed by COMBINING DOT ABOVE
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0307"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0307"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "i\u0307"sv);
|
EXPECT_EQ(result, "i\u0307"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0307"sv, "az"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0307"sv, "az"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_lowercase_full("I\u0307"sv, "tr"sv);
|
result = MUST(Unicode::to_unicode_lowercase_full("I\u0307"sv, "tr"sv));
|
||||||
EXPECT_EQ(result, "i"sv);
|
EXPECT_EQ(result, "i"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(to_unicode_uppercase_unconditional_special_casing)
|
TEST_CASE(to_unicode_uppercase_unconditional_special_casing)
|
||||||
{
|
{
|
||||||
// LATIN SMALL LETTER SHARP S
|
// LATIN SMALL LETTER SHARP S
|
||||||
auto result = Unicode::to_unicode_uppercase_full("\u00DF"sv);
|
auto result = MUST(Unicode::to_unicode_uppercase_full("\u00DF"sv));
|
||||||
EXPECT_EQ(result, "\u0053\u0053");
|
EXPECT_EQ(result, "\u0053\u0053");
|
||||||
|
|
||||||
// LATIN CAPITAL LETTER I WITH DOT ABOVE
|
// LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||||
result = Unicode::to_unicode_uppercase_full("\u0130"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\u0130"sv));
|
||||||
EXPECT_EQ(result, "\u0130");
|
EXPECT_EQ(result, "\u0130");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FF
|
// LATIN SMALL LIGATURE FF
|
||||||
result = Unicode::to_unicode_uppercase_full("\uFB00"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\uFB00"sv));
|
||||||
EXPECT_EQ(result, "\u0046\u0046");
|
EXPECT_EQ(result, "\u0046\u0046");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FI
|
// LATIN SMALL LIGATURE FI
|
||||||
result = Unicode::to_unicode_uppercase_full("\uFB01"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\uFB01"sv));
|
||||||
EXPECT_EQ(result, "\u0046\u0049");
|
EXPECT_EQ(result, "\u0046\u0049");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FL
|
// LATIN SMALL LIGATURE FL
|
||||||
result = Unicode::to_unicode_uppercase_full("\uFB02"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\uFB02"sv));
|
||||||
EXPECT_EQ(result, "\u0046\u004C");
|
EXPECT_EQ(result, "\u0046\u004C");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FFI
|
// LATIN SMALL LIGATURE FFI
|
||||||
result = Unicode::to_unicode_uppercase_full("\uFB03"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\uFB03"sv));
|
||||||
EXPECT_EQ(result, "\u0046\u0046\u0049");
|
EXPECT_EQ(result, "\u0046\u0046\u0049");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE FFL
|
// LATIN SMALL LIGATURE FFL
|
||||||
result = Unicode::to_unicode_uppercase_full("\uFB04"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\uFB04"sv));
|
||||||
EXPECT_EQ(result, "\u0046\u0046\u004C");
|
EXPECT_EQ(result, "\u0046\u0046\u004C");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE LONG S T
|
// LATIN SMALL LIGATURE LONG S T
|
||||||
result = Unicode::to_unicode_uppercase_full("\uFB05"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\uFB05"sv));
|
||||||
EXPECT_EQ(result, "\u0053\u0054");
|
EXPECT_EQ(result, "\u0053\u0054");
|
||||||
|
|
||||||
// LATIN SMALL LIGATURE ST
|
// LATIN SMALL LIGATURE ST
|
||||||
result = Unicode::to_unicode_uppercase_full("\uFB06"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\uFB06"sv));
|
||||||
EXPECT_EQ(result, "\u0053\u0054");
|
EXPECT_EQ(result, "\u0053\u0054");
|
||||||
|
|
||||||
// GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
|
// GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
|
||||||
result = Unicode::to_unicode_uppercase_full("\u0390"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\u0390"sv));
|
||||||
EXPECT_EQ(result, "\u0399\u0308\u0301");
|
EXPECT_EQ(result, "\u0399\u0308\u0301");
|
||||||
|
|
||||||
// GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
|
// GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
|
||||||
result = Unicode::to_unicode_uppercase_full("\u03B0"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\u03B0"sv));
|
||||||
EXPECT_EQ(result, "\u03A5\u0308\u0301");
|
EXPECT_EQ(result, "\u03A5\u0308\u0301");
|
||||||
|
|
||||||
// GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
|
// GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
|
||||||
result = Unicode::to_unicode_uppercase_full("\u1FB7"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\u1FB7"sv));
|
||||||
EXPECT_EQ(result, "\u0391\u0342\u0399");
|
EXPECT_EQ(result, "\u0391\u0342\u0399");
|
||||||
|
|
||||||
// GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI
|
// GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI
|
||||||
result = Unicode::to_unicode_uppercase_full("\u1FC7"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\u1FC7"sv));
|
||||||
EXPECT_EQ(result, "\u0397\u0342\u0399");
|
EXPECT_EQ(result, "\u0397\u0342\u0399");
|
||||||
|
|
||||||
// GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
|
// GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
|
||||||
result = Unicode::to_unicode_uppercase_full("\u1FF7"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("\u1FF7"sv));
|
||||||
EXPECT_EQ(result, "\u03A9\u0342\u0399");
|
EXPECT_EQ(result, "\u03A9\u0342\u0399");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(to_unicode_uppercase_special_casing_soft_dotted)
|
TEST_CASE(to_unicode_uppercase_special_casing_soft_dotted)
|
||||||
{
|
{
|
||||||
// LATIN SMALL LETTER I
|
// LATIN SMALL LETTER I
|
||||||
auto result = Unicode::to_unicode_uppercase_full("i"sv, "en"sv);
|
auto result = MUST(Unicode::to_unicode_uppercase_full("i"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "I"sv);
|
EXPECT_EQ(result, "I"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_uppercase_full("i"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("i"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "I"sv);
|
EXPECT_EQ(result, "I"sv);
|
||||||
|
|
||||||
// LATIN SMALL LETTER J
|
// LATIN SMALL LETTER J
|
||||||
result = Unicode::to_unicode_uppercase_full("j"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("j"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "J"sv);
|
EXPECT_EQ(result, "J"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_uppercase_full("j"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("j"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "J"sv);
|
EXPECT_EQ(result, "J"sv);
|
||||||
|
|
||||||
// LATIN SMALL LETTER I followed by COMBINING DOT ABOVE
|
// LATIN SMALL LETTER I followed by COMBINING DOT ABOVE
|
||||||
result = Unicode::to_unicode_uppercase_full("i\u0307"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("i\u0307"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "I\u0307"sv);
|
EXPECT_EQ(result, "I\u0307"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_uppercase_full("i\u0307"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("i\u0307"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "I"sv);
|
EXPECT_EQ(result, "I"sv);
|
||||||
|
|
||||||
// LATIN SMALL LETTER J followed by COMBINING DOT ABOVE
|
// LATIN SMALL LETTER J followed by COMBINING DOT ABOVE
|
||||||
result = Unicode::to_unicode_uppercase_full("j\u0307"sv, "en"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("j\u0307"sv, "en"sv));
|
||||||
EXPECT_EQ(result, "J\u0307"sv);
|
EXPECT_EQ(result, "J\u0307"sv);
|
||||||
|
|
||||||
result = Unicode::to_unicode_uppercase_full("j\u0307"sv, "lt"sv);
|
result = MUST(Unicode::to_unicode_uppercase_full("j\u0307"sv, "lt"sv));
|
||||||
EXPECT_EQ(result, "J"sv);
|
EXPECT_EQ(result, "J"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,13 +916,13 @@ static ThrowCompletionOr<DeprecatedString> transform_case(VM& vm, StringView str
|
|||||||
// 9. If targetCase is lower, then
|
// 9. If targetCase is lower, then
|
||||||
case TargetCase::Lower:
|
case TargetCase::Lower:
|
||||||
// a. Let newCodePoints be a List whose elements are the result of a lowercase transformation of codePoints according to an implementation-derived algorithm using locale or the Unicode Default Case Conversion algorithm.
|
// a. Let newCodePoints be a List whose elements are the result of a lowercase transformation of codePoints according to an implementation-derived algorithm using locale or the Unicode Default Case Conversion algorithm.
|
||||||
new_code_points = Unicode::to_unicode_lowercase_full(string, *locale);
|
new_code_points = TRY_OR_THROW_OOM(vm, Unicode::to_unicode_lowercase_full(string, *locale));
|
||||||
break;
|
break;
|
||||||
// 10. Else,
|
// 10. Else,
|
||||||
case TargetCase::Upper:
|
case TargetCase::Upper:
|
||||||
// a. Assert: targetCase is upper.
|
// a. Assert: targetCase is upper.
|
||||||
// b. Let newCodePoints be a List whose elements are the result of an uppercase transformation of codePoints according to an implementation-derived algorithm using locale or the Unicode Default Case Conversion algorithm.
|
// b. Let newCodePoints be a List whose elements are the result of an uppercase transformation of codePoints according to an implementation-derived algorithm using locale or the Unicode Default Case Conversion algorithm.
|
||||||
new_code_points = Unicode::to_unicode_uppercase_full(string, *locale);
|
new_code_points = TRY_OR_THROW_OOM(vm, Unicode::to_unicode_uppercase_full(string, *locale));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
@ -964,7 +964,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_locale_uppercase)
|
|||||||
JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_lowercase)
|
JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_lowercase)
|
||||||
{
|
{
|
||||||
auto string = TRY(ak_string_from(vm));
|
auto string = TRY(ak_string_from(vm));
|
||||||
auto lowercase = Unicode::to_unicode_lowercase_full(string);
|
auto lowercase = TRY_OR_THROW_OOM(vm, Unicode::to_unicode_lowercase_full(string));
|
||||||
return PrimitiveString::create(vm, move(lowercase));
|
return PrimitiveString::create(vm, move(lowercase));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -978,7 +978,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_string)
|
|||||||
JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_uppercase)
|
JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_uppercase)
|
||||||
{
|
{
|
||||||
auto string = TRY(ak_string_from(vm));
|
auto string = TRY(ak_string_from(vm));
|
||||||
auto uppercase = Unicode::to_unicode_uppercase_full(string);
|
auto uppercase = TRY_OR_THROW_OOM(vm, Unicode::to_unicode_uppercase_full(string));
|
||||||
return PrimitiveString::create(vm, move(uppercase));
|
return PrimitiveString::create(vm, move(uppercase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ u32 __attribute__((weak)) to_unicode_uppercase(u32 code_point)
|
|||||||
return to_ascii_uppercase(code_point);
|
return to_ascii_uppercase(code_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeprecatedString to_unicode_lowercase_full(StringView string, [[maybe_unused]] Optional<StringView> locale)
|
ErrorOr<DeprecatedString> to_unicode_lowercase_full(StringView string, [[maybe_unused]] Optional<StringView> locale)
|
||||||
{
|
{
|
||||||
#if ENABLE_UNICODE_DATA
|
#if ENABLE_UNICODE_DATA
|
||||||
Utf8View view { string };
|
Utf8View view { string };
|
||||||
@ -236,12 +236,12 @@ DeprecatedString to_unicode_lowercase_full(StringView string, [[maybe_unused]] O
|
|||||||
|
|
||||||
auto const* special_casing = find_matching_special_case(code_point, view, locale, index, byte_length);
|
auto const* special_casing = find_matching_special_case(code_point, view, locale, index, byte_length);
|
||||||
if (!special_casing) {
|
if (!special_casing) {
|
||||||
builder.append_code_point(to_unicode_lowercase(code_point));
|
TRY(builder.try_append_code_point(to_unicode_lowercase(code_point)));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < special_casing->lowercase_mapping_size; ++i)
|
for (size_t i = 0; i < special_casing->lowercase_mapping_size; ++i)
|
||||||
builder.append_code_point(special_casing->lowercase_mapping[i]);
|
TRY(builder.try_append_code_point(special_casing->lowercase_mapping[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
@ -250,7 +250,7 @@ DeprecatedString to_unicode_lowercase_full(StringView string, [[maybe_unused]] O
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DeprecatedString to_unicode_uppercase_full(StringView string, [[maybe_unused]] Optional<StringView> locale)
|
ErrorOr<DeprecatedString> to_unicode_uppercase_full(StringView string, [[maybe_unused]] Optional<StringView> locale)
|
||||||
{
|
{
|
||||||
#if ENABLE_UNICODE_DATA
|
#if ENABLE_UNICODE_DATA
|
||||||
Utf8View view { string };
|
Utf8View view { string };
|
||||||
@ -265,12 +265,12 @@ DeprecatedString to_unicode_uppercase_full(StringView string, [[maybe_unused]] O
|
|||||||
|
|
||||||
auto const* special_casing = find_matching_special_case(code_point, view, locale, index, byte_length);
|
auto const* special_casing = find_matching_special_case(code_point, view, locale, index, byte_length);
|
||||||
if (!special_casing) {
|
if (!special_casing) {
|
||||||
builder.append_code_point(to_unicode_uppercase(code_point));
|
TRY(builder.try_append_code_point(to_unicode_uppercase(code_point)));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < special_casing->uppercase_mapping_size; ++i)
|
for (size_t i = 0; i < special_casing->uppercase_mapping_size; ++i)
|
||||||
builder.append_code_point(special_casing->uppercase_mapping[i]);
|
TRY(builder.try_append_code_point(special_casing->uppercase_mapping[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
@ -39,8 +39,8 @@ Span<SpecialCasing const* const> special_case_mapping(u32 code_point);
|
|||||||
u32 to_unicode_lowercase(u32 code_point);
|
u32 to_unicode_lowercase(u32 code_point);
|
||||||
u32 to_unicode_uppercase(u32 code_point);
|
u32 to_unicode_uppercase(u32 code_point);
|
||||||
|
|
||||||
DeprecatedString to_unicode_lowercase_full(StringView, Optional<StringView> locale = {});
|
ErrorOr<DeprecatedString> to_unicode_lowercase_full(StringView, Optional<StringView> locale = {});
|
||||||
DeprecatedString to_unicode_uppercase_full(StringView, Optional<StringView> locale = {});
|
ErrorOr<DeprecatedString> to_unicode_uppercase_full(StringView, Optional<StringView> locale = {});
|
||||||
|
|
||||||
Optional<GeneralCategory> general_category_from_string(StringView);
|
Optional<GeneralCategory> general_category_from_string(StringView);
|
||||||
bool code_point_has_general_category(u32 code_point, GeneralCategory general_category);
|
bool code_point_has_general_category(u32 code_point, GeneralCategory general_category);
|
||||||
|
@ -32,7 +32,7 @@ static bool is_all_whitespace(StringView string)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DeprecatedString apply_text_transform(DeprecatedString const& string, CSS::TextTransform text_transform)
|
static ErrorOr<DeprecatedString> apply_text_transform(DeprecatedString const& string, CSS::TextTransform text_transform)
|
||||||
{
|
{
|
||||||
if (text_transform == CSS::TextTransform::Uppercase)
|
if (text_transform == CSS::TextTransform::Uppercase)
|
||||||
return Unicode::to_unicode_uppercase_full(string);
|
return Unicode::to_unicode_uppercase_full(string);
|
||||||
@ -44,7 +44,7 @@ static DeprecatedString apply_text_transform(DeprecatedString const& string, CSS
|
|||||||
// NOTE: This collapses whitespace into a single ASCII space if collapse is true.
|
// NOTE: This collapses whitespace into a single ASCII space if collapse is true.
|
||||||
void TextNode::compute_text_for_rendering(bool collapse)
|
void TextNode::compute_text_for_rendering(bool collapse)
|
||||||
{
|
{
|
||||||
auto data = apply_text_transform(dom_node().data(), computed_values().text_transform());
|
auto data = apply_text_transform(dom_node().data(), computed_values().text_transform()).release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
||||||
if (dom_node().is_password_input()) {
|
if (dom_node().is_password_input()) {
|
||||||
m_text_for_rendering = DeprecatedString::repeated('*', data.length());
|
m_text_for_rendering = DeprecatedString::repeated('*', data.length());
|
||||||
|
Loading…
Reference in New Issue
Block a user