|
|
|
|
@ -207,6 +207,10 @@ struct AbstractImporterTest: TestSuite::Tester {
|
|
|
|
|
void image1D(); |
|
|
|
|
void image1DCountNotImplemented(); |
|
|
|
|
void image1DCountNoFile(); |
|
|
|
|
void image1DLevelCountNotImplemented(); |
|
|
|
|
void image1DLevelCountNoFile(); |
|
|
|
|
void image1DLevelCountOutOfRange(); |
|
|
|
|
void image1DLevelCountZero(); |
|
|
|
|
void image1DForNameNotImplemented(); |
|
|
|
|
void image1DForNameNoFile(); |
|
|
|
|
void image1DNameNotImplemented(); |
|
|
|
|
@ -215,11 +219,16 @@ struct AbstractImporterTest: TestSuite::Tester {
|
|
|
|
|
void image1DNotImplemented(); |
|
|
|
|
void image1DNoFile(); |
|
|
|
|
void image1DOutOfRange(); |
|
|
|
|
void image1DLevelOutOfRange(); |
|
|
|
|
void image1DCustomDeleter(); |
|
|
|
|
|
|
|
|
|
void image2D(); |
|
|
|
|
void image2DCountNotImplemented(); |
|
|
|
|
void image2DCountNoFile(); |
|
|
|
|
void image2DLevelCountNotImplemented(); |
|
|
|
|
void image2DLevelCountNoFile(); |
|
|
|
|
void image2DLevelCountOutOfRange(); |
|
|
|
|
void image2DLevelCountZero(); |
|
|
|
|
void image2DForNameNotImplemented(); |
|
|
|
|
void image2DForNameNoFile(); |
|
|
|
|
void image2DNameNotImplemented(); |
|
|
|
|
@ -228,11 +237,16 @@ struct AbstractImporterTest: TestSuite::Tester {
|
|
|
|
|
void image2DNotImplemented(); |
|
|
|
|
void image2DNoFile(); |
|
|
|
|
void image2DOutOfRange(); |
|
|
|
|
void image2DLevelOutOfRange(); |
|
|
|
|
void image2DCustomDeleter(); |
|
|
|
|
|
|
|
|
|
void image3D(); |
|
|
|
|
void image3DCountNotImplemented(); |
|
|
|
|
void image3DCountNoFile(); |
|
|
|
|
void image3DLevelCountNotImplemented(); |
|
|
|
|
void image3DLevelCountNoFile(); |
|
|
|
|
void image3DLevelCountOutOfRange(); |
|
|
|
|
void image3DLevelCountZero(); |
|
|
|
|
void image3DForNameNotImplemented(); |
|
|
|
|
void image3DForNameNoFile(); |
|
|
|
|
void image3DNameNotImplemented(); |
|
|
|
|
@ -241,6 +255,7 @@ struct AbstractImporterTest: TestSuite::Tester {
|
|
|
|
|
void image3DNotImplemented(); |
|
|
|
|
void image3DNoFile(); |
|
|
|
|
void image3DOutOfRange(); |
|
|
|
|
void image3DLevelOutOfRange(); |
|
|
|
|
void image3DCustomDeleter(); |
|
|
|
|
|
|
|
|
|
void importerState(); |
|
|
|
|
@ -407,6 +422,10 @@ AbstractImporterTest::AbstractImporterTest() {
|
|
|
|
|
&AbstractImporterTest::image1D, |
|
|
|
|
&AbstractImporterTest::image1DCountNotImplemented, |
|
|
|
|
&AbstractImporterTest::image1DCountNoFile, |
|
|
|
|
&AbstractImporterTest::image1DLevelCountNotImplemented, |
|
|
|
|
&AbstractImporterTest::image1DLevelCountNoFile, |
|
|
|
|
&AbstractImporterTest::image1DLevelCountOutOfRange, |
|
|
|
|
&AbstractImporterTest::image1DLevelCountZero, |
|
|
|
|
&AbstractImporterTest::image1DForNameNotImplemented, |
|
|
|
|
&AbstractImporterTest::image1DForNameNoFile, |
|
|
|
|
&AbstractImporterTest::image1DNameNotImplemented, |
|
|
|
|
@ -415,11 +434,16 @@ AbstractImporterTest::AbstractImporterTest() {
|
|
|
|
|
&AbstractImporterTest::image1DNotImplemented, |
|
|
|
|
&AbstractImporterTest::image1DNoFile, |
|
|
|
|
&AbstractImporterTest::image1DOutOfRange, |
|
|
|
|
&AbstractImporterTest::image1DLevelOutOfRange, |
|
|
|
|
&AbstractImporterTest::image1DCustomDeleter, |
|
|
|
|
|
|
|
|
|
&AbstractImporterTest::image2D, |
|
|
|
|
&AbstractImporterTest::image2DCountNotImplemented, |
|
|
|
|
&AbstractImporterTest::image2DCountNoFile, |
|
|
|
|
&AbstractImporterTest::image2DLevelCountNotImplemented, |
|
|
|
|
&AbstractImporterTest::image2DLevelCountNoFile, |
|
|
|
|
&AbstractImporterTest::image2DLevelCountOutOfRange, |
|
|
|
|
&AbstractImporterTest::image2DLevelCountZero, |
|
|
|
|
&AbstractImporterTest::image2DForNameNotImplemented, |
|
|
|
|
&AbstractImporterTest::image2DForNameNoFile, |
|
|
|
|
&AbstractImporterTest::image2DNameNotImplemented, |
|
|
|
|
@ -428,11 +452,16 @@ AbstractImporterTest::AbstractImporterTest() {
|
|
|
|
|
&AbstractImporterTest::image2DNotImplemented, |
|
|
|
|
&AbstractImporterTest::image2DNoFile, |
|
|
|
|
&AbstractImporterTest::image2DOutOfRange, |
|
|
|
|
&AbstractImporterTest::image2DLevelOutOfRange, |
|
|
|
|
&AbstractImporterTest::image2DCustomDeleter, |
|
|
|
|
|
|
|
|
|
&AbstractImporterTest::image3D, |
|
|
|
|
&AbstractImporterTest::image3DCountNotImplemented, |
|
|
|
|
&AbstractImporterTest::image3DCountNoFile, |
|
|
|
|
&AbstractImporterTest::image3DLevelCountNotImplemented, |
|
|
|
|
&AbstractImporterTest::image3DLevelCountNoFile, |
|
|
|
|
&AbstractImporterTest::image3DLevelCountOutOfRange, |
|
|
|
|
&AbstractImporterTest::image3DLevelCountZero, |
|
|
|
|
&AbstractImporterTest::image3DForNameNotImplemented, |
|
|
|
|
&AbstractImporterTest::image3DForNameNoFile, |
|
|
|
|
&AbstractImporterTest::image3DNameNotImplemented, |
|
|
|
|
@ -441,6 +470,7 @@ AbstractImporterTest::AbstractImporterTest() {
|
|
|
|
|
&AbstractImporterTest::image3DNotImplemented, |
|
|
|
|
&AbstractImporterTest::image3DNoFile, |
|
|
|
|
&AbstractImporterTest::image3DOutOfRange, |
|
|
|
|
&AbstractImporterTest::image3DLevelOutOfRange, |
|
|
|
|
&AbstractImporterTest::image3DCustomDeleter, |
|
|
|
|
|
|
|
|
|
&AbstractImporterTest::importerState, |
|
|
|
|
@ -2672,6 +2702,10 @@ void AbstractImporterTest::image1D() {
|
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage1DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage1DLevelCount(UnsignedInt id) override { |
|
|
|
|
if(id == 7) return 3; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
Int doImage1DForName(const std::string& name) override { |
|
|
|
|
if(name == "eighth") return 7; |
|
|
|
|
else return -1; |
|
|
|
|
@ -2680,17 +2714,18 @@ void AbstractImporterTest::image1D() {
|
|
|
|
|
if(id == 7) return "eighth"; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
Containers::Optional<ImageData1D> doImage1D(UnsignedInt id) override { |
|
|
|
|
if(id == 7) return ImageData1D{PixelFormat::RGBA8Unorm, {}, {}, &state}; |
|
|
|
|
Containers::Optional<ImageData1D> doImage1D(UnsignedInt id, UnsignedInt level) override { |
|
|
|
|
if(id == 7 && level == 2) return ImageData1D{PixelFormat::RGBA8Unorm, {}, {}, &state}; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(importer.image1DCount(), 8); |
|
|
|
|
CORRADE_COMPARE(importer.image1DLevelCount(7), 3); |
|
|
|
|
CORRADE_COMPARE(importer.image1DForName("eighth"), 7); |
|
|
|
|
CORRADE_COMPARE(importer.image1DName(7), "eighth"); |
|
|
|
|
|
|
|
|
|
auto data = importer.image1D(7); |
|
|
|
|
auto data = importer.image1D(7, 2); |
|
|
|
|
CORRADE_VERIFY(data); |
|
|
|
|
CORRADE_COMPARE(data->importerState(), &state); |
|
|
|
|
} |
|
|
|
|
@ -2719,6 +2754,67 @@ void AbstractImporterTest::image1DCountNoFile() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image1DCount(): no file opened\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image1DLevelCountNotImplemented() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage1DCount() const override { return 8; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(importer.image1DLevelCount(7), 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image1DLevelCountNoFile() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return false; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image1DLevelCount(7); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image1DLevelCount(): no file opened\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image1DLevelCountOutOfRange() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage1DCount() const override { return 8; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image1DLevelCount(8); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image1DLevelCount(): index 8 out of range for 8 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image1DLevelCountZero() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage1DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage1DLevelCount(UnsignedInt) override { return 0; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image1DLevelCount(7); |
|
|
|
|
/* This should print a similar message instead of a confusing
|
|
|
|
|
"level 1 out of range for 0 entries" */ |
|
|
|
|
importer.image1D(7, 1); |
|
|
|
|
CORRADE_COMPARE(out.str(), |
|
|
|
|
"Trade::AbstractImporter::image1DLevelCount(): implementation reported zero levels\n" |
|
|
|
|
"Trade::AbstractImporter::image1D(): implementation reported zero levels\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image1DForNameNotImplemented() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
@ -2831,6 +2927,22 @@ void AbstractImporterTest::image1DOutOfRange() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image1D(): index 8 out of range for 8 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image1DLevelOutOfRange() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage1DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage1DLevelCount(UnsignedInt) override { return 3; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image1D(7, 3); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image1D(): level 3 out of range for 3 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image1DCustomDeleter() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
@ -2838,7 +2950,7 @@ void AbstractImporterTest::image1DCustomDeleter() {
|
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage1DCount() const override { return 1; } |
|
|
|
|
Containers::Optional<ImageData1D> doImage1D(UnsignedInt) override { |
|
|
|
|
Containers::Optional<ImageData1D> doImage1D(UnsignedInt, UnsignedInt) override { |
|
|
|
|
return ImageData1D{PixelFormat::RGBA8Unorm, {}, Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}}; |
|
|
|
|
} |
|
|
|
|
} importer; |
|
|
|
|
@ -2857,6 +2969,10 @@ void AbstractImporterTest::image2D() {
|
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage2DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage2DLevelCount(UnsignedInt id) override { |
|
|
|
|
if(id == 7) return 3; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
Int doImage2DForName(const std::string& name) override { |
|
|
|
|
if(name == "eighth") return 7; |
|
|
|
|
else return -1; |
|
|
|
|
@ -2865,17 +2981,18 @@ void AbstractImporterTest::image2D() {
|
|
|
|
|
if(id == 7) return "eighth"; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
Containers::Optional<ImageData2D> doImage2D(UnsignedInt id) override { |
|
|
|
|
if(id == 7) return ImageData2D{PixelFormat::RGBA8Unorm, {}, {}, &state}; |
|
|
|
|
Containers::Optional<ImageData2D> doImage2D(UnsignedInt id, UnsignedInt level) override { |
|
|
|
|
if(id == 7 && level == 2) return ImageData2D{PixelFormat::RGBA8Unorm, {}, {}, &state}; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(importer.image2DCount(), 8); |
|
|
|
|
CORRADE_COMPARE(importer.image2DLevelCount(7), 3); |
|
|
|
|
CORRADE_COMPARE(importer.image2DForName("eighth"), 7); |
|
|
|
|
CORRADE_COMPARE(importer.image2DName(7), "eighth"); |
|
|
|
|
|
|
|
|
|
auto data = importer.image2D(7); |
|
|
|
|
auto data = importer.image2D(7, 2); |
|
|
|
|
CORRADE_VERIFY(data); |
|
|
|
|
CORRADE_COMPARE(data->importerState(), &state); |
|
|
|
|
} |
|
|
|
|
@ -2904,6 +3021,67 @@ void AbstractImporterTest::image2DCountNoFile() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image2DCount(): no file opened\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image2DLevelCountNotImplemented() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage2DCount() const override { return 8; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(importer.image2DLevelCount(7), 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image2DLevelCountNoFile() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return false; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image2DLevelCount(7); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image2DLevelCount(): no file opened\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image2DLevelCountOutOfRange() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage2DCount() const override { return 8; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image2DLevelCount(8); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image2DLevelCount(): index 8 out of range for 8 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image2DLevelCountZero() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage2DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage2DLevelCount(UnsignedInt) override { return 0; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image2DLevelCount(7); |
|
|
|
|
/* This should print a similar message instead of a confusing
|
|
|
|
|
"level 1 out of range for 0 entries" */ |
|
|
|
|
importer.image2D(7, 1); |
|
|
|
|
CORRADE_COMPARE(out.str(), |
|
|
|
|
"Trade::AbstractImporter::image2DLevelCount(): implementation reported zero levels\n" |
|
|
|
|
"Trade::AbstractImporter::image2D(): implementation reported zero levels\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image2DForNameNotImplemented() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
@ -3016,6 +3194,22 @@ void AbstractImporterTest::image2DOutOfRange() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image2D(): index 8 out of range for 8 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image2DLevelOutOfRange() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage2DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage2DLevelCount(UnsignedInt) override { return 3; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image2D(7, 3); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image2D(): level 3 out of range for 3 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image2DCustomDeleter() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
@ -3023,7 +3217,7 @@ void AbstractImporterTest::image2DCustomDeleter() {
|
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage2DCount() const override { return 1; } |
|
|
|
|
Containers::Optional<ImageData2D> doImage2D(UnsignedInt) override { |
|
|
|
|
Containers::Optional<ImageData2D> doImage2D(UnsignedInt, UnsignedInt) override { |
|
|
|
|
return ImageData2D{PixelFormat::RGBA8Unorm, {}, Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}}; |
|
|
|
|
} |
|
|
|
|
} importer; |
|
|
|
|
@ -3042,6 +3236,10 @@ void AbstractImporterTest::image3D() {
|
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage3DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage3DLevelCount(UnsignedInt id) override { |
|
|
|
|
if(id == 7) return 3; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
Int doImage3DForName(const std::string& name) override { |
|
|
|
|
if(name == "eighth") return 7; |
|
|
|
|
else return -1; |
|
|
|
|
@ -3050,17 +3248,18 @@ void AbstractImporterTest::image3D() {
|
|
|
|
|
if(id == 7) return "eighth"; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
Containers::Optional<ImageData3D> doImage3D(UnsignedInt id) override { |
|
|
|
|
if(id == 7) return ImageData3D{PixelFormat::RGBA8Unorm, {}, {}, &state}; |
|
|
|
|
Containers::Optional<ImageData3D> doImage3D(UnsignedInt id, UnsignedInt level) override { |
|
|
|
|
if(id == 7 && level == 2) return ImageData3D{PixelFormat::RGBA8Unorm, {}, {}, &state}; |
|
|
|
|
else return {}; |
|
|
|
|
} |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(importer.image3DCount(), 8); |
|
|
|
|
CORRADE_COMPARE(importer.image3DLevelCount(7), 3); |
|
|
|
|
CORRADE_COMPARE(importer.image3DForName("eighth"), 7); |
|
|
|
|
CORRADE_COMPARE(importer.image3DName(7), "eighth"); |
|
|
|
|
|
|
|
|
|
auto data = importer.image3D(7); |
|
|
|
|
auto data = importer.image3D(7, 2); |
|
|
|
|
CORRADE_VERIFY(data); |
|
|
|
|
CORRADE_COMPARE(data->importerState(), &state); |
|
|
|
|
} |
|
|
|
|
@ -3089,6 +3288,68 @@ void AbstractImporterTest::image3DCountNoFile() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image3DCount(): no file opened\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image3DLevelCountNotImplemented() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage3DCount() const override { return 8; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(importer.image3DLevelCount(7), 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image3DLevelCountNoFile() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return false; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
|
|
|
|
|
importer.image3DLevelCount(7); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image3DLevelCount(): no file opened\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image3DLevelCountOutOfRange() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage3DCount() const override { return 8; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image3DLevelCount(8); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image3DLevelCount(): index 8 out of range for 8 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image3DLevelCountZero() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage3DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage3DLevelCount(UnsignedInt) override { return 0; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image3DLevelCount(7); |
|
|
|
|
/* This should print a similar message instead of a confusing
|
|
|
|
|
"level 1 out of range for 0 entries" */ |
|
|
|
|
importer.image3D(7, 1); |
|
|
|
|
CORRADE_COMPARE(out.str(), |
|
|
|
|
"Trade::AbstractImporter::image3DLevelCount(): implementation reported zero levels\n" |
|
|
|
|
"Trade::AbstractImporter::image3D(): implementation reported zero levels\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image3DForNameNotImplemented() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
@ -3201,6 +3462,22 @@ void AbstractImporterTest::image3DOutOfRange() {
|
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image3D(): index 8 out of range for 8 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image3DLevelOutOfRange() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
bool doIsOpened() const override { return true; } |
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage3DCount() const override { return 8; } |
|
|
|
|
UnsignedInt doImage3DLevelCount(UnsignedInt) override { return 3; } |
|
|
|
|
} importer; |
|
|
|
|
|
|
|
|
|
std::ostringstream out; |
|
|
|
|
Error redirectError{&out}; |
|
|
|
|
importer.image3D(7, 3); |
|
|
|
|
CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::image3D(): level 3 out of range for 3 entries\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AbstractImporterTest::image3DCustomDeleter() { |
|
|
|
|
struct: AbstractImporter { |
|
|
|
|
ImporterFeatures doFeatures() const override { return {}; } |
|
|
|
|
@ -3208,7 +3485,7 @@ void AbstractImporterTest::image3DCustomDeleter() {
|
|
|
|
|
void doClose() override {} |
|
|
|
|
|
|
|
|
|
UnsignedInt doImage3DCount() const override { return 1; } |
|
|
|
|
Containers::Optional<ImageData3D> doImage3D(UnsignedInt) override { |
|
|
|
|
Containers::Optional<ImageData3D> doImage3D(UnsignedInt, UnsignedInt) override { |
|
|
|
|
return ImageData3D{PixelFormat::RGBA8Unorm, {}, Containers::Array<char>{nullptr, 0, [](char*, std::size_t) {}}}; |
|
|
|
|
} |
|
|
|
|
} importer; |
|
|
|
|
|