diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-02-13 13:44:51 -0500 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-02-15 10:13:19 -0500 |
commit | 5658524aa332e67a512f45d6a4a4af97a0f1e4f5 (patch) | |
tree | 88117826d4d4db7224bea45912be0b4481243c3c | |
parent | 0505e031f1a0eba5b717d00efd0ad11d49ecbca1 (diff) | |
download | serenity-5658524aa332e67a512f45d6a4a4af97a0f1e4f5.zip |
Tests: Add Unicode tests for CharacterType block properties
-rw-r--r-- | Tests/LibUnicode/TestUnicodeCharacterTypes.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Tests/LibUnicode/TestUnicodeCharacterTypes.cpp b/Tests/LibUnicode/TestUnicodeCharacterTypes.cpp index 3214acc237..20499d425f 100644 --- a/Tests/LibUnicode/TestUnicodeCharacterTypes.cpp +++ b/Tests/LibUnicode/TestUnicodeCharacterTypes.cpp @@ -579,6 +579,43 @@ TEST_CASE(script) } } +TEST_CASE(block) +{ + auto block = [](StringView name) { + auto block = Unicode::block_from_string(name); + VERIFY(block.has_value()); + return *block; + }; + + auto no_block = block("No_Block"sv); + auto block_nb = block("NB"sv); + EXPECT_EQ(no_block, block_nb); + + auto block_basic_latin = block("Basic_Latin"sv); + auto block_ascii = block("ASCII"sv); + EXPECT_EQ(block_basic_latin, block_ascii); + + auto block_greek_coptic = block("Greek_And_Coptic"sv); + auto block_greek = block("Greek"sv); + EXPECT_EQ(block_greek_coptic, block_greek); + + auto block_variation = block("Variation_Selectors_Supplement"sv); + auto block_vs_sup = block("VS_Sup"sv); + EXPECT_EQ(block_variation, block_vs_sup); + + for (u32 code_point = 0x0000; code_point <= 0x007F; ++code_point) + EXPECT(Unicode::code_point_has_block(code_point, block_basic_latin)); + + for (u32 code_point = 0xE0100; code_point <= 0xE01EF; ++code_point) + EXPECT(Unicode::code_point_has_block(code_point, block_variation)); + + for (u32 code_point = 0x0000; code_point <= 0x007F; ++code_point) + EXPECT_EQ("Basic Latin"sv, Unicode::code_point_block_display_name(code_point).value()); + + for (u32 code_point = 0x0370; code_point <= 0x03FF; ++code_point) + EXPECT_EQ("Greek and Coptic"sv, Unicode::code_point_block_display_name(code_point).value()); +} + TEST_CASE(script_extension) { auto script = [](StringView name) { |