summaryrefslogtreecommitdiff
path: root/Tests/LibGfx
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2023-05-07 20:14:06 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2023-05-14 15:39:38 -0600
commitf890b70eae1f0723913aa799a2b25ad3f1d4bf87 (patch)
tree89c27cf70ff5499f335d1fe4997d76ee9a3994f4 /Tests/LibGfx
parent87a7299078fe563b3e49f15994ee697b89d380a2 (diff)
downloadserenity-f890b70eae1f0723913aa799a2b25ad3f1d4bf87.zip
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
Diffstat (limited to 'Tests/LibGfx')
-rw-r--r--Tests/LibGfx/TestFontHandling.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/Tests/LibGfx/TestFontHandling.cpp b/Tests/LibGfx/TestFontHandling.cpp
index a1cde06f26..1c22989594 100644
--- a/Tests/LibGfx/TestFontHandling.cpp
+++ b/Tests/LibGfx/TestFontHandling.cpp
@@ -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 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);
+ auto font = TRY_OR_FAIL(Gfx::BitmapFont::try_load_from_file(TEST_INPUT("TestFont.font"sv)));
+
+ 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 = 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);
}