diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index 72a02d4d6..5828b066f 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -129,7 +129,7 @@ bool AbstractFontConverter::exportFontToFile(AbstractFont& font, AbstractGlyphCa bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, AbstractGlyphCache& cache, const std::string& filename, const std::u32string& characters) const { CORRADE_ASSERT(features() & FontConverterFeature::ConvertData, - "Text::AbstractFontConverter::exportFontToFile(): not implemented", false); + "Text::AbstractFontConverter::exportFontToFile(): feature advertised but not implemented", {}); /* Export all data */ const auto data = doExportFontToData(font, cache, filename, characters); @@ -181,7 +181,7 @@ bool AbstractFontConverter::exportGlyphCacheToFile(AbstractGlyphCache& cache, co bool AbstractFontConverter::doExportGlyphCacheToFile(AbstractGlyphCache& cache, const std::string& filename) const { CORRADE_ASSERT(features() & FontConverterFeature::ConvertData, - "Text::AbstractFontConverter::exportGlyphCacheToFile(): not implemented", false); + "Text::AbstractFontConverter::exportGlyphCacheToFile(): feature advertised but not implemented", {}); /* Export all data */ const auto data = doExportGlyphCacheToData(cache, filename); @@ -235,7 +235,7 @@ Containers::Pointer AbstractFontConverter::importGlyphCacheF Containers::Pointer AbstractFontConverter::doImportGlyphCacheFromFile(const std::string& filename) const { CORRADE_ASSERT(features() & FontConverterFeature::ConvertData && !(features() & FontConverterFeature::MultiFile), - "Text::AbstractFontConverter::importGlyphCacheFromFile(): not implemented", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromFile(): feature advertised but not implemented", {}); /* Open file */ if(!Utility::Directory::exists(filename)) { diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index 8ccfc7a3b..8eb876791 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -26,12 +26,12 @@ find_package(Corrade REQUIRED PluginManager) # Files shared between main library and unit test library -set(MagnumText_SRCS - AbstractFontConverter.cpp) +set(MagnumText_SRCS ) # Files compiled with different flags for main library and unit test library set(MagnumText_GracefulAssert_SRCS AbstractFont.cpp + AbstractFontConverter.cpp AbstractGlyphCache.cpp) set(MagnumText_HEADERS @@ -52,6 +52,9 @@ if(TARGET_GL) DistanceFieldGlyphCache.h GlyphCache.h Renderer.h) +else() + # So MagnumTextObjects has at least something + list(APPEND MagnumText_SRCS ${PROJECT_SOURCE_DIR}/src/dummy.cpp) endif() if(NOT CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT) diff --git a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp index d78fa781a..7e9bd49c4 100644 --- a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp @@ -45,27 +45,49 @@ struct AbstractFontConverterTest: TestSuite::Tester { void convertGlyphs(); void exportFontToSingleData(); + void exportFontToSingleDataNotSupported(); + void exportFontToSingleDataNotImplemented(); + void exportFontToSingleDataNotSingleFile(); void exportFontToData(); + void exportFontToDataNotSupported(); + void exportFontToDataNotImplemented(); void exportFontToDataThroughSingleData(); void exportFontToDataThroughSingleDataFailed(); void exportFontToFile(); + void exportFontToFileNotSupported(); + void exportFontToFileNotImplemented(); void exportFontToFileThroughData(); void exportFontToFileThroughDataFailed(); void exportFontToFileThroughDataNotWritable(); void exportGlyphCacheToSingleData(); + void exportGlyphCacheToSingleDataNotSupported(); + void exportGlyphCacheToSingleDataNotImplemented(); + void exportGlyphCacheToSingleDataNotSingleFile(); void exportGlyphCacheToData(); + void exportGlyphCacheToDataNotSupported(); + void exportGlyphCacheToDataNotImplemented(); void exportGlyphCacheToDataThroughSingleData(); void exportGlyphCacheToDataThroughSingleDataFailed(); void exportGlyphCacheToFile(); + void exportGlyphCacheToFileNotSupported(); + void exportGlyphCacheToFileNotImplemented(); void exportGlyphCacheToFileThroughData(); void exportGlyphCacheToFileThroughDataFailed(); void exportGlyphCacheToFileThroughDataNotWritable(); void importGlyphCacheFromSingleData(); + void importGlyphCacheFromSingleDataNotSupported(); + void importGlyphCacheFromSingleDataNotImplemented(); + void importGlyphCacheFromSingleDataNotSingleFile(); void importGlyphCacheFromData(); + void importGlyphCacheFromDataNoData(); + void importGlyphCacheFromDataNotSupported(); + void importGlyphCacheFromDataNotImplemented(); void importGlyphCacheFromDataAsSingleData(); void importGlyphCacheFromFile(); + void importGlyphCacheFromFileNotSupported(); + void importGlyphCacheFromFileNotImplemented(); void importGlyphCacheFromFileAsSingleData(); void importGlyphCacheFromFileAsSingleDataNotFound(); @@ -77,27 +99,49 @@ AbstractFontConverterTest::AbstractFontConverterTest() { addTests({&AbstractFontConverterTest::convertGlyphs, &AbstractFontConverterTest::exportFontToSingleData, + &AbstractFontConverterTest::exportFontToSingleDataNotSupported, + &AbstractFontConverterTest::exportFontToSingleDataNotImplemented, + &AbstractFontConverterTest::exportFontToSingleDataNotSingleFile, &AbstractFontConverterTest::exportFontToData, + &AbstractFontConverterTest::exportFontToDataNotSupported, + &AbstractFontConverterTest::exportFontToDataNotImplemented, &AbstractFontConverterTest::exportFontToDataThroughSingleData, &AbstractFontConverterTest::exportFontToDataThroughSingleDataFailed, &AbstractFontConverterTest::exportFontToFile, + &AbstractFontConverterTest::exportFontToFileNotSupported, + &AbstractFontConverterTest::exportFontToFileNotImplemented, &AbstractFontConverterTest::exportFontToFileThroughData, &AbstractFontConverterTest::exportFontToFileThroughDataFailed, &AbstractFontConverterTest::exportFontToFileThroughDataNotWritable, &AbstractFontConverterTest::exportGlyphCacheToSingleData, + &AbstractFontConverterTest::exportGlyphCacheToSingleDataNotSupported, + &AbstractFontConverterTest::exportGlyphCacheToSingleDataNotImplemented, + &AbstractFontConverterTest::exportGlyphCacheToSingleDataNotSingleFile, &AbstractFontConverterTest::exportGlyphCacheToData, + &AbstractFontConverterTest::exportGlyphCacheToDataNotSupported, + &AbstractFontConverterTest::exportGlyphCacheToDataNotImplemented, &AbstractFontConverterTest::exportGlyphCacheToDataThroughSingleData, &AbstractFontConverterTest::exportGlyphCacheToDataThroughSingleDataFailed, &AbstractFontConverterTest::exportGlyphCacheToFile, + &AbstractFontConverterTest::exportGlyphCacheToFileNotSupported, + &AbstractFontConverterTest::exportGlyphCacheToFileNotImplemented, &AbstractFontConverterTest::exportGlyphCacheToFileThroughData, &AbstractFontConverterTest::exportGlyphCacheToFileThroughDataFailed, &AbstractFontConverterTest::exportGlyphCacheToFileThroughDataNotWritable, &AbstractFontConverterTest::importGlyphCacheFromSingleData, + &AbstractFontConverterTest::importGlyphCacheFromSingleDataNotSupported, + &AbstractFontConverterTest::importGlyphCacheFromSingleDataNotImplemented, + &AbstractFontConverterTest::importGlyphCacheFromSingleDataNotSingleFile, &AbstractFontConverterTest::importGlyphCacheFromData, + &AbstractFontConverterTest::importGlyphCacheFromDataNoData, + &AbstractFontConverterTest::importGlyphCacheFromDataNotSupported, + &AbstractFontConverterTest::importGlyphCacheFromDataNotImplemented, &AbstractFontConverterTest::importGlyphCacheFromDataAsSingleData, &AbstractFontConverterTest::importGlyphCacheFromFile, + &AbstractFontConverterTest::importGlyphCacheFromFileNotSupported, + &AbstractFontConverterTest::importGlyphCacheFromFileNotImplemented, &AbstractFontConverterTest::importGlyphCacheFromFileAsSingleData, &AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataNotFound, @@ -165,6 +209,57 @@ void AbstractFontConverterTest::exportFontToSingleData() { TestSuite::Compare::Container); } +void AbstractFontConverterTest::exportFontToSingleDataNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportFont; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportFontToSingleData(dummyFont, dummyGlyphCache, {}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToSingleData(): feature not supported\n"); +} + +void AbstractFontConverterTest::exportFontToSingleDataNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ConvertData|FontConverterFeature::ExportFont; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportFontToSingleData(dummyFont, dummyGlyphCache, {}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToSingleData(): feature advertised but not implemented\n"); +} + +void AbstractFontConverterTest::exportFontToSingleDataNotSingleFile() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ConvertData|FontConverterFeature::ExportFont|FontConverterFeature::MultiFile; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportFontToSingleData(dummyFont, dummyGlyphCache, {}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToSingleData(): the format is not single-file\n"); +} + void AbstractFontConverterTest::exportFontToData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -192,6 +287,42 @@ void AbstractFontConverterTest::exportFontToData() { TestSuite::Compare::Container); } +void AbstractFontConverterTest::exportFontToDataNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportFont; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportFontToData(dummyFont, dummyGlyphCache, "font.out", {}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToData(): feature not supported\n"); +} + +void AbstractFontConverterTest::exportFontToDataNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + /* MultiFile, otherwise it'd proxy through SingleData where the + assertion is already tested */ + return FontConverterFeature::ConvertData|FontConverterFeature::ExportFont|FontConverterFeature::MultiFile; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportFontToData(dummyFont, dummyGlyphCache, "font.out", {}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented\n"); +} + void AbstractFontConverterTest::exportFontToDataThroughSingleData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -255,6 +386,40 @@ void AbstractFontConverterTest::exportFontToFile() { "\xfe\x02", TestSuite::Compare::FileToString); } +void AbstractFontConverterTest::exportFontToFileNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportFontToFile(dummyFont, dummyGlyphCache, "file.out", {}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToFile(): feature not supported\n"); +} + +void AbstractFontConverterTest::exportFontToFileNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportFont; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportFontToFile(dummyFont, dummyGlyphCache, "file.out", {}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportFontToFile(): feature advertised but not implemented\n"); +} + void AbstractFontConverterTest::exportFontToFileThroughData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -346,6 +511,57 @@ void AbstractFontConverterTest::exportGlyphCacheToSingleData() { TestSuite::Compare::Container); } +void AbstractFontConverterTest::exportGlyphCacheToSingleDataNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportGlyphCacheToSingleData(dummyGlyphCache); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature not supported\n"); +} + +void AbstractFontConverterTest::exportGlyphCacheToSingleDataNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ConvertData|FontConverterFeature::ExportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportGlyphCacheToSingleData(dummyGlyphCache); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature advertised but not implemented\n"); +} + +void AbstractFontConverterTest::exportGlyphCacheToSingleDataNotSingleFile() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ConvertData|FontConverterFeature::ExportGlyphCache|FontConverterFeature::MultiFile; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportGlyphCacheToSingleData(dummyGlyphCache); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): the format is not single-file\n"); +} + void AbstractFontConverterTest::exportGlyphCacheToData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -372,6 +588,42 @@ void AbstractFontConverterTest::exportGlyphCacheToData() { TestSuite::Compare::Container); } +void AbstractFontConverterTest::exportGlyphCacheToDataNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportGlyphCacheToData(dummyGlyphCache, "cache.out"); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported\n"); +} + +void AbstractFontConverterTest::exportGlyphCacheToDataNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + /* MultiFile, otherwise it'd proxy through SingleData where the + assertion is already tested */ + return FontConverterFeature::ConvertData|FontConverterFeature::ExportGlyphCache|FontConverterFeature::MultiFile; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportGlyphCacheToData(dummyGlyphCache, "cache.out"); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToData(): feature advertised but not implemented\n"); +} + void AbstractFontConverterTest::exportGlyphCacheToDataThroughSingleData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -436,6 +688,40 @@ void AbstractFontConverterTest::exportGlyphCacheToFile() { "\xfe\xed", TestSuite::Compare::FileToString); } +void AbstractFontConverterTest::exportGlyphCacheToFileNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportFont; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportGlyphCacheToFile(dummyGlyphCache, "cache.out"); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToFile(): feature not supported\n"); +} + +void AbstractFontConverterTest::exportGlyphCacheToFileNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.exportGlyphCacheToFile(dummyGlyphCache, "cache.out"); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::exportGlyphCacheToFile(): feature advertised but not implemented\n"); +} + void AbstractFontConverterTest::exportGlyphCacheToFileThroughData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -527,6 +813,57 @@ void AbstractFontConverterTest::importGlyphCacheFromSingleData() { CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345})); } +void AbstractFontConverterTest::importGlyphCacheFromSingleDataNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ImportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromSingleData({}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported\n"); +} + +void AbstractFontConverterTest::importGlyphCacheFromSingleDataNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ConvertData|FontConverterFeature::ImportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromSingleData({}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature advertised but not implemented\n"); +} + +void AbstractFontConverterTest::importGlyphCacheFromSingleDataNotSingleFile() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ConvertData|FontConverterFeature::ImportGlyphCache|FontConverterFeature::MultiFile; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromSingleData({}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): the format is not single-file\n"); +} + void AbstractFontConverterTest::importGlyphCacheFromData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -546,6 +883,59 @@ void AbstractFontConverterTest::importGlyphCacheFromData() { CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345})); } +void AbstractFontConverterTest::importGlyphCacheFromDataNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ImportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromData({{}}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported\n"); +} + +void AbstractFontConverterTest::importGlyphCacheFromDataNoData() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ConvertData|FontConverterFeature::ImportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromData({}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromData(): no data passed\n"); +} + +void AbstractFontConverterTest::importGlyphCacheFromDataNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + /* MultiFile, otherwise it'd proxy through SingleData where the + assertion is already tested */ + return FontConverterFeature::ConvertData|FontConverterFeature::ImportGlyphCache|FontConverterFeature::MultiFile; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromData({{}}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromData(): feature advertised but not implemented\n"); +} + void AbstractFontConverterTest::importGlyphCacheFromDataAsSingleData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { @@ -584,6 +974,40 @@ void AbstractFontConverterTest::importGlyphCacheFromFile() { CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345})); } +void AbstractFontConverterTest::importGlyphCacheFromFileNotSupported() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ExportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromFile({}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromFile(): feature not supported\n"); +} + +void AbstractFontConverterTest::importGlyphCacheFromFileNotImplemented() { + #ifdef CORRADE_NO_ASSERT + CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); + #endif + + struct: AbstractFontConverter { + FontConverterFeatures doFeatures() const override { + return FontConverterFeature::ImportGlyphCache; + } + } converter; + + std::ostringstream out; + Error redirectError{&out}; + converter.importGlyphCacheFromFile({}); + CORRADE_COMPARE(out.str(), "Text::AbstractFontConverter::importGlyphCacheFromFile(): feature advertised but not implemented\n"); +} + void AbstractFontConverterTest::importGlyphCacheFromFileAsSingleData() { struct: AbstractFontConverter { FontConverterFeatures doFeatures() const override { diff --git a/src/Magnum/Text/Test/CMakeLists.txt b/src/Magnum/Text/Test/CMakeLists.txt index 32d37b31c..f0da9ce54 100644 --- a/src/Magnum/Text/Test/CMakeLists.txt +++ b/src/Magnum/Text/Test/CMakeLists.txt @@ -39,7 +39,7 @@ corrade_add_test(TextAbstractFontTest AbstractFontTest.cpp FILES data.bin) target_include_directories(TextAbstractFontTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(TextAbstractFontConverterTest AbstractFontConverterTest.cpp - LIBRARIES Magnum MagnumText + LIBRARIES Magnum MagnumTextTestLib FILES data.bin) target_include_directories(TextAbstractFontConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(TextAbstractGlyphCacheTest AbstractGlyphCacheTest.cpp LIBRARIES MagnumTextTestLib)