Browse Source

Text: test glyph cache access with padding included.

It's been [0] days since the last issue caused by "100%" coverage.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
d460134122
  1. 22
      src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp

22
src/Magnum/Text/Test/AbstractGlyphCacheTest.cpp

@ -79,40 +79,42 @@ struct DummyGlyphCache: AbstractGlyphCache {
}; };
void AbstractGlyphCacheTest::initialize() { void AbstractGlyphCacheTest::initialize() {
DummyGlyphCache cache{{1024, 2048}}; DummyGlyphCache cache{{1024, 2048}, {23, 46}};
CORRADE_COMPARE(cache.textureSize(), (Vector2i{1024, 2048})); CORRADE_COMPARE(cache.textureSize(), (Vector2i{1024, 2048}));
CORRADE_COMPARE(cache.padding(), (Vector2i{23, 46}));
} }
void AbstractGlyphCacheTest::access() { void AbstractGlyphCacheTest::access() {
DummyGlyphCache cache{Vector2i(236)}; DummyGlyphCache cache{{100, 200}, {2, 3}};
Vector2i position; Vector2i position;
Range2Di rectangle; Range2Di rectangle;
/* Default "Not Found" glyph */ /* Default "Not Found" glyph */
CORRADE_COMPARE(cache.glyphCount(), 1); CORRADE_COMPARE(cache.glyphCount(), 1);
std::tie(position, rectangle) = cache[0]; std::tie(position, rectangle) = cache[0];
CORRADE_COMPARE(position, Vector2i(0, 0)); CORRADE_COMPARE(position, (Vector2i{0, 0}));
CORRADE_COMPARE(rectangle, Range2Di({0, 0}, {0, 0})); CORRADE_COMPARE(rectangle, (Range2Di{{0, 0}, {0, 0}}));
/* Overwrite the "Not Found" glyph */ /* Overwrite the "Not Found" glyph */
cache.insert(0, {3, 5}, {{10, 10}, {23, 45}}); cache.insert(0, {3, 5}, {{10, 10}, {23, 45}});
CORRADE_COMPARE(cache.glyphCount(), 1); CORRADE_COMPARE(cache.glyphCount(), 1);
std::tie(position, rectangle) = cache[0]; std::tie(position, rectangle) = cache[0];
CORRADE_COMPARE(position, Vector2i(3, 5)); /* The position is with negative padding, rectangle with positive */
CORRADE_COMPARE(rectangle, Range2Di({10, 10}, {23, 45})); CORRADE_COMPARE(position, (Vector2i{1, 2}));
CORRADE_COMPARE(rectangle, (Range2Di{{8, 7}, {25, 48}}));
/* Querying available glyph */ /* Querying available glyph */
cache.insert(25, {3, 4}, {{15, 30}, {45, 35}}); cache.insert(25, {3, 4}, {{15, 30}, {45, 35}});
CORRADE_COMPARE(cache.glyphCount(), 2); CORRADE_COMPARE(cache.glyphCount(), 2);
std::tie(position, rectangle) = cache[25]; std::tie(position, rectangle) = cache[25];
CORRADE_COMPARE(position, Vector2i(3, 4)); CORRADE_COMPARE(position, (Vector2i{1, 1}));
CORRADE_COMPARE(rectangle, Range2Di({15, 30}, {45, 35})); CORRADE_COMPARE(rectangle, (Range2Di{{13, 27}, {47, 38}}));
/* Querying not available glyph falls back to "Not Found" */ /* Querying not available glyph falls back to "Not Found" */
std::tie(position, rectangle) = cache[42]; std::tie(position, rectangle) = cache[42];
CORRADE_COMPARE(position, Vector2i(3, 5)); CORRADE_COMPARE(position, (Vector2i{1, 2}));
CORRADE_COMPARE(rectangle, Range2Di({10, 10}, {23, 45})); CORRADE_COMPARE(rectangle, (Range2Di{{8, 7}, {25, 48}}));
} }
void AbstractGlyphCacheTest::reserve() { void AbstractGlyphCacheTest::reserve() {

Loading…
Cancel
Save