Tests: Update TestFontHandling and add new test
Updates BitmapFont testing for fallible writes and adds a new test font file for use in a new un/masking test.
This commit is contained in:
parent
cc291a0ca7
commit
3c1ea2861b
Notes:
sideshowbarker
2024-07-17 08:27:02 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/3c1ea2861b Pull-request: https://github.com/SerenityOS/serenity/pull/14736 Reviewed-by: https://github.com/krkk
3 changed files with 21 additions and 1 deletions
|
@ -7,3 +7,5 @@ set(TEST_SOURCES
|
|||
foreach(source IN LISTS TEST_SOURCES)
|
||||
serenity_test("${source}" LibGfx LIBS LibGUI)
|
||||
endforeach()
|
||||
|
||||
install(FILES TestFont.font DESTINATION usr/Tests/LibGfx)
|
||||
|
|
BIN
Tests/LibGfx/TestFont.font
Normal file
BIN
Tests/LibGfx/TestFont.font
Normal file
Binary file not shown.
|
@ -131,6 +131,24 @@ TEST_CASE(test_write_to_file)
|
|||
|
||||
char path[] = "/tmp/new.font.XXXXXX";
|
||||
EXPECT(mkstemp(path) != -1);
|
||||
EXPECT(font->write_to_file(path));
|
||||
EXPECT(!font->write_to_file(path).is_error());
|
||||
unlink(path);
|
||||
}
|
||||
|
||||
TEST_CASE(test_character_set_masking)
|
||||
{
|
||||
auto font = Gfx::BitmapFont::try_load_from_file("/usr/Tests/LibGfx/TestFont.font");
|
||||
EXPECT(!font.is_error());
|
||||
|
||||
auto unmasked_font = font.value()->unmasked_character_set();
|
||||
EXPECT(!unmasked_font.is_error());
|
||||
EXPECT(unmasked_font.value()->glyph_index(0x0041).value() == 0x0041);
|
||||
EXPECT(unmasked_font.value()->glyph_index(0x0100).value() == 0x0100);
|
||||
EXPECT(unmasked_font.value()->glyph_index(0xFFFD).value() == 0xFFFD);
|
||||
|
||||
auto masked_font = unmasked_font.value()->masked_character_set();
|
||||
EXPECT(!masked_font.is_error());
|
||||
EXPECT(masked_font.value()->glyph_index(0x0041).value() == 0x0041);
|
||||
EXPECT(!masked_font.value()->glyph_index(0x0100).has_value());
|
||||
EXPECT(masked_font.value()->glyph_index(0xFFFD).value() == 0x1FD);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue