summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-02-26 18:02:50 +0000
committerAndreas Kling <kling@serenityos.org>2023-02-26 19:43:17 +0100
commit6cf8eeb7a46f72b48510ad8f4c6b32cb255e0404 (patch)
tree1eab3f938dae61649b1230d35becfbc58c85d132 /Tests
parent8d9cb538d6abc20cc34200e4835f5ac142e066f4 (diff)
downloadserenity-6cf8eeb7a46f72b48510ad8f4c6b32cb255e0404.zip
LibGfx: Return bool not ErrorOr<bool> from ImageDecoderPlugin::sniff()
Nobody made use of the ErrorOr return value and it just added more chance of confusion, since it was not clear if failing to sniff an image should return an error or false. The answer was false, if you returned Error you'd crash the ImageDecoder.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibGfx/TestImageDecoder.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp
index ced7b2a351..6597fc3d91 100644
--- a/Tests/LibGfx/TestImageDecoder.cpp
+++ b/Tests/LibGfx/TestImageDecoder.cpp
@@ -31,7 +31,7 @@
TEST_CASE(test_bmp)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("rgba32-1.bmp"sv)));
- EXPECT(MUST(Gfx::BMPImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::BMPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::BMPImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -46,7 +46,7 @@ TEST_CASE(test_bmp)
TEST_CASE(test_gif)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("download-animation.gif"sv)));
- EXPECT(MUST(Gfx::GIFImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::GIFImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::GIFImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -61,7 +61,7 @@ TEST_CASE(test_gif)
TEST_CASE(test_not_ico)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie.png"sv)));
- EXPECT(!MUST(Gfx::ICOImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(!Gfx::ICOImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::ICOImageDecoderPlugin::create(file->bytes()));
EXPECT(!plugin_decoder->initialize());
@@ -75,7 +75,7 @@ TEST_CASE(test_not_ico)
TEST_CASE(test_bmp_embedded_in_ico)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("serenity.ico"sv)));
- EXPECT(MUST(Gfx::ICOImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::ICOImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::ICOImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -89,7 +89,7 @@ TEST_CASE(test_bmp_embedded_in_ico)
TEST_CASE(test_jpg)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("rgb24.jpg"sv)));
- EXPECT(MUST(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -104,7 +104,7 @@ TEST_CASE(test_jpg)
TEST_CASE(test_pbm)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-raw.pbm"sv)));
- EXPECT(MUST(Gfx::PBMImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::PBMImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::PBMImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -119,7 +119,7 @@ TEST_CASE(test_pbm)
TEST_CASE(test_pgm)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-raw.pgm"sv)));
- EXPECT(MUST(Gfx::PGMImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::PGMImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::PGMImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -134,7 +134,7 @@ TEST_CASE(test_pgm)
TEST_CASE(test_png)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie.png"sv)));
- EXPECT(MUST(Gfx::PNGImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::PNGImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::PNGImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -149,7 +149,7 @@ TEST_CASE(test_png)
TEST_CASE(test_ppm)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie-raw.ppm"sv)));
- EXPECT(MUST(Gfx::PPMImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::PPMImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::PPMImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -224,7 +224,7 @@ TEST_CASE(test_targa_top_left_compressed)
TEST_CASE(test_webp_simple_lossy)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("simple-vp8.webp"sv)));
- EXPECT(MUST(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -238,7 +238,7 @@ TEST_CASE(test_webp_simple_lossy)
TEST_CASE(test_webp_simple_lossless)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("simple-vp8l.webp"sv)));
- EXPECT(MUST(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -252,7 +252,7 @@ TEST_CASE(test_webp_simple_lossless)
TEST_CASE(test_webp_extended_lossy)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("extended-lossy.webp"sv)));
- EXPECT(MUST(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -266,7 +266,7 @@ TEST_CASE(test_webp_extended_lossy)
TEST_CASE(test_webp_extended_lossless)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("extended-lossless.webp"sv)));
- EXPECT(MUST(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());
@@ -280,7 +280,7 @@ TEST_CASE(test_webp_extended_lossless)
TEST_CASE(test_webp_extended_lossless_animated)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("extended-lossless-animated.webp"sv)));
- EXPECT(MUST(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())));
+ EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
EXPECT(plugin_decoder->initialize());