mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-25 10:24:13 +00:00
LibUnicode: Replace code point bidirectional classes with ICU
This commit is contained in:
parent
e77dafc987
commit
aa3a30870b
Notes:
sideshowbarker
2024-07-17 02:37:08 +09:00
Author: https://github.com/trflynn89
Commit: aa3a30870b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/239
8 changed files with 102 additions and 348 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2021-2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -307,25 +307,13 @@ TEST_CASE(script_extension)
|
|||
|
||||
TEST_CASE(code_point_bidirectional_character_type)
|
||||
{
|
||||
auto code_point_bidi_class = [](u32 code_point) {
|
||||
auto bidi_class = Unicode::bidirectional_class(code_point);
|
||||
VERIFY(bidi_class.has_value());
|
||||
return bidi_class.release_value();
|
||||
};
|
||||
|
||||
auto bidi_class_from_string = [](StringView name) {
|
||||
auto result = Unicode::bidirectional_class_from_string(name);
|
||||
VERIFY(result.has_value());
|
||||
return result.release_value();
|
||||
};
|
||||
|
||||
// Left-to-right
|
||||
EXPECT_EQ(code_point_bidi_class('A'), bidi_class_from_string("L"sv));
|
||||
EXPECT_EQ(code_point_bidi_class('z'), bidi_class_from_string("L"sv));
|
||||
EXPECT_EQ(Unicode::bidirectional_class('A'), Unicode::BidiClass::LeftToRight);
|
||||
EXPECT_EQ(Unicode::bidirectional_class('z'), Unicode::BidiClass::LeftToRight);
|
||||
// European number
|
||||
EXPECT_EQ(code_point_bidi_class('7'), bidi_class_from_string("EN"sv));
|
||||
EXPECT_EQ(Unicode::bidirectional_class('7'), Unicode::BidiClass::EuropeanNumber);
|
||||
// Whitespace
|
||||
EXPECT_EQ(code_point_bidi_class(' '), bidi_class_from_string("WS"sv));
|
||||
EXPECT_EQ(Unicode::bidirectional_class(' '), Unicode::BidiClass::WhiteSpaceNeutral);
|
||||
// Arabic right-to-left (U+FEB4 ARABIC LETTER SEEN MEDIAL FORM)
|
||||
EXPECT_EQ(code_point_bidi_class(0xFEB4), bidi_class_from_string("AL"sv));
|
||||
EXPECT_EQ(Unicode::bidirectional_class(0xFEB4), Unicode::BidiClass::RightToLeftArabic);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue