From e4e1ce289df9afe76a56cef06d83845f89770585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 9 Aug 2015 19:30:54 +0200 Subject: [PATCH] TgaImporter: test that the image can be loaded twice in a row. --- .../TgaImporter/Test/TgaImporterTest.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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)