Tests: Add a pam test file

Hand-written in a text editor.

I verified that `convert` converts it to a png that looks like the
test expectations.
This commit is contained in:
Nico Weber 2024-01-25 11:29:05 -05:00 committed by Andreas Kling
parent 556addc5cb
commit ba8f4e73bf
2 changed files with 21 additions and 0 deletions

View file

@ -15,6 +15,7 @@
#include <LibGfx/ImageFormats/ImageDecoder.h>
#include <LibGfx/ImageFormats/JPEGLoader.h>
#include <LibGfx/ImageFormats/JPEGXLLoader.h>
#include <LibGfx/ImageFormats/PAMLoader.h>
#include <LibGfx/ImageFormats/PBMLoader.h>
#include <LibGfx/ImageFormats/PGMLoader.h>
#include <LibGfx/ImageFormats/PNGLoader.h>
@ -444,6 +445,18 @@ TEST_CASE(test_jpeg_malformed_frame)
}
}
TEST_CASE(test_pam_rgb)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("pnm/2x1.pam"sv)));
EXPECT(Gfx::PAMImageDecoderPlugin::sniff(file->bytes()));
auto plugin_decoder = TRY_OR_FAIL(Gfx::PAMImageDecoderPlugin::create(file->bytes()));
auto frame = TRY_OR_FAIL(expect_single_frame(*plugin_decoder));
EXPECT_EQ(frame.image->size(), Gfx::IntSize(2, 1));
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color('0', 'z', '0'));
EXPECT_EQ(frame.image->get_pixel(1, 0), Gfx::Color('0', '0', 'z'));
}
TEST_CASE(test_pbm)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.pbm"sv)));

View file

@ -0,0 +1,8 @@
P7
WIDTH 2
HEIGHT 1
DEPTH 3
MAXVAL 255
TUPLTYPE RGB
ENDHDR
0z000z