Skip to content

Commit b6bd5f4

Browse files
MacDuenico
authored andcommitted
Tests/LibGfx: Add test of TGA image with an identifier
The test image was found in the TinyVG reference rendering examples (https://github.com/TinyVG/examples/tree/main/files), which have an MIT license.
1 parent 75e473e commit b6bd5f4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Tests/LibGfx/TestImageDecoder.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,25 @@ TEST_CASE(test_targa_image_descriptor)
14021402
}
14031403
}
14041404

1405+
TEST_CASE(test_targa_image_with_identifier)
1406+
{
1407+
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tga/image-with-identifier.tga"sv)));
1408+
EXPECT(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()));
1409+
auto plugin_decoder = TRY_OR_FAIL(Gfx::TGAImageDecoderPlugin::create(file->bytes()));
1410+
1411+
auto metadata = plugin_decoder->metadata();
1412+
EXPECT(metadata.has_value());
1413+
1414+
auto& tags = metadata->main_tags();
1415+
EXPECT_EQ(tags.size(), 1U);
1416+
auto ident = tags.get("Identifier"sv);
1417+
EXPECT(ident.has_value());
1418+
EXPECT_EQ(*ident, "Hello, TGA!"sv);
1419+
1420+
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 24, 24 }));
1421+
EXPECT_EQ(frame.image->get_pixel(5, 5), Gfx::Color(40, 172, 255));
1422+
}
1423+
14051424
TEST_CASE(test_tiff_uncompressed)
14061425
{
14071426
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/uncompressed.tiff"sv)));
Binary file not shown.

0 commit comments

Comments
 (0)