Skip to content

Commit 31233e7

Browse files
committed
Tests: Add a test for JPEG images with random bytes between segments
The image have been generated with our encoder but with the little twist of calling this function after some segments. ErrorOr<void> add_bytes(Stream& stream) { for (u8 i{}; i < NumericLimits<u8>::max(); ++i) TRY(stream.write_value<u8>(i)); return {}; }
1 parent 02c6486 commit 31233e7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Tests/LibGfx/TestImageDecoder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,15 @@ TEST_CASE(test_jpeg_malformed_frame)
585585
}
586586
}
587587

588+
TEST_CASE(test_jpeg_random_bytes_between_segments)
589+
{
590+
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("jpg/random_bytes_between_segments.jpg"sv)));
591+
EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes()));
592+
auto plugin_decoder = TRY_OR_FAIL(Gfx::JPEGImageDecoderPlugin::create(file->bytes()));
593+
594+
TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 16, 16 }));
595+
}
596+
588597
TEST_CASE(test_jpeg2000_spec_annex_j_10_bitplane_decoding)
589598
{
590599
// J.10.4 Arithmetic-coded compressed data
2.87 KB
Loading

0 commit comments

Comments
 (0)