Browse Source

TgaImporter: test that the image can be loaded twice in a row.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
e4e1ce289d
  1. 22
      src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp

22
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<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->size(), (Vector2i{2, 3}));
} {
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->size(), (Vector2i{2, 3}));
}
}
}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::TgaImporterTest)

Loading…
Cancel
Save