From 41ef0e2f9e27b2f1c1b224bda6adea07bfad2c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 4 Oct 2023 18:42:31 +0200 Subject: [PATCH] Text: no need to painstakingly fill a cache in AbstractFont test. Just verify the arguments or the return values were passed correctly. --- src/Magnum/Text/Test/AbstractFontTest.cpp | 31 +++++++++++------------ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Magnum/Text/Test/AbstractFontTest.cpp b/src/Magnum/Text/Test/AbstractFontTest.cpp index 42a3c606a..851f28b8d 100644 --- a/src/Magnum/Text/Test/AbstractFontTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontTest.cpp @@ -30,6 +30,7 @@ #include /** @todo remove once Debug is stream-free */ #include #include +#include #include #include /** @todo remove once Debug is stream-free */ #include @@ -1001,20 +1002,23 @@ void AbstractFontTest::fillGlyphCache() { Containers::Pointer doLayout(const AbstractGlyphCache&, Float, Containers::StringView) override { return nullptr; } void doFillGlyphCache(AbstractGlyphCache& cache, Containers::ArrayView characters) override { - for(char a: characters) cache.insert(a*10, {a/2, a*2}, {}); + CORRADE_COMPARE(cache.textureSize(), (Vector2i{100, 100})); + CORRADE_COMPARE_AS(characters, Containers::arrayView({ + 'h', 'e', 'l', 'o' + }), TestSuite::Compare::Container); + called = true; } + + bool called = false; } font; + /* Capture correct function name */ + CORRADE_VERIFY(true); + DummyGlyphCache cache{{100, 100}}; - CORRADE_COMPARE(cache.glyphCount(), 1); font.fillGlyphCache(cache, "helo"); - - CORRADE_COMPARE(cache.glyphCount(), 5); - CORRADE_COMPARE(cache['h'*10], (std::pair{{52, 208}, {}})); - CORRADE_COMPARE(cache['e'*10], (std::pair{{50, 202}, {}})); - CORRADE_COMPARE(cache['l'*10], (std::pair{{54, 216}, {}})); - CORRADE_COMPARE(cache['o'*10], (std::pair{{55, 222}, {}})); + CORRADE_VERIFY(font.called); } void AbstractFontTest::fillGlyphCacheNotSupported() { @@ -1113,19 +1117,14 @@ void AbstractFontTest::createGlyphCache() { Containers::Pointer doLayout(const AbstractGlyphCache&, Float, Containers::StringView) override { return nullptr; } Containers::Pointer doCreateGlyphCache() override { - Containers::Pointer cache{InPlaceInit, Vector2i{100, 100}}; - for(char a: "helo"_s) cache->insert(a*10, {a/2, a*2}, {}); - return cache; + return Containers::pointer(Vector2i{123, 345}); } } font; Containers::Pointer cache = font.createGlyphCache(); + CORRADE_VERIFY(cache); - CORRADE_COMPARE(cache->glyphCount(), 5); - CORRADE_COMPARE((*cache)['h'*10], (std::pair{{52, 208}, {}})); - CORRADE_COMPARE((*cache)['e'*10], (std::pair{{50, 202}, {}})); - CORRADE_COMPARE((*cache)['l'*10], (std::pair{{54, 216}, {}})); - CORRADE_COMPARE((*cache)['o'*10], (std::pair{{55, 222}, {}})); + CORRADE_COMPARE(cache->textureSize(), (Vector2i{123, 345})); } void AbstractFontTest::createGlyphCacheNotSupported() {