|
|
|
@ -53,14 +53,11 @@ class TgaImporterTest: public TestSuite::Tester { |
|
|
|
void grayscaleBits8(); |
|
|
|
void grayscaleBits8(); |
|
|
|
void grayscaleBits16(); |
|
|
|
void grayscaleBits16(); |
|
|
|
|
|
|
|
|
|
|
|
void file(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void useTwice(); |
|
|
|
void useTwice(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
TgaImporterTest::TgaImporterTest() { |
|
|
|
TgaImporterTest::TgaImporterTest() { |
|
|
|
addTests({&TgaImporterTest::openNonexistent, |
|
|
|
addTests({&TgaImporterTest::openShort, |
|
|
|
&TgaImporterTest::openShort, |
|
|
|
|
|
|
|
&TgaImporterTest::paletted, |
|
|
|
&TgaImporterTest::paletted, |
|
|
|
&TgaImporterTest::compressed, |
|
|
|
&TgaImporterTest::compressed, |
|
|
|
|
|
|
|
|
|
|
|
@ -71,20 +68,9 @@ TgaImporterTest::TgaImporterTest() { |
|
|
|
&TgaImporterTest::grayscaleBits8, |
|
|
|
&TgaImporterTest::grayscaleBits8, |
|
|
|
&TgaImporterTest::grayscaleBits16, |
|
|
|
&TgaImporterTest::grayscaleBits16, |
|
|
|
|
|
|
|
|
|
|
|
&TgaImporterTest::file, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&TgaImporterTest::useTwice}); |
|
|
|
&TgaImporterTest::useTwice}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::openNonexistent() { |
|
|
|
|
|
|
|
std::ostringstream debug; |
|
|
|
|
|
|
|
Error::setOutput(&debug); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TgaImporter importer; |
|
|
|
|
|
|
|
CORRADE_VERIFY(!importer.openFile("nonexistent.file")); |
|
|
|
|
|
|
|
CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::openFile(): cannot open file nonexistent.file\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::openShort() { |
|
|
|
void TgaImporterTest::openShort() { |
|
|
|
TgaImporter importer; |
|
|
|
TgaImporter importer; |
|
|
|
const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
|
|
|
@ -214,29 +200,6 @@ void TgaImporterTest::grayscaleBits16() { |
|
|
|
CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): unsupported grayscale bits-per-pixel: 16\n"); |
|
|
|
CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): unsupported grayscale bits-per-pixel: 16\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::file() { |
|
|
|
|
|
|
|
TgaImporter importer; |
|
|
|
|
|
|
|
const char data[] = { |
|
|
|
|
|
|
|
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 8, 0, |
|
|
|
|
|
|
|
1, 2, |
|
|
|
|
|
|
|
3, 4, |
|
|
|
|
|
|
|
5, 6 |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
CORRADE_VERIFY(importer.openFile(Utility::Directory::join(TGAIMPORTER_TEST_DIR, "file.tga"))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::optional<Trade::ImageData2D> image = importer.image2D(0); |
|
|
|
|
|
|
|
CORRADE_VERIFY(image); |
|
|
|
|
|
|
|
#ifndef MAGNUM_TARGET_GLES2 |
|
|
|
|
|
|
|
CORRADE_COMPARE(image->format(), PixelFormat::Red); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
CORRADE_COMPARE(image->format(), PixelFormat::Luminance); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
CORRADE_COMPARE(image->size(), Vector2i(2, 3)); |
|
|
|
|
|
|
|
CORRADE_COMPARE(image->type(), PixelType::UnsignedByte); |
|
|
|
|
|
|
|
CORRADE_COMPARE_AS(image->data(), Containers::ArrayView<const char>{data}.suffix(18), |
|
|
|
|
|
|
|
TestSuite::Compare::Container); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TgaImporterTest::useTwice() { |
|
|
|
void TgaImporterTest::useTwice() { |
|
|
|
TgaImporter importer; |
|
|
|
TgaImporter importer; |
|
|
|
CORRADE_VERIFY(importer.openFile(Utility::Directory::join(TGAIMPORTER_TEST_DIR, "file.tga"))); |
|
|
|
CORRADE_VERIFY(importer.openFile(Utility::Directory::join(TGAIMPORTER_TEST_DIR, "file.tga"))); |
|
|
|
|