diff --git a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp b/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp index 4cdb86e43..2f49b1a11 100644 --- a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp +++ b/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp @@ -54,6 +54,8 @@ class TgaImporterTest: public TestSuite::Tester { void grayscaleBits16(); void file(); + + void useTwice(); }; TgaImporterTest::TgaImporterTest() { @@ -69,7 +71,9 @@ TgaImporterTest::TgaImporterTest() { &TgaImporterTest::grayscaleBits8, &TgaImporterTest::grayscaleBits16, - &TgaImporterTest::file}); + &TgaImporterTest::file, + + &TgaImporterTest::useTwice}); } void TgaImporterTest::openNonexistent() { @@ -230,6 +234,22 @@ void TgaImporterTest::file() { TestSuite::Compare::Container); } +void TgaImporterTest::useTwice() { + TgaImporter importer; + CORRADE_VERIFY(importer.openFile(Utility::Directory::join(TGAIMPORTER_TEST_DIR, "file.tga"))); + + /* Verify that the file is rewinded for second use */ + { + std::optional image = importer.image2D(0); + CORRADE_VERIFY(image); + CORRADE_COMPARE(image->size(), (Vector2i{2, 3})); + } { + std::optional image = importer.image2D(0); + CORRADE_VERIFY(image); + CORRADE_COMPARE(image->size(), (Vector2i{2, 3})); + } +} + }}} CORRADE_TEST_MAIN(Magnum::Trade::Test::TgaImporterTest)