mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
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
3 changed files with 21 additions and 1 deletions
|
@ -7,3 +7,5 @@ set(TEST_SOURCES
|
||||||
foreach(source IN LISTS TEST_SOURCES)
|
foreach(source IN LISTS TEST_SOURCES)
|
||||||
serenity_test("${source}" LibGfx LIBS LibGUI)
|
serenity_test("${source}" LibGfx LIBS LibGUI)
|
||||||
endforeach()
|
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";
|
char path[] = "/tmp/new.font.XXXXXX";
|
||||||
EXPECT(mkstemp(path) != -1);
|
EXPECT(mkstemp(path) != -1);
|
||||||
EXPECT(font->write_to_file(path));
|
EXPECT(!font->write_to_file(path).is_error());
|
||||||
unlink(path);
|
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
Add a link
Reference in a new issue