Browse Source

ShaderTools,Text,Trade: improve construction tests.

In some cases the plugin manager constructor was not tested at all,
leading to an uncovered line. For importers also verify that calling
close() on a non-opened instance doesn't call into doClose().

Again, the Audio importer isn't touched at all, as that interface is
scheduled for mergin into Trade.
pull/482/merge
Vladimír Vondruš 2 weeks ago
parent
commit
603f87fadc
  1. 36
      src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp
  2. 16
      src/Magnum/Text/Test/AbstractFontConverterTest.cpp
  3. 5
      src/Magnum/Text/Test/AbstractFontTest.cpp
  4. 5
      src/Magnum/Trade/Test/AbstractImporterTest.cpp
  5. 32
      src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp

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

@ -47,6 +47,9 @@ namespace Magnum { namespace ShaderTools { namespace Test { namespace {
struct AbstractConverterTest: TestSuite::Tester {
explicit AbstractConverterTest();
void construct();
void constructWithPluginManagerReference();
void featuresNone();
void setFlags();
@ -204,6 +207,9 @@ struct AbstractConverterTest: TestSuite::Tester {
AbstractConverterTest::AbstractConverterTest() {
addTests({&AbstractConverterTest::featuresNone,
&AbstractConverterTest::construct,
&AbstractConverterTest::constructWithPluginManagerReference,
&AbstractConverterTest::setFlags,
&AbstractConverterTest::setFlagsBothQuietAndVerbose,
&AbstractConverterTest::setFlagsPreprocessNotSupported,
@ -359,6 +365,36 @@ AbstractConverterTest::AbstractConverterTest() {
Utility::Path::make(SHADERTOOLS_TEST_OUTPUT_DIR);
}
void AbstractConverterTest::construct() {
struct: AbstractConverter {
ConverterFeatures doFeatures() const override {
return ConverterFeature::ValidateData;
}
void doSetInputFormat(Format, Containers::StringView) override {}
void doSetOutputFormat(Format, Containers::StringView) override {}
} converter;
CORRADE_COMPARE(converter.features(), ConverterFeature::ValidateData);
CORRADE_COMPARE(converter.flags(), ConverterFlags{});
}
void AbstractConverterTest::constructWithPluginManagerReference() {
PluginManager::Manager<AbstractConverter> manager;
struct Converter: AbstractConverter {
explicit Converter(PluginManager::Manager<AbstractConverter>& manager): AbstractConverter{manager} {}
ConverterFeatures doFeatures() const override {
return ConverterFeature::ValidateFile;
}
void doSetInputFormat(Format, Containers::StringView) override {}
void doSetOutputFormat(Format, Containers::StringView) override {}
} converter{manager};
CORRADE_COMPARE(converter.features(), ConverterFeature::ValidateFile);
CORRADE_COMPARE(converter.flags(), ConverterFlags{});
}
void AbstractConverterTest::featuresNone() {
CORRADE_SKIP_IF_NO_ASSERT();

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

@ -48,6 +48,8 @@ namespace Magnum { namespace Text { namespace Test { namespace {
struct AbstractFontConverterTest: TestSuite::Tester {
explicit AbstractFontConverterTest();
void construct();
void convertGlyphs();
void thingNotSupported();
@ -112,7 +114,9 @@ struct AbstractFontConverterTest: TestSuite::Tester {
};
AbstractFontConverterTest::AbstractFontConverterTest() {
addTests({&AbstractFontConverterTest::convertGlyphs,
addTests({&AbstractFontConverterTest::construct,
&AbstractFontConverterTest::convertGlyphs,
&AbstractFontConverterTest::thingNotSupported,
@ -178,6 +182,16 @@ AbstractFontConverterTest::AbstractFontConverterTest() {
Utility::Path::make(TEXT_TEST_OUTPUT_DIR);
}
void AbstractFontConverterTest::construct() {
struct: AbstractFontConverter {
FontConverterFeatures doFeatures() const override {
return FontConverterFeature::ConvertData;
}
} converter;
CORRADE_COMPARE(converter.features(), FontConverterFeature::ConvertData);
}
struct DummyFont: AbstractFont {
FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; }

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

@ -222,7 +222,9 @@ void AbstractFontTest::construct() {
struct: AbstractFont {
FontFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; }
void doClose() override {}
void doClose() override {
CORRADE_FAIL("This should not be called");
}
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; }
@ -233,6 +235,7 @@ void AbstractFontTest::construct() {
CORRADE_COMPARE(font.features(), FontFeatures{});
CORRADE_VERIFY(!font.isOpened());
/* This should be a no-op with doClose() not called at all */
font.close();
CORRADE_VERIFY(!font.isOpened());
}

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

@ -733,12 +733,15 @@ void AbstractImporterTest::construct() {
struct: AbstractImporter {
ImporterFeatures doFeatures() const override { return {}; }
bool doIsOpened() const override { return false; }
void doClose() override {}
void doClose() override {
CORRADE_FAIL("This should not be called");
}
} importer;
CORRADE_COMPARE(importer.features(), ImporterFeatures{});
CORRADE_VERIFY(!importer.isOpened());
/* This should be a no-op with doClose() not called at all */
importer.close();
CORRADE_VERIFY(!importer.isOpened());
}

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

@ -67,6 +67,9 @@ struct AbstractSceneConverterTest: TestSuite::Tester {
void sceneContentsForConverterSingleMesh();
void sceneContentsForConverterAll();
void construct();
void constructWithPluginManagerReference();
void featuresNone();
void setFlags();
@ -636,6 +639,9 @@ AbstractSceneConverterTest::AbstractSceneConverterTest() {
&AbstractSceneConverterTest::sceneContentsForConverterSingleMesh,
&AbstractSceneConverterTest::sceneContentsForConverterAll,
&AbstractSceneConverterTest::construct,
&AbstractSceneConverterTest::constructWithPluginManagerReference,
&AbstractSceneConverterTest::featuresNone,
&AbstractSceneConverterTest::setFlags,
@ -1014,6 +1020,32 @@ void AbstractSceneConverterTest::sceneContentsForConverterAll() {
SceneContent::Names);
}
void AbstractSceneConverterTest::construct() {
struct: AbstractSceneConverter {
SceneConverterFeatures doFeatures() const override {
return SceneConverterFeature::ConvertMeshInPlace;
}
} converter;
CORRADE_COMPARE(converter.features(), SceneConverterFeature::ConvertMeshInPlace);
CORRADE_COMPARE(converter.flags(), SceneConverterFlags{});
}
void AbstractSceneConverterTest::constructWithPluginManagerReference() {
PluginManager::Manager<AbstractSceneConverter> manager;
struct Converter: AbstractSceneConverter {
explicit Converter(PluginManager::Manager<AbstractSceneConverter>& manager): AbstractSceneConverter{manager} {}
SceneConverterFeatures doFeatures() const override {
return SceneConverterFeature::ConvertMesh;
}
} converter{manager};
CORRADE_COMPARE(converter.features(), SceneConverterFeature::ConvertMesh);
CORRADE_COMPARE(converter.flags(), SceneConverterFlags{});
}
void AbstractSceneConverterTest::featuresNone() {
CORRADE_SKIP_IF_NO_ASSERT();

Loading…
Cancel
Save