/* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include /** @todo remove once Debug is stream-free */ #include #include #include #include #include #include #include "Magnum/Image.h" #include "Magnum/ImageView.h" #include "Magnum/PixelFormat.h" #include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/ImageData.h" #include "configure.h" namespace Magnum { namespace Trade { namespace Test { namespace { struct AbstractImageConverterTest: TestSuite::Tester { explicit AbstractImageConverterTest(); void construct(); void constructWithPluginManagerReference(); void setFlags(); void setFlagsNotImplemented(); void thingNotSupported(); void convert1D(); void convert2D(); void convert3D(); void convert1DNotImplemented(); void convert2DNotImplemented(); void convert3DNotImplemented(); void convert1DCustomDeleter(); void convert2DCustomDeleter(); void convert3DCustomDeleter(); void convertCompressed1D(); void convertCompressed2D(); void convertCompressed3D(); void convertCompressed1DNotImplemented(); void convertCompressed2DNotImplemented(); void convertCompressed3DNotImplemented(); void convertCompressed1DCustomDeleter(); void convertCompressed2DCustomDeleter(); void convertCompressed3DCustomDeleter(); void convertImageData1D(); void convertImageData2D(); void convertImageData3D(); void convert1DToData(); void convert2DToData(); void convert3DToData(); /* 1D/2D/3D share the same image validity check function, so only verify one dimension thoroughly and for others just that the check is used */ void convert1DToDataInvalidImage(); void convert2DToDataZeroSize(); void convert2DToDataNullptr(); void convert3DToDataInvalidImage(); void convert1DToDataNotImplemented(); void convert2DToDataNotImplemented(); void convert3DToDataNotImplemented(); void convert1DToDataCustomDeleter(); void convert2DToDataCustomDeleter(); void convert3DToDataCustomDeleter(); void convertCompressed1DToData(); void convertCompressed2DToData(); void convertCompressed3DToData(); /* Compressed share the same image validity check function with uncompressed, so only verify it's used */ void convertCompressed1DToDataInvalidImage(); void convertCompressed2DToDataInvalidImage(); void convertCompressed3DToDataInvalidImage(); void convertCompressed1DToDataNotImplemented(); void convertCompressed2DToDataNotImplemented(); void convertCompressed3DToDataNotImplemented(); void convertCompressed1DToDataCustomDeleter(); void convertCompressed2DToDataCustomDeleter(); void convertCompressed3DToDataCustomDeleter(); void convertImageData1DToData(); void convertImageData2DToData(); void convertImageData3DToData(); void convertLevels1DToData(); void convertLevels2DToData(); void convertLevels3DToData(); /* 1D/2D/3D share the same image list validity check function, so only verify one dimension thoroughly and for others just that the check is used */ void convertLevels1DToDataInvalidImage(); void convertLevels2DToDataNoLevels(); void convertLevels2DToDataZeroSize(); void convertLevels2DToDataNullptr(); void convertLevels2DToDataInconsistentFormat(); void convertLevels2DToDataInconsistentFormatExtra(); void convertLevels3DToDataInvalidImage(); void convertLevels1DToDataNotImplemented(); void convertLevels2DToDataNotImplemented(); void convertLevels3DToDataNotImplemented(); void convertLevels1DToDataCustomDeleter(); void convertLevels2DToDataCustomDeleter(); void convertLevels3DToDataCustomDeleter(); void convertCompressedLevels1DToData(); void convertCompressedLevels2DToData(); void convertCompressedLevels3DToData(); /* Compressed have different format checks for uncompressed so it's tested again; 1D/2D/3D share the same image list validity check function, so only verify one dimension thoroughly and for others just that the check is used */ void convertCompressedLevels1DToDataInvalidImage(); void convertCompressedLevels2DToDataNoLevels(); void convertCompressedLevels2DToDataZeroSize(); void convertCompressedLevels2DToDataNullptr(); void convertCompressedLevels2DToDataInconsistentFormat(); void convertCompressedLevels3DToDataInvalidImage(); void convertCompressedLevels1DToDataNotImplemented(); void convertCompressedLevels2DToDataNotImplemented(); void convertCompressedLevels3DToDataNotImplemented(); void convertCompressedLevels1DToDataCustomDeleter(); void convertCompressedLevels2DToDataCustomDeleter(); void convertCompressedLevels3DToDataCustomDeleter(); void convert1DToDataThroughLevels(); void convert2DToDataThroughLevels(); void convert3DToDataThroughLevels(); void convertCompressed1DToDataThroughLevels(); void convertCompressed2DToDataThroughLevels(); void convertCompressed3DToDataThroughLevels(); void convert1DToFile(); void convert2DToFile(); void convert3DToFile(); void convert1DToFileThroughData(); void convert2DToFileThroughData(); void convert3DToFileThroughData(); void convert1DToFileThroughDataFailed(); void convert2DToFileThroughDataFailed(); void convert3DToFileThroughDataFailed(); void convert1DToFileThroughDataNotWritable(); void convert2DToFileThroughDataNotWritable(); void convert3DToFileThroughDataNotWritable(); /* ToFile share the same check function with ToData, so only verify it's used */ void convert1DToFileInvalidImage(); void convert2DToFileInvalidImage(); void convert3DToFileInvalidImage(); void convert1DToFileNotImplemented(); void convert2DToFileNotImplemented(); void convert3DToFileNotImplemented(); void convertCompressed1DToFile(); void convertCompressed2DToFile(); void convertCompressed3DToFile(); void convertCompressed1DToFileThroughData(); void convertCompressed2DToFileThroughData(); void convertCompressed3DToFileThroughData(); void convertCompressed1DToFileThroughDataFailed(); void convertCompressed2DToFileThroughDataFailed(); void convertCompressed3DToFileThroughDataFailed(); void convertCompressed1DToFileThroughDataNotWritable(); void convertCompressed2DToFileThroughDataNotWritable(); void convertCompressed3DToFileThroughDataNotWritable(); /* ToFile share the same check function with ToData, so only verify it's used */ void convertCompressed1DToFileInvalidImage(); void convertCompressed2DToFileInvalidImage(); void convertCompressed3DToFileInvalidImage(); void convertCompressed1DToFileNotImplemented(); void convertCompressed2DToFileNotImplemented(); void convertCompressed3DToFileNotImplemented(); void convertImageData1DToFile(); void convertImageData2DToFile(); void convertImageData3DToFile(); void convertLevels1DToFile(); void convertLevels2DToFile(); void convertLevels3DToFile(); void convertLevels1DToFileThroughData(); void convertLevels2DToFileThroughData(); void convertLevels3DToFileThroughData(); void convertLevels1DToFileThroughDataFailed(); void convertLevels2DToFileThroughDataFailed(); void convertLevels3DToFileThroughDataFailed(); void convertLevels1DToFileThroughDataNotWritable(); void convertLevels2DToFileThroughDataNotWritable(); void convertLevels3DToFileThroughDataNotWritable(); /* ToFile share the same check function with ToData, so only verify it's used */ void convertLevels1DToFileInvalidImage(); void convertLevels2DToFileInvalidImage(); void convertLevels3DToFileInvalidImage(); void convertLevels1DToFileNotImplemented(); void convertLevels2DToFileNotImplemented(); void convertLevels3DToFileNotImplemented(); void convertCompressedLevels1DToFile(); void convertCompressedLevels2DToFile(); void convertCompressedLevels3DToFile(); void convertCompressedLevels1DToFileThroughData(); void convertCompressedLevels2DToFileThroughData(); void convertCompressedLevels3DToFileThroughData(); void convertCompressedLevels1DToFileThroughDataFailed(); void convertCompressedLevels2DToFileThroughDataFailed(); void convertCompressedLevels3DToFileThroughDataFailed(); void convertCompressedLevels1DToFileThroughDataNotWritable(); void convertCompressedLevels2DToFileThroughDataNotWritable(); void convertCompressedLevels3DToFileThroughDataNotWritable(); /* ToFile share the same check function with ToData, so only verify it's used */ void convertCompressedLevels1DToFileInvalidImage(); void convertCompressedLevels2DToFileInvalidImage(); void convertCompressedLevels3DToFileInvalidImage(); void convertCompressedLevels1DToFileNotImplemented(); void convertCompressedLevels2DToFileNotImplemented(); void convertCompressedLevels3DToFileNotImplemented(); void convert1DToFileThroughLevels(); void convert2DToFileThroughLevels(); void convert3DToFileThroughLevels(); void convertCompressed1DToFileThroughLevels(); void convertCompressed2DToFileThroughLevels(); void convertCompressed3DToFileThroughLevels(); void debugFeature(); void debugFeatures(); void debugFeaturesSupersets(); void debugFlag(); void debugFlags(); }; AbstractImageConverterTest::AbstractImageConverterTest() { addTests({&AbstractImageConverterTest::construct, &AbstractImageConverterTest::constructWithPluginManagerReference, &AbstractImageConverterTest::setFlags, &AbstractImageConverterTest::setFlagsNotImplemented, &AbstractImageConverterTest::thingNotSupported, &AbstractImageConverterTest::convert1D, &AbstractImageConverterTest::convert2D, &AbstractImageConverterTest::convert3D, &AbstractImageConverterTest::convert1DNotImplemented, &AbstractImageConverterTest::convert2DNotImplemented, &AbstractImageConverterTest::convert3DNotImplemented, &AbstractImageConverterTest::convert1DCustomDeleter, &AbstractImageConverterTest::convert2DCustomDeleter, &AbstractImageConverterTest::convert3DCustomDeleter, &AbstractImageConverterTest::convertCompressed1D, &AbstractImageConverterTest::convertCompressed2D, &AbstractImageConverterTest::convertCompressed3D, &AbstractImageConverterTest::convertCompressed1DNotImplemented, &AbstractImageConverterTest::convertCompressed2DNotImplemented, &AbstractImageConverterTest::convertCompressed3DNotImplemented, &AbstractImageConverterTest::convertCompressed1DCustomDeleter, &AbstractImageConverterTest::convertCompressed2DCustomDeleter, &AbstractImageConverterTest::convertCompressed3DCustomDeleter, &AbstractImageConverterTest::convertImageData1D, &AbstractImageConverterTest::convertImageData2D, &AbstractImageConverterTest::convertImageData3D, &AbstractImageConverterTest::convert1DToData, &AbstractImageConverterTest::convert2DToData, &AbstractImageConverterTest::convert3DToData, &AbstractImageConverterTest::convert1DToDataInvalidImage, &AbstractImageConverterTest::convert2DToDataZeroSize, &AbstractImageConverterTest::convert2DToDataNullptr, &AbstractImageConverterTest::convert3DToDataInvalidImage, &AbstractImageConverterTest::convert1DToDataNotImplemented, &AbstractImageConverterTest::convert2DToDataNotImplemented, &AbstractImageConverterTest::convert3DToDataNotImplemented, &AbstractImageConverterTest::convert1DToDataCustomDeleter, &AbstractImageConverterTest::convert2DToDataCustomDeleter, &AbstractImageConverterTest::convert3DToDataCustomDeleter, &AbstractImageConverterTest::convertCompressed1DToData, &AbstractImageConverterTest::convertCompressed2DToData, &AbstractImageConverterTest::convertCompressed3DToData, &AbstractImageConverterTest::convertCompressed1DToDataInvalidImage, &AbstractImageConverterTest::convertCompressed2DToDataInvalidImage, &AbstractImageConverterTest::convertCompressed3DToDataInvalidImage, &AbstractImageConverterTest::convertCompressed1DToDataNotImplemented, &AbstractImageConverterTest::convertCompressed2DToDataNotImplemented, &AbstractImageConverterTest::convertCompressed3DToDataNotImplemented, &AbstractImageConverterTest::convertCompressed1DToDataCustomDeleter, &AbstractImageConverterTest::convertCompressed2DToDataCustomDeleter, &AbstractImageConverterTest::convertCompressed3DToDataCustomDeleter, &AbstractImageConverterTest::convertImageData1DToData, &AbstractImageConverterTest::convertImageData2DToData, &AbstractImageConverterTest::convertImageData3DToData, &AbstractImageConverterTest::convertLevels1DToData, &AbstractImageConverterTest::convertLevels2DToData, &AbstractImageConverterTest::convertLevels3DToData, &AbstractImageConverterTest::convertLevels1DToDataInvalidImage, &AbstractImageConverterTest::convertLevels2DToDataNoLevels, &AbstractImageConverterTest::convertLevels2DToDataZeroSize, &AbstractImageConverterTest::convertLevels2DToDataNullptr, &AbstractImageConverterTest::convertLevels2DToDataInconsistentFormat, &AbstractImageConverterTest::convertLevels2DToDataInconsistentFormatExtra, &AbstractImageConverterTest::convertLevels3DToDataInvalidImage, &AbstractImageConverterTest::convertLevels1DToDataNotImplemented, &AbstractImageConverterTest::convertLevels2DToDataNotImplemented, &AbstractImageConverterTest::convertLevels3DToDataNotImplemented, &AbstractImageConverterTest::convertLevels1DToDataCustomDeleter, &AbstractImageConverterTest::convertLevels2DToDataCustomDeleter, &AbstractImageConverterTest::convertLevels3DToDataCustomDeleter, &AbstractImageConverterTest::convertCompressedLevels1DToData, &AbstractImageConverterTest::convertCompressedLevels2DToData, &AbstractImageConverterTest::convertCompressedLevels3DToData, &AbstractImageConverterTest::convertCompressedLevels1DToDataInvalidImage, &AbstractImageConverterTest::convertCompressedLevels2DToDataNoLevels, &AbstractImageConverterTest::convertCompressedLevels2DToDataZeroSize, &AbstractImageConverterTest::convertCompressedLevels2DToDataNullptr, &AbstractImageConverterTest::convertCompressedLevels2DToDataInconsistentFormat, &AbstractImageConverterTest::convertCompressedLevels3DToDataInvalidImage, &AbstractImageConverterTest::convertCompressedLevels1DToDataNotImplemented, &AbstractImageConverterTest::convertCompressedLevels2DToDataNotImplemented, &AbstractImageConverterTest::convertCompressedLevels3DToDataNotImplemented, &AbstractImageConverterTest::convertCompressedLevels1DToDataCustomDeleter, &AbstractImageConverterTest::convertCompressedLevels2DToDataCustomDeleter, &AbstractImageConverterTest::convertCompressedLevels3DToDataCustomDeleter, &AbstractImageConverterTest::convert1DToDataThroughLevels, &AbstractImageConverterTest::convert2DToDataThroughLevels, &AbstractImageConverterTest::convert3DToDataThroughLevels, &AbstractImageConverterTest::convertCompressed1DToDataThroughLevels, &AbstractImageConverterTest::convertCompressed2DToDataThroughLevels, &AbstractImageConverterTest::convertCompressed3DToDataThroughLevels, &AbstractImageConverterTest::convert1DToFile, &AbstractImageConverterTest::convert2DToFile, &AbstractImageConverterTest::convert3DToFile, &AbstractImageConverterTest::convert1DToFileThroughData, &AbstractImageConverterTest::convert2DToFileThroughData, &AbstractImageConverterTest::convert3DToFileThroughData, &AbstractImageConverterTest::convert1DToFileThroughDataFailed, &AbstractImageConverterTest::convert2DToFileThroughDataFailed, &AbstractImageConverterTest::convert3DToFileThroughDataFailed, &AbstractImageConverterTest::convert1DToFileThroughDataNotWritable, &AbstractImageConverterTest::convert2DToFileThroughDataNotWritable, &AbstractImageConverterTest::convert3DToFileThroughDataNotWritable, &AbstractImageConverterTest::convert1DToFileInvalidImage, &AbstractImageConverterTest::convert2DToFileInvalidImage, &AbstractImageConverterTest::convert3DToFileInvalidImage, &AbstractImageConverterTest::convert1DToFileNotImplemented, &AbstractImageConverterTest::convert2DToFileNotImplemented, &AbstractImageConverterTest::convert3DToFileNotImplemented, &AbstractImageConverterTest::convertCompressed1DToFile, &AbstractImageConverterTest::convertCompressed2DToFile, &AbstractImageConverterTest::convertCompressed3DToFile, &AbstractImageConverterTest::convertCompressed1DToFileThroughData, &AbstractImageConverterTest::convertCompressed2DToFileThroughData, &AbstractImageConverterTest::convertCompressed3DToFileThroughData, &AbstractImageConverterTest::convertCompressed1DToFileThroughDataFailed, &AbstractImageConverterTest::convertCompressed2DToFileThroughDataFailed, &AbstractImageConverterTest::convertCompressed3DToFileThroughDataFailed, &AbstractImageConverterTest::convertCompressed1DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertCompressed2DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertCompressed3DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertCompressed1DToFileInvalidImage, &AbstractImageConverterTest::convertCompressed2DToFileInvalidImage, &AbstractImageConverterTest::convertCompressed3DToFileInvalidImage, &AbstractImageConverterTest::convertCompressed1DToFileNotImplemented, &AbstractImageConverterTest::convertCompressed2DToFileNotImplemented, &AbstractImageConverterTest::convertCompressed3DToFileNotImplemented, &AbstractImageConverterTest::convertImageData1DToFile, &AbstractImageConverterTest::convertImageData2DToFile, &AbstractImageConverterTest::convertImageData3DToFile, &AbstractImageConverterTest::convertLevels1DToFile, &AbstractImageConverterTest::convertLevels2DToFile, &AbstractImageConverterTest::convertLevels3DToFile, &AbstractImageConverterTest::convertLevels1DToFileThroughData, &AbstractImageConverterTest::convertLevels2DToFileThroughData, &AbstractImageConverterTest::convertLevels3DToFileThroughData, &AbstractImageConverterTest::convertLevels1DToFileThroughDataFailed, &AbstractImageConverterTest::convertLevels2DToFileThroughDataFailed, &AbstractImageConverterTest::convertLevels3DToFileThroughDataFailed, &AbstractImageConverterTest::convertLevels1DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertLevels2DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertLevels3DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertLevels1DToFileInvalidImage, &AbstractImageConverterTest::convertLevels2DToFileInvalidImage, &AbstractImageConverterTest::convertLevels3DToFileInvalidImage, &AbstractImageConverterTest::convertLevels1DToFileNotImplemented, &AbstractImageConverterTest::convertLevels2DToFileNotImplemented, &AbstractImageConverterTest::convertLevels3DToFileNotImplemented, &AbstractImageConverterTest::convertCompressedLevels1DToFile, &AbstractImageConverterTest::convertCompressedLevels2DToFile, &AbstractImageConverterTest::convertCompressedLevels3DToFile, &AbstractImageConverterTest::convertCompressedLevels1DToFileThroughData, &AbstractImageConverterTest::convertCompressedLevels2DToFileThroughData, &AbstractImageConverterTest::convertCompressedLevels3DToFileThroughData, &AbstractImageConverterTest::convertCompressedLevels1DToFileThroughDataFailed, &AbstractImageConverterTest::convertCompressedLevels2DToFileThroughDataFailed, &AbstractImageConverterTest::convertCompressedLevels3DToFileThroughDataFailed, &AbstractImageConverterTest::convertCompressedLevels1DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertCompressedLevels2DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertCompressedLevels3DToFileThroughDataNotWritable, &AbstractImageConverterTest::convertCompressedLevels1DToFileInvalidImage, &AbstractImageConverterTest::convertCompressedLevels2DToFileInvalidImage, &AbstractImageConverterTest::convertCompressedLevels3DToFileInvalidImage, &AbstractImageConverterTest::convertCompressedLevels1DToFileNotImplemented, &AbstractImageConverterTest::convertCompressedLevels2DToFileNotImplemented, &AbstractImageConverterTest::convertCompressedLevels3DToFileNotImplemented, &AbstractImageConverterTest::convert1DToFileThroughLevels, &AbstractImageConverterTest::convert2DToFileThroughLevels, &AbstractImageConverterTest::convert3DToFileThroughLevels, &AbstractImageConverterTest::convertCompressed1DToFileThroughLevels, &AbstractImageConverterTest::convertCompressed2DToFileThroughLevels, &AbstractImageConverterTest::convertCompressed3DToFileThroughLevels, &AbstractImageConverterTest::debugFeature, &AbstractImageConverterTest::debugFeatures, &AbstractImageConverterTest::debugFeaturesSupersets, &AbstractImageConverterTest::debugFlag, &AbstractImageConverterTest::debugFlags}); /* Create testing dir */ Utility::Path::make(TRADE_TEST_OUTPUT_DIR); } void AbstractImageConverterTest::construct() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return {}; } } converter; CORRADE_COMPARE(converter.features(), ImageConverterFeatures{}); } void AbstractImageConverterTest::constructWithPluginManagerReference() { PluginManager::Manager manager; struct Converter: AbstractImageConverter { explicit Converter(PluginManager::Manager& manager): AbstractImageConverter{manager} {} ImageConverterFeatures doFeatures() const override { return {}; } } converter{manager}; CORRADE_COMPARE(converter.features(), ImageConverterFeatures{}); } void AbstractImageConverterTest::setFlags() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return {}; } void doSetFlags(ImageConverterFlags flags) override { _flags = flags; } ImageConverterFlags _flags; } converter; CORRADE_COMPARE(converter.flags(), ImageConverterFlags{}); CORRADE_COMPARE(converter._flags, ImageConverterFlags{}); converter.setFlags(ImageConverterFlag::Verbose); CORRADE_COMPARE(converter.flags(), ImageConverterFlag::Verbose); CORRADE_COMPARE(converter._flags, ImageConverterFlag::Verbose); /** @todo use a real flag when we have more than one */ converter.addFlags(ImageConverterFlag(4)); CORRADE_COMPARE(converter.flags(), ImageConverterFlag::Verbose|ImageConverterFlag(4)); CORRADE_COMPARE(converter._flags, ImageConverterFlag::Verbose|ImageConverterFlag(4)); converter.clearFlags(ImageConverterFlag::Verbose); CORRADE_COMPARE(converter.flags(), ImageConverterFlag(4)); CORRADE_COMPARE(converter._flags, ImageConverterFlag(4)); } void AbstractImageConverterTest::setFlagsNotImplemented() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return {}; } } converter; CORRADE_COMPARE(converter.flags(), ImageConverterFlags{}); converter.setFlags(ImageConverterFlag::Verbose); CORRADE_COMPARE(converter.flags(), ImageConverterFlag::Verbose); /* Should just work, no need to implement the function */ } void AbstractImageConverterTest::thingNotSupported() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return {}; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(ImageView1D{PixelFormat::R8Unorm, 0, nullptr}); converter.convert(ImageView2D{PixelFormat::R8Unorm, {}, nullptr}); converter.convert(ImageView3D{PixelFormat::R8Unorm, {}, nullptr}); converter.convert(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}); converter.convert(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); converter.convert(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); converter.convertToData(ImageView1D{PixelFormat::RGBA8Unorm, 0, nullptr}); converter.convertToData(ImageView2D{PixelFormat::RGBA8Unorm, {}, nullptr}); converter.convertToData(ImageView3D{PixelFormat::RGBA8Unorm, {}, nullptr}); converter.convertToData({ImageView1D{PixelFormat::RGBA8Unorm, 0, nullptr}}); converter.convertToData({ImageView2D{PixelFormat::RGBA8Unorm, {}, nullptr}}); converter.convertToData({ImageView3D{PixelFormat::RGBA8Unorm, {}, nullptr}}); converter.convertToData(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}); converter.convertToData(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); converter.convertToData(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); converter.convertToData({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}}); converter.convertToData({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}}); converter.convertToData({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}}); converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 0, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile({ImageView1D{PixelFormat::RGBA8Unorm, 0, nullptr}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile({ImageView2D{PixelFormat::RGBA8Unorm, {}, nullptr}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile({ImageView3D{PixelFormat::RGBA8Unorm, {}, nullptr}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); converter.convertToFile({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): 1D image conversion not supported\n" "Trade::AbstractImageConverter::convert(): 2D image conversion not supported\n" "Trade::AbstractImageConverter::convert(): 3D image conversion not supported\n" "Trade::AbstractImageConverter::convert(): compressed 1D image conversion not supported\n" "Trade::AbstractImageConverter::convert(): compressed 2D image conversion not supported\n" "Trade::AbstractImageConverter::convert(): compressed 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): multi-level 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): multi-level 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): multi-level 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): compressed 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): compressed 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): compressed 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): multi-level compressed 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): multi-level compressed 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToData(): multi-level compressed 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): multi-level 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): multi-level 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): multi-level 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): compressed 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): compressed 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): compressed 3D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): multi-level compressed 1D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): multi-level compressed 2D image conversion not supported\n" "Trade::AbstractImageConverter::convertToFile(): multi-level compressed 3D image conversion not supported\n"); } void AbstractImageConverterTest::convert1D() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1D; } Containers::Optional doConvert(const ImageView1D& image) override { return ImageData1D{PixelFormat::RGBA8Unorm, image.size(), Containers::Array{16}}; } } converter; Containers::Optional actual = converter.convert(ImageView1D{PixelFormat::R8Unorm, 4, Containers::ArrayView{nullptr, 24}}); CORRADE_VERIFY(actual); CORRADE_VERIFY(!actual->isCompressed()); CORRADE_COMPARE(actual->data().size(), 16); CORRADE_COMPARE(actual->size(), 4); } void AbstractImageConverterTest::convert2D() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2D; } Containers::Optional doConvert(const ImageView2D& image) override { return ImageData2D{PixelFormat::RGBA8Unorm, image.size(), Containers::Array{96}}; } } converter; Containers::Optional actual = converter.convert(ImageView2D{PixelFormat::R8Unorm, {4, 6}, Containers::ArrayView{nullptr, 24}}); CORRADE_VERIFY(actual); CORRADE_VERIFY(!actual->isCompressed()); CORRADE_COMPARE(actual->data().size(), 96); CORRADE_COMPARE(actual->size(), (Vector2i{4, 6})); } void AbstractImageConverterTest::convert3D() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3D; } Containers::Optional doConvert(const ImageView3D& image) override { return ImageData3D{PixelFormat::RGBA8Unorm, image.size(), Containers::Array{96}}; } } converter; Containers::Optional actual = converter.convert(ImageView3D{PixelFormat::R8Unorm, {4, 6, 1}, Containers::ArrayView{nullptr, 24}}); CORRADE_VERIFY(actual); CORRADE_VERIFY(!actual->isCompressed()); CORRADE_COMPARE(actual->data().size(), 96); CORRADE_COMPARE(actual->size(), (Vector3i{4, 6, 1})); } void AbstractImageConverterTest::convert1DNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1D; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(ImageView1D{PixelFormat::R8Unorm, 0, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert2DNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2D; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(ImageView2D{PixelFormat::R8Unorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert3DNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3D; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(ImageView3D{PixelFormat::R8Unorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert1DCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1D; } Containers::Optional doConvert(const ImageView1D&) override { return ImageData1D{PixelFormat::RGBA8Unorm, {}, Containers::Array{nullptr, 0, [](char*, std::size_t) {}}}; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(ImageView1D{PixelFormat::R8Unorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convert2DCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2D; } Containers::Optional doConvert(const ImageView2D&) override { return ImageData2D{PixelFormat::RGBA8Unorm, {}, Containers::Array{nullptr, 0, [](char*, std::size_t) {}}}; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(ImageView2D{PixelFormat::R8Unorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convert3DCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3D; } Containers::Optional doConvert(const ImageView3D&) override { return ImageData3D{PixelFormat::RGBA8Unorm, {}, Containers::Array{nullptr, 0, [](char*, std::size_t) {}}}; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(ImageView3D{PixelFormat::R8Unorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressed1D() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1D; } Containers::Optional doConvert(const CompressedImageView1D& image) override { return ImageData1D{image.format(), image.size(), Containers::Array{64}}; } } converter; Containers::Optional actual = converter.convert(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 16, Containers::ArrayView{nullptr, 128}}); CORRADE_VERIFY(actual); CORRADE_VERIFY(actual->isCompressed()); CORRADE_COMPARE(actual->data().size(), 64); CORRADE_COMPARE(actual->size(), 16); } void AbstractImageConverterTest::convertCompressed2D() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2D; } Containers::Optional doConvert(const CompressedImageView2D& image) override { return ImageData2D{image.format(), image.size(), Containers::Array{64}}; } } converter; Containers::Optional actual = converter.convert(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8}, Containers::ArrayView{nullptr, 128}}); CORRADE_VERIFY(actual); CORRADE_VERIFY(actual->isCompressed()); CORRADE_COMPARE(actual->data().size(), 64); CORRADE_COMPARE(actual->size(), (Vector2i{16, 8})); } void AbstractImageConverterTest::convertCompressed3D() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3D; } Containers::Optional doConvert(const CompressedImageView3D& image) override { return ImageData3D{image.format(), image.size(), Containers::Array{64}}; } } converter; Containers::Optional actual = converter.convert(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8, 1}, Containers::ArrayView{nullptr, 128}}); CORRADE_VERIFY(actual); CORRADE_VERIFY(actual->isCompressed()); CORRADE_COMPARE(actual->data().size(), 64); CORRADE_COMPARE(actual->size(), (Vector3i{16, 8, 1})); } void AbstractImageConverterTest::convertCompressed1DNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1D; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): compressed 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed2DNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2D; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): compressed 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed3DNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3D; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): compressed 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed1DCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1D; } Containers::Optional doConvert(const CompressedImageView1D&) override { return ImageData1D{CompressedPixelFormat::Bc1RGBAUnorm, {}, Containers::Array{nullptr, 0, [](char*, std::size_t) {}}}; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressed2DCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2D; } Containers::Optional doConvert(const CompressedImageView2D&) override { return ImageData2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, Containers::Array{nullptr, 0, [](char*, std::size_t) {}}}; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressed3DCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3D; } Containers::Optional doConvert(const CompressedImageView3D&) override { return ImageData3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, Containers::Array{nullptr, 0, [](char*, std::size_t) {}}}; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convert(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convert(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertImageData1D() { struct: Trade::AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1D|ImageConverterFeature::ConvertCompressed1D; } Containers::Optional doConvert(const ImageView1D&) override { return ImageData1D{PixelFormat::R8Unorm, {}, Containers::array({'B'})}; }; Containers::Optional doConvert(const CompressedImageView1D&) override { return ImageData1D{PixelFormat::R8Unorm, {}, Containers::array({'C'})}; }; } converter; { /* Should get "B" when converting uncompressed */ ImageData1D image{PixelFormat::RGBA8Unorm, {}, nullptr}; Containers::Optional out = converter.convert(image); CORRADE_VERIFY(out); CORRADE_COMPARE_AS(out->data(), Containers::arrayView({'B'}), TestSuite::Compare::Container); } { /* Should get "C" when converting compressed */ ImageData1D image{CompressedPixelFormat::Bc1RGBUnorm, {}, nullptr}; Containers::Optional out = converter.convert(image); CORRADE_VERIFY(out); CORRADE_COMPARE_AS(out->data(), Containers::arrayView({'C'}), TestSuite::Compare::Container); } } void AbstractImageConverterTest::convertImageData2D() { struct: Trade::AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2D|ImageConverterFeature::ConvertCompressed2D; } Containers::Optional doConvert(const ImageView2D&) override { return ImageData2D{PixelFormat::R8Unorm, {}, Containers::array({'B'})}; }; Containers::Optional doConvert(const CompressedImageView2D&) override { return ImageData2D{PixelFormat::R8Unorm, {}, Containers::array({'C'})}; }; } converter; { /* Should get "B" when converting uncompressed */ ImageData2D image{PixelFormat::RGBA8Unorm, {}, nullptr}; Containers::Optional out = converter.convert(image); CORRADE_VERIFY(out); CORRADE_COMPARE_AS(out->data(), Containers::arrayView({'B'}), TestSuite::Compare::Container); } { /* Should get "C" when converting compressed */ ImageData2D image{CompressedPixelFormat::Bc1RGBUnorm, {}, nullptr}; Containers::Optional out = converter.convert(image); CORRADE_VERIFY(out); CORRADE_COMPARE_AS(out->data(), Containers::arrayView({'C'}), TestSuite::Compare::Container); } } void AbstractImageConverterTest::convertImageData3D() { struct: Trade::AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3D|ImageConverterFeature::ConvertCompressed3D; } Containers::Optional doConvert(const ImageView3D&) override { return ImageData3D{PixelFormat::R8Unorm, {}, Containers::array({'B'})}; }; Containers::Optional doConvert(const CompressedImageView3D&) override { return ImageData3D{PixelFormat::R8Unorm, {}, Containers::array({'C'})}; }; } converter; { /* Should get "B" when converting uncompressed */ ImageData3D image{PixelFormat::RGBA8Unorm, {}, nullptr}; Containers::Optional out = converter.convert(image); CORRADE_VERIFY(out); CORRADE_COMPARE_AS(out->data(), Containers::arrayView({'B'}), TestSuite::Compare::Container); } { /* Should get "C" when converting compressed */ ImageData3D image{CompressedPixelFormat::Bc1RGBUnorm, {}, nullptr}; Containers::Optional out = converter.convert(image); CORRADE_VERIFY(out); CORRADE_COMPARE_AS(out->data(), Containers::arrayView({'C'}), TestSuite::Compare::Container); } } void AbstractImageConverterTest::convert1DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData; } Containers::Array doConvertToData(const ImageView1D& image) override { return Containers::Array{nullptr, std::size_t(image.size().product())}; } } converter; const char data[16]{}; Containers::Array actual = converter.convertToData(ImageView1D{PixelFormat::RGBA8Unorm, 4, data}); CORRADE_COMPARE(actual.size(), 4); } void AbstractImageConverterTest::convert2DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } Containers::Array doConvertToData(const ImageView2D& image) override { return Containers::Array{nullptr, std::size_t(image.size().product())}; } } converter; const char data[96]{}; Containers::Array actual = converter.convertToData(ImageView2D{PixelFormat::RGBA8Unorm, {4, 6}, data}); CORRADE_COMPARE(actual.size(), 24); } void AbstractImageConverterTest::convert3DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData; } Containers::Array doConvertToData(const ImageView3D& image) override { return Containers::Array{nullptr, std::size_t(image.size().product())}; } } converter; const char data[192]{}; Containers::Array actual = converter.convertToData(ImageView3D{PixelFormat::RGBA8Unorm, {4, 6, 2}, data}); CORRADE_COMPARE(actual.size(), 48); } void AbstractImageConverterTest::convert1DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView1D{PixelFormat::RGBA8Unorm, 0, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image with a zero size: Vector(0)\n"); } void AbstractImageConverterTest::convert2DToDataZeroSize() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView2D{PixelFormat::RGBA8Unorm, {4, 0}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image with a zero size: Vector(4, 0)\n"); } void AbstractImageConverterTest::convert2DToDataNullptr() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, {nullptr, 4}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image with a nullptr view\n"); } void AbstractImageConverterTest::convert3DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView3D{PixelFormat::RGBA8Unorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image with a zero size: Vector(0, 0, 0)\n"); } void AbstractImageConverterTest::convert1DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView1D{PixelFormat::RGBA8Unorm, 1, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert2DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert3DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert1DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData; } Containers::Array doConvertToData(const ImageView1D&) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView1D{PixelFormat::RGBA8Unorm, 1, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convert2DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } Containers::Array doConvertToData(const ImageView2D&) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convert3DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData; } Containers::Array doConvertToData(const ImageView3D&) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressed1DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToData; } Containers::Array doConvertToData(const CompressedImageView1D& image) override { return Containers::Array{nullptr, std::size_t(image.size().product())}; } } converter; const char data[32]{}; Containers::Array actual = converter.convertToData(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 16, data}); CORRADE_COMPARE(actual.size(), 16); } void AbstractImageConverterTest::convertCompressed2DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToData; } Containers::Array doConvertToData(const CompressedImageView2D& image) override { return Containers::Array{nullptr, std::size_t(image.size().product())}; } } converter; const char data[64]{}; Containers::Array actual = converter.convertToData(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8}, data}); CORRADE_COMPARE(actual.size(), 128); } void AbstractImageConverterTest::convertCompressed3DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToData; } Containers::Array doConvertToData(const CompressedImageView3D& image) override { return Containers::Array{nullptr, std::size_t(image.size().product())}; } } converter; const char data[128]{}; Containers::Array actual = converter.convertToData(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8, 2}, data}); CORRADE_COMPARE(actual.size(), 256); } void AbstractImageConverterTest::convertCompressed1DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image with a zero size: Vector(0)\n"); } void AbstractImageConverterTest::convertCompressed2DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image with a zero size: Vector(0, 0)\n"); } void AbstractImageConverterTest::convertCompressed3DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image with a zero size: Vector(0, 0, 0)\n"); } void AbstractImageConverterTest::convertCompressed1DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToData; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): compressed 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed2DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToData; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): compressed 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed3DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToData; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): compressed 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed1DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToData; } Containers::Array doConvertToData(const CompressedImageView1D&) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressed2DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToData; } Containers::Array doConvertToData(const CompressedImageView2D&) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressed3DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToData; } Containers::Array doConvertToData(const CompressedImageView3D&) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } /* Used by convertImageDataToData() and convertImageDataToFile() */ class ImageData1DConverter: public Trade::AbstractImageConverter { private: ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData|ImageConverterFeature::ConvertCompressed1DToData; } Containers::Array doConvertToData(const ImageView1D&) override { return Containers::array({'B'}); }; Containers::Array doConvertToData(const CompressedImageView1D&) override { return Containers::array({'C'}); }; }; class ImageData2DConverter: public Trade::AbstractImageConverter { private: ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData|ImageConverterFeature::ConvertCompressed2DToData; } Containers::Array doConvertToData(const ImageView2D&) override { return Containers::array({'B'}); }; Containers::Array doConvertToData(const CompressedImageView2D&) override { return Containers::array({'C'}); }; }; class ImageData3DConverter: public Trade::AbstractImageConverter { private: ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData|ImageConverterFeature::ConvertCompressed3DToData; } Containers::Array doConvertToData(const ImageView3D&) override { return Containers::array({'B'}); }; Containers::Array doConvertToData(const CompressedImageView3D&) override { return Containers::array({'C'}); }; }; void AbstractImageConverterTest::convertImageData1DToData() { ImageData1DConverter converter; /* Should get "B" when converting uncompressed */ CORRADE_COMPARE_AS(converter.convertToData(ImageData1D{PixelFormat::RGBA8Unorm, 1, Containers::Array{4}}), Containers::arrayView({'B'}), TestSuite::Compare::Container); /* Should get "C" when converting compressed */ CORRADE_COMPARE_AS(converter.convertToData(ImageData1D{CompressedPixelFormat::Bc1RGBUnorm, 4, Containers::Array{8}}), Containers::arrayView({'C'}), TestSuite::Compare::Container); } void AbstractImageConverterTest::convertImageData2DToData() { ImageData2DConverter converter; /* Should get "B" when converting uncompressed */ CORRADE_COMPARE_AS(converter.convertToData(ImageData2D{PixelFormat::RGBA8Unorm, {1, 1}, Containers::Array{4}}), Containers::arrayView({'B'}), TestSuite::Compare::Container); /* Should get "C" when converting compressed */ CORRADE_COMPARE_AS(converter.convertToData(ImageData2D{CompressedPixelFormat::Bc1RGBUnorm, {4, 4}, Containers::Array{4}}), Containers::arrayView({'C'}), TestSuite::Compare::Container); } void AbstractImageConverterTest::convertImageData3DToData() { ImageData3DConverter converter; /* Should get "B" when converting uncompressed */ CORRADE_COMPARE_AS(converter.convertToData(ImageData3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, Containers::Array{4}}), Containers::arrayView({'B'}), TestSuite::Compare::Container); /* Should get "C" when converting compressed */ CORRADE_COMPARE_AS(converter.convertToData(ImageData3D{CompressedPixelFormat::Bc1RGBUnorm, {4, 4, 1}, Containers::Array{4}}), Containers::arrayView({'C'}), TestSuite::Compare::Container); } void AbstractImageConverterTest::convertLevels1DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[96]{}; Containers::Array actual = converter.convertToData({ /* Arbitrary dimensions should be fine */ ImageView1D{PixelFormat::RGBA8Unorm, 4, data}, ImageView1D{PixelFormat::RGBA8Unorm, 2, data}, ImageView1D{PixelFormat::RGBA8Unorm, 3, data}, }); CORRADE_COMPARE(actual.size(), 4*3); } void AbstractImageConverterTest::convertLevels2DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[96]{}; Containers::Array actual = converter.convertToData({ /* Arbitrary dimensions should be fine */ ImageView2D{PixelFormat::RGBA8Unorm, {4, 6}, data}, ImageView2D{PixelFormat::RGBA8Unorm, {1, 3}, data}, ImageView2D{PixelFormat::RGBA8Unorm, {4, 2}, data} }); CORRADE_COMPARE(actual.size(), 24*3); } void AbstractImageConverterTest::convertLevels3DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[192]{}; Containers::Array actual = converter.convertToData({ /* Arbitrary dimensions should be fine */ ImageView3D{PixelFormat::RGBA8Unorm, {4, 6, 2}, data}, ImageView3D{PixelFormat::RGBA8Unorm, {2, 3, 5}, data}, ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data} }); CORRADE_COMPARE(actual.size(), 48*3); } void AbstractImageConverterTest::convertLevels1DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(std::initializer_list{}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertLevels2DToDataNoLevels() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(std::initializer_list{}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertLevels2DToDataZeroSize() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ ImageView2D{PixelFormat::RGBA8Unorm, {2, 2}, data}, ImageView2D{PixelFormat::RGBA8Unorm, {4, 0}, data} }); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image 1 with a zero size: Vector(4, 0)\n"); } void AbstractImageConverterTest::convertLevels2DToDataNullptr() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ ImageView2D{PixelFormat::RGBA8Unorm, {2, 2}, data}, ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, {nullptr, 4}} }); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image 1 with a nullptr view\n"); } void AbstractImageConverterTest::convertLevels2DToDataInconsistentFormat() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ ImageView2D{PixelFormat::RGBA8Unorm, {2, 2}, data}, ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}, ImageView2D{PixelFormat::RGBA8Srgb, {4, 1}, data} }); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): levels don't have the same format, expected PixelFormat::RGBA8Unorm but got PixelFormat::RGBA8Srgb for image 2\n"); } void AbstractImageConverterTest::convertLevels2DToDataInconsistentFormatExtra() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ ImageView2D{PixelStorage{}, 252, 1037, 4, {2, 2}, data}, ImageView2D{PixelStorage{}, 252, 1037, 4, {1, 1}, data}, ImageView2D{PixelStorage{}, 252, 4467, 4, {4, 1}, data} }); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): levels don't have the same extra format field, expected 1037 but got 4467 for image 2\n"); } void AbstractImageConverterTest::convertLevels3DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(std::initializer_list{}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertLevels1DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ImageView1D{PixelFormat::RGBA8Unorm, 1, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): multi-level 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertLevels2DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): multi-level 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertLevels3DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): multi-level 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertLevels1DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ImageView1D{PixelFormat::RGBA8Unorm, 1, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertLevels2DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertLevels3DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressedLevels1DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[32]{}; Containers::Array actual = converter.convertToData({ /* Arbitrary dimensions should be fine */ CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 16, data}, CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}, CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 12, data} }); CORRADE_COMPARE(actual.size(), 16*3); } void AbstractImageConverterTest::convertCompressedLevels2DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[64]{}; Containers::Array actual = converter.convertToData({ /* Arbitrary dimensions should be fine */ CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8}, data}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 12}, data}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data} }); CORRADE_COMPARE(actual.size(), 128*3); } void AbstractImageConverterTest::convertCompressedLevels3DToData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[128]{}; Containers::Array actual = converter.convertToData({ /* Arbitrary dimensions should be fine */ CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8, 2}, data}, CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 16, 1}, data}, CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 4, 1}, data} }); CORRADE_COMPARE(actual.size(), 256*3); } void AbstractImageConverterTest::convertCompressedLevels1DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(std::initializer_list{}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToDataNoLevels() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(std::initializer_list{}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToDataZeroSize() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 8}, data}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 0}, data}, }); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image 1 with a zero size: Vector(4, 0)\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToDataNullptr() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 8}, data}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {1, 1}, {nullptr, 8}}, }); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): can't convert image 1 with a nullptr view\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToDataInconsistentFormat() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } } converter; const char data[16]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({ CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {8, 4}, data}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBASrgb, {4, 4}, data}, }); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): levels don't have the same format, expected CompressedPixelFormat::Bc1RGBAUnorm but got CompressedPixelFormat::Bc1RGBASrgb for image 2\n"); } void AbstractImageConverterTest::convertCompressedLevels3DToDataInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToData(std::initializer_list{}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertCompressedLevels1DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): multi-level compressed 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): multi-level compressed 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressedLevels3DToDataNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): multi-level compressed 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressedLevels1DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convertCompressedLevels3DToDataCustomDeleter() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::Array{nullptr, 0, [](char*, std::size_t) {}}; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToData({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}}); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToData(): implementation is not allowed to use a custom Array deleter\n"); } void AbstractImageConverterTest::convert1DToDataThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[16]{}; Containers::Array actual = converter.convertToData(ImageView1D{PixelFormat::RGBA8Unorm, 4, data}); CORRADE_COMPARE(actual.size(), 4); } void AbstractImageConverterTest::convert2DToDataThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[96]{}; Containers::Array actual = converter.convertToData(ImageView2D{PixelFormat::RGBA8Unorm, {4, 6}, data}); CORRADE_COMPARE(actual.size(), 24); } void AbstractImageConverterTest::convert3DToDataThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[192]{}; Containers::Array actual = converter.convertToData(ImageView3D{PixelFormat::RGBA8Unorm, {4, 6, 2}, data}); CORRADE_COMPARE(actual.size(), 48); } void AbstractImageConverterTest::convertCompressed1DToDataThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[32]{}; Containers::Array actual = converter.convertToData(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 16, data}); CORRADE_COMPARE(actual.size(), 16); } void AbstractImageConverterTest::convertCompressed2DToDataThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[64]{}; Containers::Array actual = converter.convertToData(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8}, data}); CORRADE_COMPARE(actual.size(), 128); } void AbstractImageConverterTest::convertCompressed3DToDataThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::Array{nullptr, std::size_t(imageLevels[0].size().product()*imageLevels.size())}; } } converter; const char data[128]{}; Containers::Array actual = converter.convertToData(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {16, 8, 2}, data}); CORRADE_COMPARE(actual.size(), 256); } void AbstractImageConverterTest::convert1DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToFile; } bool doConvertToFile(const ImageView1D& image, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(image.size()[0])})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 0x0f, Containers::Array{0x0f*4}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert2DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToFile; } bool doConvertToFile(const ImageView2D& image, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(image.size().x()), char(image.size().y())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {0x0f, 0x0d}, Containers::Array{0x0f*0x0d*4}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert3DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToFile; } bool doConvertToFile(const ImageView3D& image, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(image.size().x()), char(image.size().y()), char(image.size().z())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {0x0f, 0x0d, 0x02}, Containers::Array{0x0f*0x0d*0x02*4}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert1DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData; } Containers::Array doConvertToData(const ImageView1D& image) override { return Containers::array({char(image.size()[0])}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile(ImageView1D(PixelFormat::RGBA8Unorm, 0x0f, Containers::Array{0x0f*4}), filename)); CORRADE_COMPARE_AS(filename, "\x0f", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert2DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } Containers::Array doConvertToData(const ImageView2D& image) override { return Containers::array({char(image.size().x()), char(image.size().y())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile(ImageView2D(PixelFormat::RGBA8Unorm, {0x0f, 0x0d}, Containers::Array{0x0f*0x0d*4}), filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert3DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData; } Containers::Array doConvertToData(const ImageView3D& image) override { return Containers::array({char(image.size().x()), char(image.size().y()), char(image.size().z())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile(ImageView3D(PixelFormat::RGBA8Unorm, {0x0f, 0x0d, 0x02}, Containers::Array{0x0f*0x0d*0x02*4}), filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert1DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData; } Containers::Array doConvertToData(const ImageView1D&) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 1, data}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convert2DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } Containers::Array doConvertToData(const ImageView2D&) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convert3DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData; } Containers::Array doConvertToData(const ImageView3D&) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convert1DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToData; } Containers::Array doConvertToData(const ImageView1D&) override { return Containers::array({'\x00'}); }; } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 1, data}, "/some/path/that/does/not/exist")); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convert2DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToData; } Containers::Array doConvertToData(const ImageView2D&) override { return Containers::array({'\x00'}); }; } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}, "/some/path/that/does/not/exist")); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convert3DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToData; } Containers::Array doConvertToData(const ImageView3D&) override { return Containers::array({'\x00'}); }; } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}, "/some/path/that/does/not/exist")); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convert1DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 0, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): can't convert image with a zero size: Vector(0)\n"); } void AbstractImageConverterTest::convert2DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): can't convert image with a zero size: Vector(0, 0)\n"); } void AbstractImageConverterTest::convert3DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): can't convert image with a zero size: Vector(0, 0, 0)\n"); } void AbstractImageConverterTest::convert1DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert1DToFile; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 1, data}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert2DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert2DToFile; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert3DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::Convert3DToFile; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed1DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToFile; } bool doConvertToFile(const CompressedImageView1D& image, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(image.size()[0])})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0x0f, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed2DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToFile; } bool doConvertToFile(const CompressedImageView2D& image, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(image.size().x()), char(image.size().y())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d}, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed3DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToFile; } bool doConvertToFile(const CompressedImageView3D& image, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(image.size().x()), char(image.size().y()), char(image.size().z())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d, 0x02}, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed1DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToData; } Containers::Array doConvertToData(const CompressedImageView1D& image) override { return Containers::array({char(image.size()[0])}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0x0f, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed2DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToData; } Containers::Array doConvertToData(const CompressedImageView2D& image) override { return Containers::array({char(image.size().x()), char(image.size().y())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d}, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed3DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToData; } Containers::Array doConvertToData(const CompressedImageView3D& image) override { return Containers::array({char(image.size().x()), char(image.size().y()), char(image.size().z())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d, 0x02}, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed1DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToData; } Containers::Array doConvertToData(const CompressedImageView1D&) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertCompressed2DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToData; } Containers::Array doConvertToData(const CompressedImageView2D&) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertCompressed3DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToData; } Containers::Array doConvertToData(const CompressedImageView3D&) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertCompressed1DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToData; } Containers::Array doConvertToData(const CompressedImageView1D&) override { return Containers::array({'\x00'}); }; } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}, "/some/path/that/does/not/exist"); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressed2DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToData; } Containers::Array doConvertToData(const CompressedImageView2D&) override { return Containers::array({'\x00'}); }; } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}, "/some/path/that/does/not/exist"); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressed3DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToData; } Containers::Array doConvertToData(const CompressedImageView3D&) override { return Containers::array({'\x00'}); }; } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}, "/some/path/that/does/not/exist"); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressed1DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): can't convert image with a zero size: Vector(0)\n"); } void AbstractImageConverterTest::convertCompressed2DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): can't convert image with a zero size: Vector(0, 0)\n"); } void AbstractImageConverterTest::convertCompressed3DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {}, nullptr}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): can't convert image with a zero size: Vector(0, 0, 0)\n"); } void AbstractImageConverterTest::convertCompressed1DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed1DToFile; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): compressed 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed2DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed2DToFile; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): compressed 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressed3DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressed3DToFile; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): compressed 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertImageData1DToFile() { ImageData1DConverter converter; /* Should get "B" when converting uncompressed */ CORRADE_VERIFY(converter.convertToFile(ImageData1D{PixelFormat::RGBA16F, 1, Containers::Array{8}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "B", TestSuite::Compare::FileToString); /* Should get "C" when converting compressed */ CORRADE_VERIFY(converter.convertToFile(ImageData1D{CompressedPixelFormat::Bc2RGBAUnorm, 4, Containers::Array{8}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "C", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertImageData2DToFile() { ImageData2DConverter converter; /* Should get "B" when converting uncompressed */ CORRADE_VERIFY(converter.convertToFile(ImageData2D{PixelFormat::RGBA16F, {1, 1}, Containers::Array{8}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "B", TestSuite::Compare::FileToString); /* Should get "C" when converting compressed */ CORRADE_VERIFY(converter.convertToFile(ImageData2D{CompressedPixelFormat::Bc2RGBAUnorm, {4, 4}, Containers::Array{8}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "C", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertImageData3DToFile() { ImageData3DConverter converter; /* Should get "B" when converting uncompressed */ CORRADE_VERIFY(converter.convertToFile(ImageData3D{PixelFormat::RGBA16F, {1, 1, 1}, Containers::Array{8}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "B", TestSuite::Compare::FileToString); /* Should get "C" when converting compressed */ CORRADE_VERIFY(converter.convertToFile(ImageData3D{CompressedPixelFormat::Bc2RGBAUnorm, {4, 4, 1}, Containers::Array{4}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"))); CORRADE_COMPARE_AS(Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"), "C", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertLevels1DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size()[0]), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; CORRADE_VERIFY(converter.convertToFile({ /* Arbitrary dimensions should be fine */ ImageView1D{PixelFormat::RGBA8Unorm, 0x0f, Containers::Array{0x0f*4}}, ImageView1D{PixelFormat::RGBA8Unorm, 1, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertLevels2DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; CORRADE_VERIFY(converter.convertToFile({ /* Arbitrary dimensions should be fine */ ImageView2D{PixelFormat::RGBA8Unorm, {0x0f, 0x0d}, Containers::Array{0x0f*0x0d*4}}, ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertLevels3DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels[0].size().z()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; CORRADE_VERIFY(converter.convertToFile({ /* Arbitrary dimensions should be fine */ ImageView3D{PixelFormat::RGBA8Unorm, {0x0f, 0x0d, 0x0e}, Containers::Array{0x0f*0x0d*0x0e*4}}, ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x0e\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertLevels1DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::array({char(imageLevels[0].size()[0]), char(imageLevels.size())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile({ /* Arbitrary dimensions should be fine */ ImageView1D{PixelFormat::RGBA8Unorm, 0x0f, Containers::Array{0x0f*4}}, ImageView1D{PixelFormat::RGBA8Unorm, 1, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertLevels2DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::array({char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels.size())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile({ ImageView2D(PixelFormat::RGBA8Unorm, {0x0f, 0x0d}, Containers::Array{0x0f*0x0d*4}), ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertLevels3DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::array({char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels[0].size().z()), char(imageLevels.size())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile({ ImageView3D{PixelFormat::RGBA8Unorm, {0x0f, 0x0d, 0x0e}, Containers::Array{0x0f*0x0d*0x0e*4}}, ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x0e\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertLevels1DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView1D{PixelFormat::RGBA8Unorm, 1, data}}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertLevels2DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertLevels3DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[4]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertLevels1DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::array({'\x00'}); }; } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView1D{PixelFormat::RGBA8Unorm, 1, data}}, "/some/path/that/does/not/exist")); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertLevels2DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::array({'\x00'}); }; } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}}, "/some/path/that/does/not/exist")); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertLevels3DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::array({'\x00'}); }; } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}}, "/some/path/that/does/not/exist")); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertLevels1DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(std::initializer_list{}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertLevels2DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(std::initializer_list{}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertLevels3DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(std::initializer_list{}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertLevels1DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToFile; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({ImageView1D{PixelFormat::RGBA8Unorm, 1, data}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): multi-level 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertLevels2DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToFile; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): multi-level 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertLevels3DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToFile; } } converter; const char data[4]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): multi-level 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressedLevels1DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size()[0]), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; CORRADE_VERIFY(converter.convertToFile({ CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0x0f, Containers::Array{64}}, CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressedLevels2DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; CORRADE_VERIFY(converter.convertToFile({ CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d}, Containers::Array{64}}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressedLevels3DToFile() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels[0].size().z()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; CORRADE_VERIFY(converter.convertToFile({ CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d, 0x0e}, Containers::Array{64}}, CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x0e\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressedLevels1DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::array({char(imageLevels[0].size()[0]), char(imageLevels.size())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile({ CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0x0f, Containers::Array{64}}, CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressedLevels2DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::array({char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels.size())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile({ CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d}, Containers::Array{64}}, CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressedLevels3DToFileThroughData() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView imageLevels) override { return Containers::array({char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels[0].size().z()), char(imageLevels.size())}); }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* doConvertToFile() should call doConvertToData() */ CORRADE_VERIFY(converter.convertToFile({ CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d, 0x0e}, Containers::Array{64}}, CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 4}, data} }, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x0e\x02", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressedLevels1DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertCompressedLevels2DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertCompressedLevels3DToFileThroughDataFailed() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return {}; }; } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); const char data[8]{}; /* Function should fail, no file should get written and no error output should be printed (the base implementation assumes the plugin does it) */ std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 4}, data}}, filename)); CORRADE_VERIFY(!Utility::Path::exists(filename)); CORRADE_COMPARE(out.str(), ""); } void AbstractImageConverterTest::convertCompressedLevels1DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::array({'\x00'}); }; } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}}, "/some/path/that/does/not/exist"); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressedLevels2DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::array({'\x00'}); }; } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}}, "/some/path/that/does/not/exist"); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressedLevels3DToFileThroughDataNotWritable() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToData; } Containers::Array doConvertToData(Containers::ArrayView) override { return Containers::array({'\x00'}); }; } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}}, "/some/path/that/does/not/exist"); CORRADE_COMPARE_AS(out.str(), "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressedLevels1DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(std::initializer_list{}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(std::initializer_list{}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertCompressedLevels3DToFileInvalidImage() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToFile; } } converter; std::ostringstream out; Error redirectError{&out}; converter.convertToFile(std::initializer_list{}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): at least one image has to be specified\n"); } void AbstractImageConverterTest::convertCompressedLevels1DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToFile; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): multi-level compressed 1D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressedLevels2DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToFile; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): multi-level compressed 2D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convertCompressedLevels3DToFileNotImplemented() { #ifdef CORRADE_NO_ASSERT CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); #endif struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToFile; } } converter; const char data[8]{}; std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 4}, data}}, Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out")); CORRADE_COMPARE(out.str(), "Trade::AbstractImageConverter::convertToFile(): multi-level compressed 3D image conversion advertised but not implemented\n"); } void AbstractImageConverterTest::convert1DToFileThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels1DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size()[0]), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 0x0f, Containers::Array{0x0f*4}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x01", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert2DToFileThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels2DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {0x0f, 0x0d}, Containers::Array{0x0f*0x0d*4}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x01", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convert3DToFileThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertLevels3DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels[0].size().z()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {0x0f, 0x0d, 0x0e}, Containers::Array{0x0f*0x0d*0x0e*4}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x0e\x01", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed1DToFileThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels1DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size()[0]), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 0x0f, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x01", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed2DToFileThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels2DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d}, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x01", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::convertCompressed3DToFileThroughLevels() { struct: AbstractImageConverter { ImageConverterFeatures doFeatures() const override { return ImageConverterFeature::ConvertCompressedLevels3DToFile; } bool doConvertToFile(Containers::ArrayView imageLevels, Containers::StringView filename) override { return Utility::Path::write(filename, Containers::arrayView( {char(imageLevels[0].size().x()), char(imageLevels[0].size().y()), char(imageLevels[0].size().z()), char(imageLevels.size())})); } } converter; /* Remove previous file, if any */ Containers::String filename = Utility::Path::join(TRADE_TEST_OUTPUT_DIR, "image.out"); if(Utility::Path::exists(filename)) CORRADE_VERIFY(Utility::Path::remove(filename)); CORRADE_VERIFY(converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {0x0f, 0x0d, 0x0e}, Containers::Array{64}}, filename)); CORRADE_COMPARE_AS(filename, "\x0f\x0d\x0e\x01", TestSuite::Compare::FileToString); } void AbstractImageConverterTest::debugFeature() { std::ostringstream out; Debug{&out} << ImageConverterFeature::ConvertCompressed2D << ImageConverterFeature(0xdeadbeef); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertCompressed2D Trade::ImageConverterFeature(0xdeadbeef)\n"); } void AbstractImageConverterTest::debugFeatures() { std::ostringstream out; Debug{&out} << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::ConvertCompressed2DToFile) << ImageConverterFeatures{}; CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::Convert2DToData|Trade::ImageConverterFeature::ConvertCompressed2DToFile Trade::ImageConverterFeatures{}\n"); } void AbstractImageConverterTest::debugFeaturesSupersets() { /* Convert*DToData is a superset of Convert*DToFile, so only one should be printed */ { std::ostringstream out; Debug{&out} << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::Convert2DToFile); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::Convert2DToData\n"); /* ConvertCompressed*DToData is a superset of ConvertCompressed*DToFile, so only one should be printed */ } { std::ostringstream out; Debug{&out} << (ImageConverterFeature::ConvertCompressed1DToData|ImageConverterFeature::ConvertCompressed1DToFile); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertCompressed1DToData\n"); /* ConvertLevels*DToData is a superset of ConvertLevels*DToFile, so only one should be printed */ } { std::ostringstream out; Debug{&out} << (ImageConverterFeature::ConvertLevels2DToData|ImageConverterFeature::ConvertLevels2DToFile); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertLevels2DToData\n"); /* ConvertLevels*DToData is *also* a superset of Convert*DToData, so only one should be printed */ } { std::ostringstream out; Debug{&out} << (ImageConverterFeature::ConvertLevels3DToData|ImageConverterFeature::Convert3DToData); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertLevels3DToData\n"); /* ConvertCompressedLevels*DToData is a superset of ConvertCompressedLevels*DToFile, so only one should be printed */ } { std::ostringstream out; Debug{&out} << (ImageConverterFeature::ConvertCompressedLevels1DToData|ImageConverterFeature::ConvertCompressedLevels1DToFile); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertCompressedLevels1DToData\n"); /* ConvertCompressedLevels*DToData is *also* a superset of ConvertCompressed*DToData, so only one should be printed */ } { std::ostringstream out; Debug{&out} << (ImageConverterFeature::ConvertCompressedLevels3DToData|ImageConverterFeature::ConvertCompressed3DToData); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertCompressedLevels3DToData\n"); } } void AbstractImageConverterTest::debugFlag() { std::ostringstream out; Debug{&out} << ImageConverterFlag::Verbose << ImageConverterFlag(0xf0); CORRADE_COMPARE(out.str(), "Trade::ImageConverterFlag::Verbose Trade::ImageConverterFlag(0xf0)\n"); } void AbstractImageConverterTest::debugFlags() { std::ostringstream out; Debug{&out} << (ImageConverterFlag::Verbose|ImageConverterFlag(0xf0)) << ImageConverterFlags{}; CORRADE_COMPARE(out.str(), "Trade::ImageConverterFlag::Verbose|Trade::ImageConverterFlag(0xf0) Trade::ImageConverterFlags{}\n"); } }}}} CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractImageConverterTest)