Browse Source

ShaderTools,Text,Trade: move debug output code & tests to the top.

It's done like this in all other code, not sure why not here. Likely
because debug output wasn't tested at all before and only got added
later, thus at the end? So make it consistent.
pull/482/merge
Vladimír Vondruš 2 weeks ago
parent
commit
eb81fa48e4
  1. 182
      src/Magnum/ShaderTools/AbstractConverter.cpp
  2. 184
      src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp
  3. 53
      src/Magnum/Text/AbstractFont.cpp
  4. 61
      src/Magnum/Text/AbstractFontConverter.cpp
  5. 80
      src/Magnum/Text/Test/AbstractFontConverterTest.cpp
  6. 79
      src/Magnum/Text/Test/AbstractFontTest.cpp
  7. 218
      src/Magnum/Trade/AbstractImageConverter.cpp
  8. 96
      src/Magnum/Trade/AbstractImporter.cpp
  9. 285
      src/Magnum/Trade/AbstractSceneConverter.cpp
  10. 212
      src/Magnum/Trade/Test/AbstractImageConverterTest.cpp
  11. 114
      src/Magnum/Trade/Test/AbstractImporterTest.cpp
  12. 226
      src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp

182
src/Magnum/ShaderTools/AbstractConverter.cpp

@ -52,6 +52,97 @@ namespace Magnum { namespace ShaderTools {
using namespace Containers::Literals; using namespace Containers::Literals;
Debug& operator<<(Debug& debug, const ConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "ShaderTools::ConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(ValidateData)
_c(ValidateFile)
_c(ConvertData)
_c(ConvertFile)
_c(LinkData)
_c(LinkFile)
_c(InputFileCallback)
_c(Preprocess)
_c(Optimize)
_c(DebugInfo)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const ConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "ShaderTools::ConverterFeatures{}", {
ConverterFeature::ValidateData,
/* Implied by ValidateData, has to be after */
ConverterFeature::ValidateFile,
ConverterFeature::ConvertData,
/* Implied by ConvertData, has to be after */
ConverterFeature::ConvertFile,
ConverterFeature::LinkData,
/* Implied by LinkData, has to be after */
ConverterFeature::LinkFile,
ConverterFeature::InputFileCallback,
ConverterFeature::Preprocess,
ConverterFeature::Optimize,
ConverterFeature::DebugInfo
});
}
Debug& operator<<(Debug& debug, const ConverterFlag value) {
debug << "ShaderTools::ConverterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ConverterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
_c(WarningAsError)
_c(PreprocessOnly)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const ConverterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "ShaderTools::ConverterFlags{}", {
ConverterFlag::Quiet,
ConverterFlag::Verbose,
ConverterFlag::WarningAsError,
ConverterFlag::PreprocessOnly
});
}
Debug& operator<<(Debug& debug, const Format value) {
debug << "ShaderTools::Format" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case Format::v: return debug << "::" #v;
_c(Unspecified)
_c(Glsl)
_c(Spirv)
_c(SpirvAssembly)
_c(Hlsl)
_c(Msl)
_c(Wgsl)
_c(Dxil)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Containers::StringView AbstractConverter::pluginInterface() { Containers::StringView AbstractConverter::pluginInterface() {
return MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE ""_s; return MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE ""_s;
} }
@ -729,95 +820,4 @@ Containers::Optional<Containers::Array<char>> AbstractConverter::doLinkFilesToDa
} }
} }
Debug& operator<<(Debug& debug, const ConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "ShaderTools::ConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(ValidateData)
_c(ValidateFile)
_c(ConvertData)
_c(ConvertFile)
_c(LinkData)
_c(LinkFile)
_c(InputFileCallback)
_c(Preprocess)
_c(Optimize)
_c(DebugInfo)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const ConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "ShaderTools::ConverterFeatures{}", {
ConverterFeature::ValidateData,
/* Implied by ValidateData, has to be after */
ConverterFeature::ValidateFile,
ConverterFeature::ConvertData,
/* Implied by ConvertData, has to be after */
ConverterFeature::ConvertFile,
ConverterFeature::LinkData,
/* Implied by LinkData, has to be after */
ConverterFeature::LinkFile,
ConverterFeature::InputFileCallback,
ConverterFeature::Preprocess,
ConverterFeature::Optimize,
ConverterFeature::DebugInfo
});
}
Debug& operator<<(Debug& debug, const ConverterFlag value) {
debug << "ShaderTools::ConverterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ConverterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
_c(WarningAsError)
_c(PreprocessOnly)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const ConverterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "ShaderTools::ConverterFlags{}", {
ConverterFlag::Quiet,
ConverterFlag::Verbose,
ConverterFlag::WarningAsError,
ConverterFlag::PreprocessOnly
});
}
Debug& operator<<(Debug& debug, const Format value) {
debug << "ShaderTools::Format" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case Format::v: return debug << "::" #v;
_c(Unspecified)
_c(Glsl)
_c(Spirv)
_c(SpirvAssembly)
_c(Hlsl)
_c(Msl)
_c(Wgsl)
_c(Dxil)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
}} }}

184
src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp

@ -47,6 +47,15 @@ namespace Magnum { namespace ShaderTools { namespace Test { namespace {
struct AbstractConverterTest: TestSuite::Tester { struct AbstractConverterTest: TestSuite::Tester {
explicit AbstractConverterTest(); explicit AbstractConverterTest();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void debugFeaturesSupersets();
void debugFlag();
void debugFlags();
void debugFormat();
void construct(); void construct();
void constructWithPluginManagerReference(); void constructWithPluginManagerReference();
@ -193,19 +202,19 @@ struct AbstractConverterTest: TestSuite::Tester {
void setInputFileCallbackLinkFilesToDataThroughBaseImplementationFailed(); void setInputFileCallbackLinkFilesToDataThroughBaseImplementationFailed();
void setInputFileCallbackLinkFilesToDataAsData(); void setInputFileCallbackLinkFilesToDataAsData();
void setInputFileCallbackLinkFilesToDataAsDataFailed(); void setInputFileCallbackLinkFilesToDataAsDataFailed();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void debugFeaturesSupersets();
void debugFlag();
void debugFlags();
void debugFormat();
}; };
AbstractConverterTest::AbstractConverterTest() { AbstractConverterTest::AbstractConverterTest() {
addTests({&AbstractConverterTest::featuresNone, addTests({&AbstractConverterTest::debugFeature,
&AbstractConverterTest::debugFeaturePacked,
&AbstractConverterTest::debugFeatures,
&AbstractConverterTest::debugFeaturesPacked,
&AbstractConverterTest::debugFeaturesSupersets,
&AbstractConverterTest::debugFlag,
&AbstractConverterTest::debugFlags,
&AbstractConverterTest::debugFormat,
&AbstractConverterTest::featuresNone,
&AbstractConverterTest::construct, &AbstractConverterTest::construct,
&AbstractConverterTest::constructWithPluginManagerReference, &AbstractConverterTest::constructWithPluginManagerReference,
@ -350,21 +359,84 @@ AbstractConverterTest::AbstractConverterTest() {
&AbstractConverterTest::setInputFileCallbackLinkFilesToDataThroughBaseImplementation, &AbstractConverterTest::setInputFileCallbackLinkFilesToDataThroughBaseImplementation,
&AbstractConverterTest::setInputFileCallbackLinkFilesToDataThroughBaseImplementationFailed, &AbstractConverterTest::setInputFileCallbackLinkFilesToDataThroughBaseImplementationFailed,
&AbstractConverterTest::setInputFileCallbackLinkFilesToDataAsData, &AbstractConverterTest::setInputFileCallbackLinkFilesToDataAsData,
&AbstractConverterTest::setInputFileCallbackLinkFilesToDataAsDataFailed, &AbstractConverterTest::setInputFileCallbackLinkFilesToDataAsDataFailed});
&AbstractConverterTest::debugFeature,
&AbstractConverterTest::debugFeaturePacked,
&AbstractConverterTest::debugFeatures,
&AbstractConverterTest::debugFeaturesPacked,
&AbstractConverterTest::debugFeaturesSupersets,
&AbstractConverterTest::debugFlag,
&AbstractConverterTest::debugFlags,
&AbstractConverterTest::debugFormat});
/* Create testing dir */ /* Create testing dir */
Utility::Path::make(SHADERTOOLS_TEST_OUTPUT_DIR); Utility::Path::make(SHADERTOOLS_TEST_OUTPUT_DIR);
} }
void AbstractConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << ConverterFeature::ConvertData << ConverterFeature(0xf0);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ConvertData ShaderTools::ConverterFeature(0xf0)\n");
}
void AbstractConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ConverterFeature::ConvertData << Debug::packed << ConverterFeature(0xf0) << ConverterFeature::ValidateFile;
CORRADE_COMPARE(out, "ConvertData 0xf0 ShaderTools::ConverterFeature::ValidateFile\n");
}
void AbstractConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (ConverterFeature::ValidateData|ConverterFeature::ConvertFile) << ConverterFeatures{};
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ValidateData|ShaderTools::ConverterFeature::ConvertFile ShaderTools::ConverterFeatures{}\n");
}
void AbstractConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (ConverterFeature::ValidateData|ConverterFeature::ConvertFile) << Debug::packed << ConverterFeatures{} << ConverterFeature::InputFileCallback;
CORRADE_COMPARE(out, "ValidateData|ConvertFile {} ShaderTools::ConverterFeature::InputFileCallback\n");
}
void AbstractConverterTest::debugFeaturesSupersets() {
/* ValidateData is a superset of ValidateFile, so only one should be
printed */
{
Containers::String out;
Debug{&out} << (ConverterFeature::ValidateData|ConverterFeature::ValidateFile);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ValidateData\n");
/* ConvertData is a superset of ConvertFile, so only one should be
printed */
} {
Containers::String out;
Debug{&out} << (ConverterFeature::ConvertData|ConverterFeature::ConvertFile);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ConvertData\n");
/* LinkData is a superset of LinkFile, so only one should be printed */
} {
Containers::String out;
Debug{&out} << (ConverterFeature::LinkData|ConverterFeature::LinkFile);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::LinkData\n");
}
}
void AbstractConverterTest::debugFlag() {
Containers::String out;
Debug{&out} << ConverterFlag::Verbose << ConverterFlag(0xf0);
CORRADE_COMPARE(out, "ShaderTools::ConverterFlag::Verbose ShaderTools::ConverterFlag(0xf0)\n");
}
void AbstractConverterTest::debugFlags() {
Containers::String out;
Debug{&out} << (ConverterFlag::Verbose|ConverterFlag(0xf0)) << ConverterFlags{};
CORRADE_COMPARE(out, "ShaderTools::ConverterFlag::Verbose|ShaderTools::ConverterFlag(0xf0) ShaderTools::ConverterFlags{}\n");
}
void AbstractConverterTest::debugFormat() {
Containers::String out;
Debug{&out} << Format::Glsl << Format(0xf0);
CORRADE_COMPARE(out, "ShaderTools::Format::Glsl ShaderTools::Format(0xf0)\n");
}
void AbstractConverterTest::construct() { void AbstractConverterTest::construct() {
struct: AbstractConverter { struct: AbstractConverter {
ConverterFeatures doFeatures() const override { ConverterFeatures doFeatures() const override {
@ -3695,78 +3767,6 @@ void AbstractConverterTest::setInputFileCallbackLinkFilesToDataAsDataFailed() {
CORRADE_COMPARE(out, "ShaderTools::AbstractConverter::linkFilesToData(): cannot open file file.dat\n"); CORRADE_COMPARE(out, "ShaderTools::AbstractConverter::linkFilesToData(): cannot open file file.dat\n");
} }
void AbstractConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << ConverterFeature::ConvertData << ConverterFeature(0xf0);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ConvertData ShaderTools::ConverterFeature(0xf0)\n");
}
void AbstractConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ConverterFeature::ConvertData << Debug::packed << ConverterFeature(0xf0) << ConverterFeature::ValidateFile;
CORRADE_COMPARE(out, "ConvertData 0xf0 ShaderTools::ConverterFeature::ValidateFile\n");
}
void AbstractConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (ConverterFeature::ValidateData|ConverterFeature::ConvertFile) << ConverterFeatures{};
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ValidateData|ShaderTools::ConverterFeature::ConvertFile ShaderTools::ConverterFeatures{}\n");
}
void AbstractConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (ConverterFeature::ValidateData|ConverterFeature::ConvertFile) << Debug::packed << ConverterFeatures{} << ConverterFeature::InputFileCallback;
CORRADE_COMPARE(out, "ValidateData|ConvertFile {} ShaderTools::ConverterFeature::InputFileCallback\n");
}
void AbstractConverterTest::debugFeaturesSupersets() {
/* ValidateData is a superset of ValidateFile, so only one should be
printed */
{
Containers::String out;
Debug{&out} << (ConverterFeature::ValidateData|ConverterFeature::ValidateFile);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ValidateData\n");
/* ConvertData is a superset of ConvertFile, so only one should be
printed */
} {
Containers::String out;
Debug{&out} << (ConverterFeature::ConvertData|ConverterFeature::ConvertFile);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::ConvertData\n");
/* LinkData is a superset of LinkFile, so only one should be printed */
} {
Containers::String out;
Debug{&out} << (ConverterFeature::LinkData|ConverterFeature::LinkFile);
CORRADE_COMPARE(out, "ShaderTools::ConverterFeature::LinkData\n");
}
}
void AbstractConverterTest::debugFlag() {
Containers::String out;
Debug{&out} << ConverterFlag::Verbose << ConverterFlag(0xf0);
CORRADE_COMPARE(out, "ShaderTools::ConverterFlag::Verbose ShaderTools::ConverterFlag(0xf0)\n");
}
void AbstractConverterTest::debugFlags() {
Containers::String out;
Debug{&out} << (ConverterFlag::Verbose|ConverterFlag(0xf0)) << ConverterFlags{};
CORRADE_COMPARE(out, "ShaderTools::ConverterFlag::Verbose|ShaderTools::ConverterFlag(0xf0) ShaderTools::ConverterFlags{}\n");
}
void AbstractConverterTest::debugFormat() {
Containers::String out;
Debug{&out} << Format::Glsl << Format(0xf0);
CORRADE_COMPARE(out, "ShaderTools::Format::Glsl ShaderTools::Format(0xf0)\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::ShaderTools::Test::AbstractConverterTest) CORRADE_TEST_MAIN(Magnum::ShaderTools::Test::AbstractConverterTest)

53
src/Magnum/Text/AbstractFont.cpp

@ -66,6 +66,33 @@ namespace Magnum { namespace Text {
using namespace Containers::Literals; using namespace Containers::Literals;
Debug& operator<<(Debug& debug, const FontFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Text::FontFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case FontFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(OpenData)
_c(FileCallback)
_c(PreparedGlyphCache)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const FontFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Text::FontFeatures{}", {
FontFeature::OpenData,
FontFeature::FileCallback,
FontFeature::PreparedGlyphCache
});
}
Containers::StringView AbstractFont::pluginInterface() { Containers::StringView AbstractFont::pluginInterface() {
return MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE ""_s; return MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE ""_s;
} }
@ -486,32 +513,6 @@ Containers::Pointer<AbstractLayouter> AbstractFont::layout(const AbstractGlyphCa
CORRADE_IGNORE_DEPRECATED_POP CORRADE_IGNORE_DEPRECATED_POP
#endif #endif
Debug& operator<<(Debug& debug, const FontFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Text::FontFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case FontFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(OpenData)
_c(FileCallback)
_c(PreparedGlyphCache)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const FontFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Text::FontFeatures{}", {
FontFeature::OpenData,
FontFeature::FileCallback,
FontFeature::PreparedGlyphCache});
}
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
AbstractLayouter::AbstractLayouter(Containers::Array<Containers::Triple<Range2D, Range2D, Vector2>>&& glyphs): _glyphs{Utility::move(glyphs)} {} AbstractLayouter::AbstractLayouter(Containers::Array<Containers::Triple<Range2D, Range2D, Vector2>>&& glyphs): _glyphs{Utility::move(glyphs)} {}

61
src/Magnum/Text/AbstractFontConverter.cpp

@ -54,6 +54,37 @@ namespace Magnum { namespace Text {
using namespace Containers::Literals; using namespace Containers::Literals;
Debug& operator<<(Debug& debug, const FontConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Text::FontConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case FontConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(ExportFont)
_c(ExportGlyphCache)
_c(ImportGlyphCache)
_c(ConvertData)
_c(MultiFile)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << Containers::enumCastUnderlyingType(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const FontConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Text::FontConverterFeatures{}", {
FontConverterFeature::ExportFont,
FontConverterFeature::ExportGlyphCache,
FontConverterFeature::ImportGlyphCache,
FontConverterFeature::ConvertData,
FontConverterFeature::MultiFile
});
}
namespace { namespace {
std::u32string uniqueUnicode(const std::string& characters) std::u32string uniqueUnicode(const std::string& characters)
@ -284,34 +315,4 @@ Containers::Pointer<AbstractGlyphCache> AbstractFontConverter::doImportGlyphCach
return doImportGlyphCacheFromSingleData(*data); return doImportGlyphCacheFromSingleData(*data);
} }
Debug& operator<<(Debug& debug, const FontConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Text::FontConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case FontConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(ExportFont)
_c(ExportGlyphCache)
_c(ImportGlyphCache)
_c(ConvertData)
_c(MultiFile)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << Containers::enumCastUnderlyingType(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const FontConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Text::FontConverterFeatures{}", {
FontConverterFeature::ExportFont,
FontConverterFeature::ExportGlyphCache,
FontConverterFeature::ImportGlyphCache,
FontConverterFeature::ConvertData,
FontConverterFeature::MultiFile});
}
}} }}

80
src/Magnum/Text/Test/AbstractFontConverterTest.cpp

@ -48,6 +48,11 @@ namespace Magnum { namespace Text { namespace Test { namespace {
struct AbstractFontConverterTest: TestSuite::Tester { struct AbstractFontConverterTest: TestSuite::Tester {
explicit AbstractFontConverterTest(); explicit AbstractFontConverterTest();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void construct(); void construct();
void convertGlyphs(); void convertGlyphs();
@ -106,15 +111,15 @@ struct AbstractFontConverterTest: TestSuite::Tester {
void importGlyphCacheFromFileAsSingleData(); void importGlyphCacheFromFileAsSingleData();
void importGlyphCacheFromFileAsSingleDataNotFound(); void importGlyphCacheFromFileAsSingleDataNotFound();
void importGlyphCacheFromFileAsSingleDataFailed(); void importGlyphCacheFromFileAsSingleDataFailed();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
}; };
AbstractFontConverterTest::AbstractFontConverterTest() { AbstractFontConverterTest::AbstractFontConverterTest() {
addTests({&AbstractFontConverterTest::construct, addTests({&AbstractFontConverterTest::debugFeature,
&AbstractFontConverterTest::debugFeaturePacked,
&AbstractFontConverterTest::debugFeatures,
&AbstractFontConverterTest::debugFeaturesPacked,
&AbstractFontConverterTest::construct,
&AbstractFontConverterTest::convertGlyphs, &AbstractFontConverterTest::convertGlyphs,
@ -171,17 +176,40 @@ AbstractFontConverterTest::AbstractFontConverterTest() {
&AbstractFontConverterTest::importGlyphCacheFromFileNotImplemented, &AbstractFontConverterTest::importGlyphCacheFromFileNotImplemented,
&AbstractFontConverterTest::importGlyphCacheFromFileAsSingleData, &AbstractFontConverterTest::importGlyphCacheFromFileAsSingleData,
&AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataNotFound, &AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataNotFound,
&AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataFailed, &AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataFailed});
&AbstractFontConverterTest::debugFeature,
&AbstractFontConverterTest::debugFeaturePacked,
&AbstractFontConverterTest::debugFeatures,
&AbstractFontConverterTest::debugFeaturesPacked});
/* Create testing dir */ /* Create testing dir */
Utility::Path::make(TEXT_TEST_OUTPUT_DIR); Utility::Path::make(TEXT_TEST_OUTPUT_DIR);
} }
void AbstractFontConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << FontConverterFeature::ExportFont << FontConverterFeature(0xf0);
CORRADE_COMPARE(out, "Text::FontConverterFeature::ExportFont Text::FontConverterFeature(0xf0)\n");
}
void AbstractFontConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << FontConverterFeature::ExportFont << Debug::packed << FontConverterFeature(0xf0) << FontConverterFeature::ImportGlyphCache;
CORRADE_COMPARE(out, "ExportFont 0xf0 Text::FontConverterFeature::ImportGlyphCache\n");
}
void AbstractFontConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (FontConverterFeature::ExportFont|FontConverterFeature::ImportGlyphCache) << FontConverterFeatures{};
CORRADE_COMPARE(out, "Text::FontConverterFeature::ExportFont|Text::FontConverterFeature::ImportGlyphCache Text::FontConverterFeatures{}\n");
}
void AbstractFontConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (FontConverterFeature::ExportFont|FontConverterFeature::ImportGlyphCache) << Debug::packed << FontConverterFeatures{} << FontConverterFeature::ExportGlyphCache;
CORRADE_COMPARE(out, "ExportFont|ImportGlyphCache {} Text::FontConverterFeature::ExportGlyphCache\n");
}
void AbstractFontConverterTest::construct() { void AbstractFontConverterTest::construct() {
struct: AbstractFontConverter { struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override { FontConverterFeatures doFeatures() const override {
@ -1333,34 +1361,6 @@ void AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataFailed() {
CORRADE_COMPARE(out, ""); CORRADE_COMPARE(out, "");
} }
void AbstractFontConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << FontConverterFeature::ExportFont << FontConverterFeature(0xf0);
CORRADE_COMPARE(out, "Text::FontConverterFeature::ExportFont Text::FontConverterFeature(0xf0)\n");
}
void AbstractFontConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << FontConverterFeature::ExportFont << Debug::packed << FontConverterFeature(0xf0) << FontConverterFeature::ImportGlyphCache;
CORRADE_COMPARE(out, "ExportFont 0xf0 Text::FontConverterFeature::ImportGlyphCache\n");
}
void AbstractFontConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (FontConverterFeature::ExportFont|FontConverterFeature::ImportGlyphCache) << FontConverterFeatures{};
CORRADE_COMPARE(out, "Text::FontConverterFeature::ExportFont|Text::FontConverterFeature::ImportGlyphCache Text::FontConverterFeatures{}\n");
}
void AbstractFontConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (FontConverterFeature::ExportFont|FontConverterFeature::ImportGlyphCache) << Debug::packed << FontConverterFeatures{} << FontConverterFeature::ExportGlyphCache;
CORRADE_COMPARE(out, "ExportFont|ImportGlyphCache {} Text::FontConverterFeature::ExportGlyphCache\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontConverterTest) CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontConverterTest)

79
src/Magnum/Text/Test/AbstractFontTest.cpp

@ -55,6 +55,11 @@ namespace Magnum { namespace Text { namespace Test { namespace {
struct AbstractFontTest: TestSuite::Tester { struct AbstractFontTest: TestSuite::Tester {
explicit AbstractFontTest(); explicit AbstractFontTest();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void construct(); void construct();
void openData(); void openData();
@ -128,15 +133,15 @@ struct AbstractFontTest: TestSuite::Tester {
void layoutGlyphOutOfRange(); void layoutGlyphOutOfRange();
void layoutNoFont(); void layoutNoFont();
#endif #endif
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
}; };
AbstractFontTest::AbstractFontTest() { AbstractFontTest::AbstractFontTest() {
addTests({&AbstractFontTest::construct, addTests({&AbstractFontTest::debugFeature,
&AbstractFontTest::debugFeaturePacked,
&AbstractFontTest::debugFeatures,
&AbstractFontTest::debugFeaturesPacked,
&AbstractFontTest::construct,
&AbstractFontTest::openData, &AbstractFontTest::openData,
&AbstractFontTest::openDataFailed, &AbstractFontTest::openDataFailed,
@ -209,15 +214,39 @@ AbstractFontTest::AbstractFontTest() {
&AbstractFontTest::layoutGlyphOutOfRange, &AbstractFontTest::layoutGlyphOutOfRange,
&AbstractFontTest::layoutNoFont, &AbstractFontTest::layoutNoFont,
#endif #endif
});
&AbstractFontTest::debugFeature,
&AbstractFontTest::debugFeaturePacked,
&AbstractFontTest::debugFeatures,
&AbstractFontTest::debugFeaturesPacked});
} }
using namespace Containers::Literals; using namespace Containers::Literals;
void AbstractFontTest::debugFeature() {
Containers::String out;
Debug{&out} << FontFeature::OpenData << FontFeature(0xf0);
CORRADE_COMPARE(out, "Text::FontFeature::OpenData Text::FontFeature(0xf0)\n");
}
void AbstractFontTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << FontFeature::OpenData << Debug::packed << FontFeature(0xf0) << FontFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData 0xf0 Text::FontFeature::FileCallback\n");
}
void AbstractFontTest::debugFeatures() {
Containers::String out;
Debug{&out} << (FontFeature::OpenData|FontFeature::PreparedGlyphCache) << FontFeatures{};
CORRADE_COMPARE(out, "Text::FontFeature::OpenData|Text::FontFeature::PreparedGlyphCache Text::FontFeatures{}\n");
}
void AbstractFontTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (FontFeature::OpenData|FontFeature::PreparedGlyphCache) << Debug::packed << FontFeatures{} << FontFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData|PreparedGlyphCache {} Text::FontFeature::FileCallback\n");
}
void AbstractFontTest::construct() { void AbstractFontTest::construct() {
struct: AbstractFont { struct: AbstractFont {
FontFeatures doFeatures() const override { return {}; } FontFeatures doFeatures() const override { return {}; }
@ -2242,34 +2271,6 @@ void AbstractFontTest::layoutNoFont() {
} }
#endif #endif
void AbstractFontTest::debugFeature() {
Containers::String out;
Debug{&out} << FontFeature::OpenData << FontFeature(0xf0);
CORRADE_COMPARE(out, "Text::FontFeature::OpenData Text::FontFeature(0xf0)\n");
}
void AbstractFontTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << FontFeature::OpenData << Debug::packed << FontFeature(0xf0) << FontFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData 0xf0 Text::FontFeature::FileCallback\n");
}
void AbstractFontTest::debugFeatures() {
Containers::String out;
Debug{&out} << (FontFeature::OpenData|FontFeature::PreparedGlyphCache) << FontFeatures{};
CORRADE_COMPARE(out, "Text::FontFeature::OpenData|Text::FontFeature::PreparedGlyphCache Text::FontFeatures{}\n");
}
void AbstractFontTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (FontFeature::OpenData|FontFeature::PreparedGlyphCache) << Debug::packed << FontFeatures{} << FontFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData|PreparedGlyphCache {} Text::FontFeature::FileCallback\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontTest) CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontTest)

218
src/Magnum/Trade/AbstractImageConverter.cpp

@ -57,6 +57,116 @@ namespace Magnum { namespace Trade {
using namespace Containers::Literals; using namespace Containers::Literals;
Debug& operator<<(Debug& debug, const ImageConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
#ifdef MAGNUM_BUILD_DEPRECATED
/* If printing a deprecated flag combination, make it look like the enum
set */
if((value & ImageConverterFeature::Levels) && (value & ~ImageConverterFeature::Levels))
return debug << (value & ~ImageConverterFeature::Levels) << Debug::nospace << (packed ? "|Levels" : "|Trade::ImageConverterFeature::Levels");
#endif
if(!packed)
debug << "Trade::ImageConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImageConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(Convert1D)
_c(Convert2D)
_c(Convert3D)
_c(ConvertCompressed1D)
_c(ConvertCompressed2D)
_c(ConvertCompressed3D)
_c(Convert1DToFile)
_c(Convert2DToFile)
_c(Convert3DToFile)
_c(ConvertCompressed1DToFile)
_c(ConvertCompressed2DToFile)
_c(ConvertCompressed3DToFile)
_c(Convert1DToData)
_c(Convert2DToData)
_c(Convert3DToData)
_c(ConvertCompressed1DToData)
_c(ConvertCompressed2DToData)
_c(ConvertCompressed3DToData)
_c(Levels)
#undef _c
/* LCOV_EXCL_STOP */
#ifdef MAGNUM_BUILD_DEPRECATED
/* LCOV_EXCL_START */
CORRADE_IGNORE_DEPRECATED_PUSH
case ImageConverterFeature::ConvertLevels1DToData:
case ImageConverterFeature::ConvertLevels2DToData:
case ImageConverterFeature::ConvertLevels3DToData:
case ImageConverterFeature::ConvertCompressedLevels1DToData:
case ImageConverterFeature::ConvertCompressedLevels2DToData:
case ImageConverterFeature::ConvertCompressedLevels3DToData:
case ImageConverterFeature::ConvertLevels1DToFile:
case ImageConverterFeature::ConvertLevels2DToFile:
case ImageConverterFeature::ConvertLevels3DToFile:
case ImageConverterFeature::ConvertCompressedLevels1DToFile:
case ImageConverterFeature::ConvertCompressedLevels2DToFile:
case ImageConverterFeature::ConvertCompressedLevels3DToFile:
CORRADE_INTERNAL_ASSERT_UNREACHABLE();
CORRADE_IGNORE_DEPRECATED_POP
/* LCOV_EXCL_STOP */
#endif
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedInt(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const ImageConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::ImageConverterFeatures{}", {
ImageConverterFeature::Convert1D,
ImageConverterFeature::Convert2D,
ImageConverterFeature::Convert3D,
ImageConverterFeature::ConvertCompressed1D,
ImageConverterFeature::ConvertCompressed2D,
ImageConverterFeature::ConvertCompressed3D,
ImageConverterFeature::Convert1DToData,
ImageConverterFeature::Convert2DToData,
ImageConverterFeature::Convert3DToData,
ImageConverterFeature::ConvertCompressed1DToData,
ImageConverterFeature::ConvertCompressed2DToData,
ImageConverterFeature::ConvertCompressed3DToData,
/* These 6 are implied by Convert[Compressed]ToData, so have to be
after */
ImageConverterFeature::Convert1DToFile,
ImageConverterFeature::Convert2DToFile,
ImageConverterFeature::Convert3DToFile,
ImageConverterFeature::ConvertCompressed1DToFile,
ImageConverterFeature::ConvertCompressed2DToFile,
ImageConverterFeature::ConvertCompressed3DToFile,
ImageConverterFeature::Levels
});
}
Debug& operator<<(Debug& debug, const ImageConverterFlag value) {
debug << "Trade::ImageConverterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImageConverterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const ImageConverterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::ImageConverterFlags{}", {
ImageConverterFlag::Quiet,
ImageConverterFlag::Verbose
});
}
Containers::StringView AbstractImageConverter::pluginInterface() { Containers::StringView AbstractImageConverter::pluginInterface() {
return MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE ""_s; return MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE ""_s;
} }
@ -1291,112 +1401,4 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView<const C
return true; return true;
} }
Debug& operator<<(Debug& debug, const ImageConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
#ifdef MAGNUM_BUILD_DEPRECATED
/* If printing a deprecated flag combination, make it look like the enum
set */
if((value & ImageConverterFeature::Levels) && (value & ~ImageConverterFeature::Levels))
return debug << (value & ~ImageConverterFeature::Levels) << Debug::nospace << (packed ? "|Levels" : "|Trade::ImageConverterFeature::Levels");
#endif
if(!packed)
debug << "Trade::ImageConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImageConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(Convert1D)
_c(Convert2D)
_c(Convert3D)
_c(ConvertCompressed1D)
_c(ConvertCompressed2D)
_c(ConvertCompressed3D)
_c(Convert1DToFile)
_c(Convert2DToFile)
_c(Convert3DToFile)
_c(ConvertCompressed1DToFile)
_c(ConvertCompressed2DToFile)
_c(ConvertCompressed3DToFile)
_c(Convert1DToData)
_c(Convert2DToData)
_c(Convert3DToData)
_c(ConvertCompressed1DToData)
_c(ConvertCompressed2DToData)
_c(ConvertCompressed3DToData)
_c(Levels)
#undef _c
/* LCOV_EXCL_STOP */
#ifdef MAGNUM_BUILD_DEPRECATED
/* LCOV_EXCL_START */
CORRADE_IGNORE_DEPRECATED_PUSH
case ImageConverterFeature::ConvertLevels1DToData:
case ImageConverterFeature::ConvertLevels2DToData:
case ImageConverterFeature::ConvertLevels3DToData:
case ImageConverterFeature::ConvertCompressedLevels1DToData:
case ImageConverterFeature::ConvertCompressedLevels2DToData:
case ImageConverterFeature::ConvertCompressedLevels3DToData:
case ImageConverterFeature::ConvertLevels1DToFile:
case ImageConverterFeature::ConvertLevels2DToFile:
case ImageConverterFeature::ConvertLevels3DToFile:
case ImageConverterFeature::ConvertCompressedLevels1DToFile:
case ImageConverterFeature::ConvertCompressedLevels2DToFile:
case ImageConverterFeature::ConvertCompressedLevels3DToFile:
CORRADE_INTERNAL_ASSERT_UNREACHABLE();
CORRADE_IGNORE_DEPRECATED_POP
/* LCOV_EXCL_STOP */
#endif
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedInt(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const ImageConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::ImageConverterFeatures{}", {
ImageConverterFeature::Convert1D,
ImageConverterFeature::Convert2D,
ImageConverterFeature::Convert3D,
ImageConverterFeature::ConvertCompressed1D,
ImageConverterFeature::ConvertCompressed2D,
ImageConverterFeature::ConvertCompressed3D,
ImageConverterFeature::Convert1DToData,
ImageConverterFeature::Convert2DToData,
ImageConverterFeature::Convert3DToData,
ImageConverterFeature::ConvertCompressed1DToData,
ImageConverterFeature::ConvertCompressed2DToData,
ImageConverterFeature::ConvertCompressed3DToData,
/* These 6 are implied by Convert[Compressed]ToData, so have to be
after */
ImageConverterFeature::Convert1DToFile,
ImageConverterFeature::Convert2DToFile,
ImageConverterFeature::Convert3DToFile,
ImageConverterFeature::ConvertCompressed1DToFile,
ImageConverterFeature::ConvertCompressed2DToFile,
ImageConverterFeature::ConvertCompressed3DToFile,
ImageConverterFeature::Levels});
}
Debug& operator<<(Debug& debug, const ImageConverterFlag value) {
debug << "Trade::ImageConverterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImageConverterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const ImageConverterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::ImageConverterFlags{}", {
ImageConverterFlag::Quiet,
ImageConverterFlag::Verbose});
}
}} }}

96
src/Magnum/Trade/AbstractImporter.cpp

@ -81,6 +81,55 @@ namespace Magnum { namespace Trade {
using namespace Containers::Literals; using namespace Containers::Literals;
Debug& operator<<(Debug& debug, const ImporterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::ImporterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImporterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(OpenData)
_c(OpenState)
_c(FileCallback)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const ImporterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::ImporterFeatures{}", {
ImporterFeature::OpenData,
ImporterFeature::OpenState,
ImporterFeature::FileCallback
});
}
Debug& operator<<(Debug& debug, const ImporterFlag value) {
debug << "Trade::ImporterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImporterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const ImporterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::ImporterFlags{}", {
ImporterFlag::Quiet,
ImporterFlag::Verbose
});
}
Containers::StringView AbstractImporter::pluginInterface() { Containers::StringView AbstractImporter::pluginInterface() {
return MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE ""_s; return MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE ""_s;
} }
@ -1618,51 +1667,4 @@ const void* AbstractImporter::importerState() const {
const void* AbstractImporter::doImporterState() const { return nullptr; } const void* AbstractImporter::doImporterState() const { return nullptr; }
Debug& operator<<(Debug& debug, const ImporterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::ImporterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImporterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(OpenData)
_c(OpenState)
_c(FileCallback)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const ImporterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::ImporterFeatures{}", {
ImporterFeature::OpenData,
ImporterFeature::OpenState,
ImporterFeature::FileCallback});
}
Debug& operator<<(Debug& debug, const ImporterFlag value) {
debug << "Trade::ImporterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case ImporterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const ImporterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::ImporterFlags{}", {
ImporterFlag::Quiet,
ImporterFlag::Verbose});
}
}} }}

285
src/Magnum/Trade/AbstractSceneConverter.cpp

@ -69,6 +69,150 @@ namespace Magnum { namespace Trade {
using namespace Containers::Literals; using namespace Containers::Literals;
Debug& operator<<(Debug& debug, const SceneConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case SceneConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(ConvertMesh)
_c(ConvertMeshInPlace)
_c(ConvertMeshToData)
_c(ConvertMeshToFile)
_c(ConvertMultiple)
_c(ConvertMultipleToData)
_c(ConvertMultipleToFile)
_c(AddScenes)
_c(AddAnimations)
_c(AddLights)
_c(AddCameras)
_c(AddSkins2D)
_c(AddSkins3D)
_c(AddMeshes)
_c(AddMaterials)
_c(AddTextures)
_c(AddImages1D)
_c(AddImages2D)
_c(AddImages3D)
_c(AddCompressedImages1D)
_c(AddCompressedImages2D)
_c(AddCompressedImages3D)
_c(MeshLevels)
_c(ImageLevels)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedInt(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SceneConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::SceneConverterFeatures{}", {
SceneConverterFeature::ConvertMesh,
SceneConverterFeature::ConvertMeshInPlace,
SceneConverterFeature::ConvertMeshToData,
/* Implied by ConvertMeshToData, has to be after */
SceneConverterFeature::ConvertMeshToFile,
SceneConverterFeature::ConvertMultiple,
SceneConverterFeature::ConvertMultipleToData,
/* Implied by ConvertMultipleToData, has to be after */
SceneConverterFeature::ConvertMultipleToFile,
SceneConverterFeature::AddScenes,
SceneConverterFeature::AddAnimations,
SceneConverterFeature::AddLights,
SceneConverterFeature::AddCameras,
SceneConverterFeature::AddSkins2D,
SceneConverterFeature::AddSkins3D,
SceneConverterFeature::AddMeshes,
SceneConverterFeature::AddMaterials,
SceneConverterFeature::AddTextures,
SceneConverterFeature::AddImages1D,
SceneConverterFeature::AddImages2D,
SceneConverterFeature::AddImages3D,
SceneConverterFeature::AddCompressedImages1D,
SceneConverterFeature::AddCompressedImages2D,
SceneConverterFeature::AddCompressedImages3D,
SceneConverterFeature::MeshLevels,
SceneConverterFeature::ImageLevels
});
}
Debug& operator<<(Debug& debug, const SceneConverterFlag value) {
debug << "Trade::SceneConverterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case SceneConverterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const SceneConverterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::SceneConverterFlags{}", {
SceneConverterFlag::Quiet,
SceneConverterFlag::Verbose
});
}
Debug& operator<<(Debug& debug, const SceneContent value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneContent" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case SceneContent::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(Scenes)
_c(Animations)
_c(Lights)
_c(Cameras)
_c(Skins2D)
_c(Skins3D)
_c(Meshes)
_c(Materials)
_c(Textures)
_c(Images1D)
_c(Images2D)
_c(Images3D)
_c(MeshLevels)
_c(ImageLevels)
_c(Names)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedInt(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SceneContents value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::SceneContents{}", {
SceneContent::Scenes,
SceneContent::Animations,
SceneContent::Lights,
SceneContent::Cameras,
SceneContent::Skins2D,
SceneContent::Skins3D,
SceneContent::Meshes,
SceneContent::Materials,
SceneContent::Textures,
SceneContent::Images1D,
SceneContent::Images2D,
SceneContent::Images3D,
SceneContent::MeshLevels,
SceneContent::ImageLevels,
SceneContent::Names
});
}
SceneContents sceneContentsFor(const AbstractImporter& importer) { SceneContents sceneContentsFor(const AbstractImporter& importer) {
CORRADE_ASSERT(importer.isOpened(), CORRADE_ASSERT(importer.isOpened(),
"Trade::sceneContentsFor(): the importer is not opened", {}); "Trade::sceneContentsFor(): the importer is not opened", {});
@ -1716,145 +1860,4 @@ bool AbstractSceneConverter::addSupportedImporterContents(AbstractImporter& impo
return addImporterContentsInternal(importer, used, true); return addImporterContentsInternal(importer, used, true);
} }
Debug& operator<<(Debug& debug, const SceneConverterFeature value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneConverterFeature" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case SceneConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(ConvertMesh)
_c(ConvertMeshInPlace)
_c(ConvertMeshToData)
_c(ConvertMeshToFile)
_c(ConvertMultiple)
_c(ConvertMultipleToData)
_c(ConvertMultipleToFile)
_c(AddScenes)
_c(AddAnimations)
_c(AddLights)
_c(AddCameras)
_c(AddSkins2D)
_c(AddSkins3D)
_c(AddMeshes)
_c(AddMaterials)
_c(AddTextures)
_c(AddImages1D)
_c(AddImages2D)
_c(AddImages3D)
_c(AddCompressedImages1D)
_c(AddCompressedImages2D)
_c(AddCompressedImages3D)
_c(MeshLevels)
_c(ImageLevels)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedInt(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SceneConverterFeatures value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::SceneConverterFeatures{}", {
SceneConverterFeature::ConvertMesh,
SceneConverterFeature::ConvertMeshInPlace,
SceneConverterFeature::ConvertMeshToData,
/* Implied by ConvertMeshToData, has to be after */
SceneConverterFeature::ConvertMeshToFile,
SceneConverterFeature::ConvertMultiple,
SceneConverterFeature::ConvertMultipleToData,
/* Implied by ConvertMultipleToData, has to be after */
SceneConverterFeature::ConvertMultipleToFile,
SceneConverterFeature::AddScenes,
SceneConverterFeature::AddAnimations,
SceneConverterFeature::AddLights,
SceneConverterFeature::AddCameras,
SceneConverterFeature::AddSkins2D,
SceneConverterFeature::AddSkins3D,
SceneConverterFeature::AddMeshes,
SceneConverterFeature::AddMaterials,
SceneConverterFeature::AddTextures,
SceneConverterFeature::AddImages1D,
SceneConverterFeature::AddImages2D,
SceneConverterFeature::AddImages3D,
SceneConverterFeature::AddCompressedImages1D,
SceneConverterFeature::AddCompressedImages2D,
SceneConverterFeature::AddCompressedImages3D,
SceneConverterFeature::MeshLevels,
SceneConverterFeature::ImageLevels});
}
Debug& operator<<(Debug& debug, const SceneConverterFlag value) {
debug << "Trade::SceneConverterFlag" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case SceneConverterFlag::v: return debug << "::" #v;
_c(Quiet)
_c(Verbose)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const SceneConverterFlags value) {
return Containers::enumSetDebugOutput(debug, value, "Trade::SceneConverterFlags{}", {
SceneConverterFlag::Quiet,
SceneConverterFlag::Verbose});
}
Debug& operator<<(Debug& debug, const SceneContent value) {
const bool packed = debug.immediateFlags() >= Debug::Flag::Packed;
if(!packed)
debug << "Trade::SceneContent" << Debug::nospace;
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case SceneContent::v: return debug << (packed ? "" : "::") << Debug::nospace << #v;
_c(Scenes)
_c(Animations)
_c(Lights)
_c(Cameras)
_c(Skins2D)
_c(Skins3D)
_c(Meshes)
_c(Materials)
_c(Textures)
_c(Images1D)
_c(Images2D)
_c(Images3D)
_c(MeshLevels)
_c(ImageLevels)
_c(Names)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedInt(value) << Debug::nospace << (packed ? "" : ")");
}
Debug& operator<<(Debug& debug, const SceneContents value) {
return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::SceneContents{}", {
SceneContent::Scenes,
SceneContent::Animations,
SceneContent::Lights,
SceneContent::Cameras,
SceneContent::Skins2D,
SceneContent::Skins3D,
SceneContent::Meshes,
SceneContent::Materials,
SceneContent::Textures,
SceneContent::Images1D,
SceneContent::Images2D,
SceneContent::Images3D,
SceneContent::MeshLevels,
SceneContent::ImageLevels,
SceneContent::Names});
}
}} }}

212
src/Magnum/Trade/Test/AbstractImageConverterTest.cpp

@ -46,6 +46,18 @@ namespace Magnum { namespace Trade { namespace Test { namespace {
struct AbstractImageConverterTest: TestSuite::Tester { struct AbstractImageConverterTest: TestSuite::Tester {
explicit AbstractImageConverterTest(); explicit AbstractImageConverterTest();
void debugFeature();
void debugFeaturePacked();
#ifdef MAGNUM_BUILD_DEPRECATED
void debugFeatureDeprecated();
void debugFeatureDeprecatedPacked();
#endif
void debugFeatures();
void debugFeaturesPacked();
void debugFeaturesSupersets();
void debugFlag();
void debugFlags();
void construct(); void construct();
void constructWithPluginManagerReference(); void constructWithPluginManagerReference();
@ -319,22 +331,22 @@ struct AbstractImageConverterTest: TestSuite::Tester {
void convertCompressed3DToFileThroughLevelsFailed(); void convertCompressed3DToFileThroughLevelsFailed();
/* Conversion of a compressed image to a file through levels and through /* Conversion of a compressed image to a file through levels and through
data not tested, as that should just work transitively */ data not tested, as that should just work transitively */
void debugFeature();
void debugFeaturePacked();
#ifdef MAGNUM_BUILD_DEPRECATED
void debugFeatureDeprecated();
void debugFeatureDeprecatedPacked();
#endif
void debugFeatures();
void debugFeaturesPacked();
void debugFeaturesSupersets();
void debugFlag();
void debugFlags();
}; };
AbstractImageConverterTest::AbstractImageConverterTest() { AbstractImageConverterTest::AbstractImageConverterTest() {
addTests({&AbstractImageConverterTest::construct, addTests({&AbstractImageConverterTest::debugFeature,
&AbstractImageConverterTest::debugFeaturePacked,
#ifdef MAGNUM_BUILD_DEPRECATED
&AbstractImageConverterTest::debugFeatureDeprecated,
&AbstractImageConverterTest::debugFeatureDeprecatedPacked,
#endif
&AbstractImageConverterTest::debugFeatures,
&AbstractImageConverterTest::debugFeaturesPacked,
&AbstractImageConverterTest::debugFeaturesSupersets,
&AbstractImageConverterTest::debugFlag,
&AbstractImageConverterTest::debugFlags,
&AbstractImageConverterTest::construct,
&AbstractImageConverterTest::constructWithPluginManagerReference, &AbstractImageConverterTest::constructWithPluginManagerReference,
&AbstractImageConverterTest::setFlags, &AbstractImageConverterTest::setFlags,
@ -581,24 +593,92 @@ AbstractImageConverterTest::AbstractImageConverterTest() {
&AbstractImageConverterTest::convertCompressed3DToFileThroughLevels, &AbstractImageConverterTest::convertCompressed3DToFileThroughLevels,
&AbstractImageConverterTest::convertCompressed1DToFileThroughLevelsFailed, &AbstractImageConverterTest::convertCompressed1DToFileThroughLevelsFailed,
&AbstractImageConverterTest::convertCompressed2DToFileThroughLevelsFailed, &AbstractImageConverterTest::convertCompressed2DToFileThroughLevelsFailed,
&AbstractImageConverterTest::convertCompressed3DToFileThroughLevelsFailed, &AbstractImageConverterTest::convertCompressed3DToFileThroughLevelsFailed});
&AbstractImageConverterTest::debugFeature,
&AbstractImageConverterTest::debugFeaturePacked,
#ifdef MAGNUM_BUILD_DEPRECATED
&AbstractImageConverterTest::debugFeatureDeprecated,
&AbstractImageConverterTest::debugFeatureDeprecatedPacked,
#endif
&AbstractImageConverterTest::debugFeatures,
&AbstractImageConverterTest::debugFeaturesPacked,
&AbstractImageConverterTest::debugFeaturesSupersets,
&AbstractImageConverterTest::debugFlag,
&AbstractImageConverterTest::debugFlags});
/* Create testing dir */ /* Create testing dir */
Utility::Path::make(TRADE_TEST_OUTPUT_DIR); Utility::Path::make(TRADE_TEST_OUTPUT_DIR);
} }
void AbstractImageConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << ImageConverterFeature::ConvertCompressed2D << ImageConverterFeature(0xdeadbeef);
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::ConvertCompressed2D Trade::ImageConverterFeature(0xdeadbeef)\n");
}
void AbstractImageConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImageConverterFeature::ConvertCompressed2D << Debug::packed << ImageConverterFeature(0xdeadbeef) << ImageConverterFeature::Convert3D;
CORRADE_COMPARE(out, "ConvertCompressed2D 0xdeadbeef Trade::ImageConverterFeature::Convert3D\n");
}
#ifdef MAGNUM_BUILD_DEPRECATED
void AbstractImageConverterTest::debugFeatureDeprecated() {
Containers::String out;
CORRADE_IGNORE_DEPRECATED_PUSH
Debug{&out} << ImageConverterFeature::ConvertCompressedLevels1DToData << ImageConverterFeature::ConvertLevels3DToFile;
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::ConvertCompressed1DToData|Trade::ImageConverterFeature::Levels Trade::ImageConverterFeature::Convert3DToFile|Trade::ImageConverterFeature::Levels\n");
}
void AbstractImageConverterTest::debugFeatureDeprecatedPacked() {
Containers::String out;
CORRADE_IGNORE_DEPRECATED_PUSH
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImageConverterFeature::ConvertCompressedLevels1DToData << Debug::packed << ImageConverterFeature::ConvertLevels3DToFile << ImageConverterFeature::Convert1D;
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out, "ConvertCompressed1DToData|Levels Convert3DToFile|Levels Trade::ImageConverterFeature::Convert1D\n");
}
#endif
void AbstractImageConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::ConvertCompressed2DToFile) << ImageConverterFeatures{};
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::Convert2DToData|Trade::ImageConverterFeature::ConvertCompressed2DToFile Trade::ImageConverterFeatures{}\n");
}
void AbstractImageConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::ConvertCompressed2DToFile) << Debug::packed << ImageConverterFeatures{} << ImageConverterFeature::Convert1D;
CORRADE_COMPARE(out, "Convert2DToData|ConvertCompressed2DToFile {} Trade::ImageConverterFeature::Convert1D\n");
}
void AbstractImageConverterTest::debugFeaturesSupersets() {
/* Convert*DToData is a superset of Convert*DToFile, so only one should be
printed */
{
Containers::String out;
Debug{&out} << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::Convert2DToFile);
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::Convert2DToData\n");
/* ConvertCompressed*DToData is a superset of ConvertCompressed*DToFile, so
only one should be printed */
} {
Containers::String out;
Debug{&out} << (ImageConverterFeature::ConvertCompressed1DToData|ImageConverterFeature::ConvertCompressed1DToFile);
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::ConvertCompressed1DToData\n");
}
}
void AbstractImageConverterTest::debugFlag() {
Containers::String out;
Debug{&out} << ImageConverterFlag::Verbose << ImageConverterFlag(0xf0);
CORRADE_COMPARE(out, "Trade::ImageConverterFlag::Verbose Trade::ImageConverterFlag(0xf0)\n");
}
void AbstractImageConverterTest::debugFlags() {
Containers::String out;
Debug{&out} << (ImageConverterFlag::Verbose|ImageConverterFlag(0xf0)) << ImageConverterFlags{};
CORRADE_COMPARE(out, "Trade::ImageConverterFlag::Verbose|Trade::ImageConverterFlag(0xf0) Trade::ImageConverterFlags{}\n");
}
void AbstractImageConverterTest::construct() { void AbstractImageConverterTest::construct() {
struct: AbstractImageConverter { struct: AbstractImageConverter {
ImageConverterFeatures doFeatures() const override { return {}; } ImageConverterFeatures doFeatures() const override { return {}; }
@ -5280,86 +5360,6 @@ void AbstractImageConverterTest::convertCompressed3DToFileThroughLevelsFailed()
CORRADE_COMPARE(out, ""); CORRADE_COMPARE(out, "");
} }
void AbstractImageConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << ImageConverterFeature::ConvertCompressed2D << ImageConverterFeature(0xdeadbeef);
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::ConvertCompressed2D Trade::ImageConverterFeature(0xdeadbeef)\n");
}
void AbstractImageConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImageConverterFeature::ConvertCompressed2D << Debug::packed << ImageConverterFeature(0xdeadbeef) << ImageConverterFeature::Convert3D;
CORRADE_COMPARE(out, "ConvertCompressed2D 0xdeadbeef Trade::ImageConverterFeature::Convert3D\n");
}
#ifdef MAGNUM_BUILD_DEPRECATED
void AbstractImageConverterTest::debugFeatureDeprecated() {
Containers::String out;
CORRADE_IGNORE_DEPRECATED_PUSH
Debug{&out} << ImageConverterFeature::ConvertCompressedLevels1DToData << ImageConverterFeature::ConvertLevels3DToFile;
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::ConvertCompressed1DToData|Trade::ImageConverterFeature::Levels Trade::ImageConverterFeature::Convert3DToFile|Trade::ImageConverterFeature::Levels\n");
}
void AbstractImageConverterTest::debugFeatureDeprecatedPacked() {
Containers::String out;
CORRADE_IGNORE_DEPRECATED_PUSH
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImageConverterFeature::ConvertCompressedLevels1DToData << Debug::packed << ImageConverterFeature::ConvertLevels3DToFile << ImageConverterFeature::Convert1D;
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE(out, "ConvertCompressed1DToData|Levels Convert3DToFile|Levels Trade::ImageConverterFeature::Convert1D\n");
}
#endif
void AbstractImageConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::ConvertCompressed2DToFile) << ImageConverterFeatures{};
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::Convert2DToData|Trade::ImageConverterFeature::ConvertCompressed2DToFile Trade::ImageConverterFeatures{}\n");
}
void AbstractImageConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::ConvertCompressed2DToFile) << Debug::packed << ImageConverterFeatures{} << ImageConverterFeature::Convert1D;
CORRADE_COMPARE(out, "Convert2DToData|ConvertCompressed2DToFile {} Trade::ImageConverterFeature::Convert1D\n");
}
void AbstractImageConverterTest::debugFeaturesSupersets() {
/* Convert*DToData is a superset of Convert*DToFile, so only one should be
printed */
{
Containers::String out;
Debug{&out} << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::Convert2DToFile);
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::Convert2DToData\n");
/* ConvertCompressed*DToData is a superset of ConvertCompressed*DToFile, so
only one should be printed */
} {
Containers::String out;
Debug{&out} << (ImageConverterFeature::ConvertCompressed1DToData|ImageConverterFeature::ConvertCompressed1DToFile);
CORRADE_COMPARE(out, "Trade::ImageConverterFeature::ConvertCompressed1DToData\n");
}
}
void AbstractImageConverterTest::debugFlag() {
Containers::String out;
Debug{&out} << ImageConverterFlag::Verbose << ImageConverterFlag(0xf0);
CORRADE_COMPARE(out, "Trade::ImageConverterFlag::Verbose Trade::ImageConverterFlag(0xf0)\n");
}
void AbstractImageConverterTest::debugFlags() {
Containers::String out;
Debug{&out} << (ImageConverterFlag::Verbose|ImageConverterFlag(0xf0)) << ImageConverterFlags{};
CORRADE_COMPARE(out, "Trade::ImageConverterFlag::Verbose|Trade::ImageConverterFlag(0xf0) Trade::ImageConverterFlags{}\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractImageConverterTest) CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractImageConverterTest)

114
src/Magnum/Trade/Test/AbstractImporterTest.cpp

@ -73,6 +73,13 @@ namespace Magnum { namespace Trade { namespace Test { namespace {
struct AbstractImporterTest: TestSuite::Tester { struct AbstractImporterTest: TestSuite::Tester {
explicit AbstractImporterTest(); explicit AbstractImporterTest();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void debugFlag();
void debugFlags();
void construct(); void construct();
void constructWithPluginManagerReference(); void constructWithPluginManagerReference();
@ -382,13 +389,6 @@ struct AbstractImporterTest: TestSuite::Tester {
void importerState(); void importerState();
void importerStateNotImplemented(); void importerStateNotImplemented();
void importerStateNoFile(); void importerStateNoFile();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void debugFlag();
void debugFlags();
}; };
constexpr struct { constexpr struct {
@ -402,7 +402,14 @@ constexpr struct {
using namespace Math::Literals; using namespace Math::Literals;
AbstractImporterTest::AbstractImporterTest() { AbstractImporterTest::AbstractImporterTest() {
addTests({&AbstractImporterTest::construct, addTests({&AbstractImporterTest::debugFeature,
&AbstractImporterTest::debugFeaturePacked,
&AbstractImporterTest::debugFeatures,
&AbstractImporterTest::debugFeaturesPacked,
&AbstractImporterTest::debugFlag,
&AbstractImporterTest::debugFlags,
&AbstractImporterTest::construct,
&AbstractImporterTest::constructWithPluginManagerReference, &AbstractImporterTest::constructWithPluginManagerReference,
&AbstractImporterTest::setFlags, &AbstractImporterTest::setFlags,
@ -719,14 +726,49 @@ AbstractImporterTest::AbstractImporterTest() {
&AbstractImporterTest::importerState, &AbstractImporterTest::importerState,
&AbstractImporterTest::importerStateNotImplemented, &AbstractImporterTest::importerStateNotImplemented,
&AbstractImporterTest::importerStateNoFile, &AbstractImporterTest::importerStateNoFile});
}
&AbstractImporterTest::debugFeature, void AbstractImporterTest::debugFeature() {
&AbstractImporterTest::debugFeaturePacked, Containers::String out;
&AbstractImporterTest::debugFeatures,
&AbstractImporterTest::debugFeaturesPacked, Debug{&out} << ImporterFeature::OpenData << ImporterFeature(0xf0);
&AbstractImporterTest::debugFlag, CORRADE_COMPARE(out, "Trade::ImporterFeature::OpenData Trade::ImporterFeature(0xf0)\n");
&AbstractImporterTest::debugFlags}); }
void AbstractImporterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImporterFeature::OpenData << Debug::packed << ImporterFeature(0xf0) << ImporterFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData 0xf0 Trade::ImporterFeature::FileCallback\n");
}
void AbstractImporterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (ImporterFeature::OpenData|ImporterFeature::OpenState) << ImporterFeatures{};
CORRADE_COMPARE(out, "Trade::ImporterFeature::OpenData|Trade::ImporterFeature::OpenState Trade::ImporterFeatures{}\n");
}
void AbstractImporterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (ImporterFeature::OpenData|ImporterFeature::OpenState) << Debug::packed << ImporterFeatures{} << ImporterFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData|OpenState {} Trade::ImporterFeature::FileCallback\n");
}
void AbstractImporterTest::debugFlag() {
Containers::String out;
Debug{&out} << ImporterFlag::Verbose << ImporterFlag(0xf0);
CORRADE_COMPARE(out, "Trade::ImporterFlag::Verbose Trade::ImporterFlag(0xf0)\n");
}
void AbstractImporterTest::debugFlags() {
Containers::String out;
Debug{&out} << (ImporterFlag::Verbose|ImporterFlag(0xf0)) << ImporterFlags{};
CORRADE_COMPARE(out, "Trade::ImporterFlag::Verbose|Trade::ImporterFlag(0xf0) Trade::ImporterFlags{}\n");
} }
void AbstractImporterTest::construct() { void AbstractImporterTest::construct() {
@ -8071,48 +8113,6 @@ void AbstractImporterTest::importerStateNoFile() {
CORRADE_COMPARE(out, "Trade::AbstractImporter::importerState(): no file opened\n"); CORRADE_COMPARE(out, "Trade::AbstractImporter::importerState(): no file opened\n");
} }
void AbstractImporterTest::debugFeature() {
Containers::String out;
Debug{&out} << ImporterFeature::OpenData << ImporterFeature(0xf0);
CORRADE_COMPARE(out, "Trade::ImporterFeature::OpenData Trade::ImporterFeature(0xf0)\n");
}
void AbstractImporterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << ImporterFeature::OpenData << Debug::packed << ImporterFeature(0xf0) << ImporterFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData 0xf0 Trade::ImporterFeature::FileCallback\n");
}
void AbstractImporterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (ImporterFeature::OpenData|ImporterFeature::OpenState) << ImporterFeatures{};
CORRADE_COMPARE(out, "Trade::ImporterFeature::OpenData|Trade::ImporterFeature::OpenState Trade::ImporterFeatures{}\n");
}
void AbstractImporterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (ImporterFeature::OpenData|ImporterFeature::OpenState) << Debug::packed << ImporterFeatures{} << ImporterFeature::FileCallback;
CORRADE_COMPARE(out, "OpenData|OpenState {} Trade::ImporterFeature::FileCallback\n");
}
void AbstractImporterTest::debugFlag() {
Containers::String out;
Debug{&out} << ImporterFlag::Verbose << ImporterFlag(0xf0);
CORRADE_COMPARE(out, "Trade::ImporterFlag::Verbose Trade::ImporterFlag(0xf0)\n");
}
void AbstractImporterTest::debugFlags() {
Containers::String out;
Debug{&out} << (ImporterFlag::Verbose|ImporterFlag(0xf0)) << ImporterFlags{};
CORRADE_COMPARE(out, "Trade::ImporterFlag::Verbose|Trade::ImporterFlag(0xf0) Trade::ImporterFlags{}\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractImporterTest) CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractImporterTest)

226
src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp

@ -59,6 +59,18 @@ namespace Magnum { namespace Trade { namespace Test { namespace {
struct AbstractSceneConverterTest: TestSuite::Tester { struct AbstractSceneConverterTest: TestSuite::Tester {
explicit AbstractSceneConverterTest(); explicit AbstractSceneConverterTest();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void debugFeaturesSupersets();
void debugFlag();
void debugFlags();
void debugContent();
void debugContentPacked();
void debugContents();
void debugContentsPacked();
void sceneContentsForImporterNone(); void sceneContentsForImporterNone();
void sceneContentsForImporterAll(); void sceneContentsForImporterAll();
void sceneContentsForImporterNotOpened(); void sceneContentsForImporterNotOpened();
@ -307,18 +319,6 @@ struct AbstractSceneConverterTest: TestSuite::Tester {
void addSupportedImporterContents(); void addSupportedImporterContents();
void addSupportedImporterContentsLevels(); void addSupportedImporterContentsLevels();
void addSupportedImporterContentsNotOpened(); void addSupportedImporterContentsNotOpened();
void debugFeature();
void debugFeaturePacked();
void debugFeatures();
void debugFeaturesPacked();
void debugFeaturesSupersets();
void debugFlag();
void debugFlags();
void debugContent();
void debugContentPacked();
void debugContents();
void debugContentsPacked();
}; };
using namespace Containers::Literals; using namespace Containers::Literals;
@ -631,7 +631,19 @@ const struct {
}; };
AbstractSceneConverterTest::AbstractSceneConverterTest() { AbstractSceneConverterTest::AbstractSceneConverterTest() {
addTests({&AbstractSceneConverterTest::sceneContentsForImporterNone, addTests({&AbstractSceneConverterTest::debugFeature,
&AbstractSceneConverterTest::debugFeaturePacked,
&AbstractSceneConverterTest::debugFeatures,
&AbstractSceneConverterTest::debugFeaturesPacked,
&AbstractSceneConverterTest::debugFeaturesSupersets,
&AbstractSceneConverterTest::debugFlag,
&AbstractSceneConverterTest::debugFlags,
&AbstractSceneConverterTest::debugContent,
&AbstractSceneConverterTest::debugContentPacked,
&AbstractSceneConverterTest::debugContents,
&AbstractSceneConverterTest::debugContentsPacked,
&AbstractSceneConverterTest::sceneContentsForImporterNone,
&AbstractSceneConverterTest::sceneContentsForImporterAll, &AbstractSceneConverterTest::sceneContentsForImporterAll,
&AbstractSceneConverterTest::sceneContentsForImporterNotOpened, &AbstractSceneConverterTest::sceneContentsForImporterNotOpened,
@ -877,24 +889,99 @@ AbstractSceneConverterTest::AbstractSceneConverterTest() {
Containers::arraySize(AddSupportedImporterContentsData)); Containers::arraySize(AddSupportedImporterContentsData));
addTests({&AbstractSceneConverterTest::addSupportedImporterContentsNotOpened, addTests({&AbstractSceneConverterTest::addSupportedImporterContentsNotOpened,
&AbstractSceneConverterTest::addSupportedImporterContentsLevels, &AbstractSceneConverterTest::addSupportedImporterContentsLevels});
&AbstractSceneConverterTest::debugFeature,
&AbstractSceneConverterTest::debugFeaturePacked,
&AbstractSceneConverterTest::debugFeatures,
&AbstractSceneConverterTest::debugFeaturesPacked,
&AbstractSceneConverterTest::debugFeaturesSupersets,
&AbstractSceneConverterTest::debugFlag,
&AbstractSceneConverterTest::debugFlags,
&AbstractSceneConverterTest::debugContent,
&AbstractSceneConverterTest::debugContentPacked,
&AbstractSceneConverterTest::debugContents,
&AbstractSceneConverterTest::debugContentsPacked});
/* Create testing dir */ /* Create testing dir */
Utility::Path::make(TRADE_TEST_OUTPUT_DIR); Utility::Path::make(TRADE_TEST_OUTPUT_DIR);
} }
void AbstractSceneConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << SceneConverterFeature::ConvertMeshInPlace << SceneConverterFeature(0xdeaddead);
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMeshInPlace Trade::SceneConverterFeature(0xdeaddead)\n");
}
void AbstractSceneConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << SceneConverterFeature::ConvertMeshInPlace << Debug::packed << SceneConverterFeature(0xdeaddead) << SceneConverterFeature::AddCameras;
CORRADE_COMPARE(out, "ConvertMeshInPlace 0xdeaddead Trade::SceneConverterFeature::AddCameras\n");
}
void AbstractSceneConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (SceneConverterFeature::ConvertMesh|SceneConverterFeature::ConvertMeshToFile) << SceneConverterFeatures{};
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMesh|Trade::SceneConverterFeature::ConvertMeshToFile Trade::SceneConverterFeatures{}\n");
}
void AbstractSceneConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (SceneConverterFeature::ConvertMesh|SceneConverterFeature::ConvertMeshToFile) << Debug::packed << SceneConverterFeatures{} << SceneConverterFeature::AddLights;
CORRADE_COMPARE(out, "ConvertMesh|ConvertMeshToFile {} Trade::SceneConverterFeature::AddLights\n");
}
void AbstractSceneConverterTest::debugFeaturesSupersets() {
/* ConvertMeshToData is a superset of ConvertMeshToFile, so only one should
be printed */
{
Containers::String out;
Debug{&out} << (SceneConverterFeature::ConvertMeshToData|SceneConverterFeature::ConvertMeshToFile);
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMeshToData\n");
/* ConvertMultipleToData is a superset of ConvertMultipleToFile, so only
one should be printed */
} {
Containers::String out;
Debug{&out} << (SceneConverterFeature::ConvertMultipleToData|SceneConverterFeature::ConvertMultipleToFile);
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMultipleToData\n");
}
}
void AbstractSceneConverterTest::debugFlag() {
Containers::String out;
Debug{&out} << SceneConverterFlag::Verbose << SceneConverterFlag(0xf0);
CORRADE_COMPARE(out, "Trade::SceneConverterFlag::Verbose Trade::SceneConverterFlag(0xf0)\n");
}
void AbstractSceneConverterTest::debugFlags() {
Containers::String out;
Debug{&out} << (SceneConverterFlag::Verbose|SceneConverterFlag(0xf0)) << SceneConverterFlags{};
CORRADE_COMPARE(out, "Trade::SceneConverterFlag::Verbose|Trade::SceneConverterFlag(0xf0) Trade::SceneConverterFlags{}\n");
}
void AbstractSceneConverterTest::debugContent() {
Containers::String out;
Debug{&out} << SceneContent::Skins3D << SceneContent(0xdeaddead);
CORRADE_COMPARE(out, "Trade::SceneContent::Skins3D Trade::SceneContent(0xdeaddead)\n");
}
void AbstractSceneConverterTest::debugContentPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << SceneContent::Animations << Debug::packed << SceneContent(0xdeaddead) << SceneContent::Cameras;
CORRADE_COMPARE(out, "Animations 0xdeaddead Trade::SceneContent::Cameras\n");
}
void AbstractSceneConverterTest::debugContents() {
Containers::String out;
Debug{&out} << (SceneContent::Animations|SceneContent::MeshLevels) << SceneConverterFeatures{};
CORRADE_COMPARE(out, "Trade::SceneContent::Animations|Trade::SceneContent::MeshLevels Trade::SceneConverterFeatures{}\n");
}
void AbstractSceneConverterTest::debugContentsPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (SceneContent::Animations|SceneContent::MeshLevels) << Debug::packed << SceneConverterFeatures{} << SceneContent::Lights;
CORRADE_COMPARE(out, "Animations|MeshLevels {} Trade::SceneContent::Lights\n");
}
void AbstractSceneConverterTest::sceneContentsForImporterNone() { void AbstractSceneConverterTest::sceneContentsForImporterNone() {
struct: AbstractImporter { struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; } ImporterFeatures doFeatures() const override { return {}; }
@ -7877,93 +7964,6 @@ void AbstractSceneConverterTest::addSupportedImporterContentsNotOpened() {
CORRADE_COMPARE(out, "Trade::AbstractSceneConverter::addSupportedImporterContents(): the importer is not opened\n"); CORRADE_COMPARE(out, "Trade::AbstractSceneConverter::addSupportedImporterContents(): the importer is not opened\n");
} }
void AbstractSceneConverterTest::debugFeature() {
Containers::String out;
Debug{&out} << SceneConverterFeature::ConvertMeshInPlace << SceneConverterFeature(0xdeaddead);
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMeshInPlace Trade::SceneConverterFeature(0xdeaddead)\n");
}
void AbstractSceneConverterTest::debugFeaturePacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << SceneConverterFeature::ConvertMeshInPlace << Debug::packed << SceneConverterFeature(0xdeaddead) << SceneConverterFeature::AddCameras;
CORRADE_COMPARE(out, "ConvertMeshInPlace 0xdeaddead Trade::SceneConverterFeature::AddCameras\n");
}
void AbstractSceneConverterTest::debugFeatures() {
Containers::String out;
Debug{&out} << (SceneConverterFeature::ConvertMesh|SceneConverterFeature::ConvertMeshToFile) << SceneConverterFeatures{};
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMesh|Trade::SceneConverterFeature::ConvertMeshToFile Trade::SceneConverterFeatures{}\n");
}
void AbstractSceneConverterTest::debugFeaturesPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (SceneConverterFeature::ConvertMesh|SceneConverterFeature::ConvertMeshToFile) << Debug::packed << SceneConverterFeatures{} << SceneConverterFeature::AddLights;
CORRADE_COMPARE(out, "ConvertMesh|ConvertMeshToFile {} Trade::SceneConverterFeature::AddLights\n");
}
void AbstractSceneConverterTest::debugFeaturesSupersets() {
/* ConvertMeshToData is a superset of ConvertMeshToFile, so only one should
be printed */
{
Containers::String out;
Debug{&out} << (SceneConverterFeature::ConvertMeshToData|SceneConverterFeature::ConvertMeshToFile);
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMeshToData\n");
/* ConvertMultipleToData is a superset of ConvertMultipleToFile, so only
one should be printed */
} {
Containers::String out;
Debug{&out} << (SceneConverterFeature::ConvertMultipleToData|SceneConverterFeature::ConvertMultipleToFile);
CORRADE_COMPARE(out, "Trade::SceneConverterFeature::ConvertMultipleToData\n");
}
}
void AbstractSceneConverterTest::debugFlag() {
Containers::String out;
Debug{&out} << SceneConverterFlag::Verbose << SceneConverterFlag(0xf0);
CORRADE_COMPARE(out, "Trade::SceneConverterFlag::Verbose Trade::SceneConverterFlag(0xf0)\n");
}
void AbstractSceneConverterTest::debugFlags() {
Containers::String out;
Debug{&out} << (SceneConverterFlag::Verbose|SceneConverterFlag(0xf0)) << SceneConverterFlags{};
CORRADE_COMPARE(out, "Trade::SceneConverterFlag::Verbose|Trade::SceneConverterFlag(0xf0) Trade::SceneConverterFlags{}\n");
}
void AbstractSceneConverterTest::debugContent() {
Containers::String out;
Debug{&out} << SceneContent::Skins3D << SceneContent(0xdeaddead);
CORRADE_COMPARE(out, "Trade::SceneContent::Skins3D Trade::SceneContent(0xdeaddead)\n");
}
void AbstractSceneConverterTest::debugContentPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << SceneContent::Animations << Debug::packed << SceneContent(0xdeaddead) << SceneContent::Cameras;
CORRADE_COMPARE(out, "Animations 0xdeaddead Trade::SceneContent::Cameras\n");
}
void AbstractSceneConverterTest::debugContents() {
Containers::String out;
Debug{&out} << (SceneContent::Animations|SceneContent::MeshLevels) << SceneConverterFeatures{};
CORRADE_COMPARE(out, "Trade::SceneContent::Animations|Trade::SceneContent::MeshLevels Trade::SceneConverterFeatures{}\n");
}
void AbstractSceneConverterTest::debugContentsPacked() {
Containers::String out;
/* Last is not packed, ones before should not make any flags persistent */
Debug{&out} << Debug::packed << (SceneContent::Animations|SceneContent::MeshLevels) << Debug::packed << SceneConverterFeatures{} << SceneContent::Lights;
CORRADE_COMPARE(out, "Animations|MeshLevels {} Trade::SceneContent::Lights\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractSceneConverterTest) CORRADE_TEST_MAIN(Magnum::Trade::Test::AbstractSceneConverterTest)

Loading…
Cancel
Save