mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
Tests: Prefer TRY_OR_FAIL() and MUST() over EXPECT(!.is_error())
Note that in some cases (in particular SQL::Result and PDFErrorOr), there is no Formatter defined for the error type, hence TRY_OR_FAIL cannot work as-is. Furthermore, this commit leaves untouched the places where MUST could be replaced by TRY_OR_FAIL. Inspired by: https://github.com/SerenityOS/serenity/pull/18710#discussion_r1186892445
This commit is contained in:
parent
87a7299078
commit
f890b70eae
23 changed files with 415 additions and 742 deletions
|
@ -146,24 +146,21 @@ TEST_CASE(test_write_to_file)
|
|||
|
||||
char path[] = "/tmp/new.font.XXXXXX";
|
||||
EXPECT(mkstemp(path) != -1);
|
||||
EXPECT(!font->write_to_file(path).is_error());
|
||||
TRY_OR_FAIL(font->write_to_file(path));
|
||||
unlink(path);
|
||||
}
|
||||
|
||||
TEST_CASE(test_character_set_masking)
|
||||
{
|
||||
auto font = Gfx::BitmapFont::try_load_from_file(TEST_INPUT("TestFont.font"sv));
|
||||
EXPECT(!font.is_error());
|
||||
auto font = TRY_OR_FAIL(Gfx::BitmapFont::try_load_from_file(TEST_INPUT("TestFont.font"sv)));
|
||||
|
||||
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 unmasked_font = TRY_OR_FAIL(font->unmasked_character_set());
|
||||
EXPECT(unmasked_font->glyph_index(0x0041).value() == 0x0041);
|
||||
EXPECT(unmasked_font->glyph_index(0x0100).value() == 0x0100);
|
||||
EXPECT(unmasked_font->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);
|
||||
auto masked_font = TRY_OR_FAIL(unmasked_font->masked_character_set());
|
||||
EXPECT(masked_font->glyph_index(0x0041).value() == 0x0041);
|
||||
EXPECT(!masked_font->glyph_index(0x0100).has_value());
|
||||
EXPECT(masked_font->glyph_index(0xFFFD).value() == 0x1FD);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue