Abfahrtsanzeiger Display Basic Library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
libmonoformat/cpp/test/test_font.cpp

45 lines
1.6 KiB

#include <catch2/catch_all.hpp>
#include <monoformat_fontreader.hpp>
static std::uint8_t const SampleFontData[] = {
0, 0, 4, 4, 8, 8, 8, 8, 8, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 2, // Header
'\n', 0, // First glyph
0, 4, 255, 255, // Unicode Table
0, '\n', 0, // Unicode entry
};
TEST_CASE("TestFontReader.CanReadFontProperties") {
auto font = monoformat::FontReader{std::as_bytes(std::span{SampleFontData})};
CHECK(font.supportsBackgroundColor() == false);
CHECK(font.glyphCount() == 0);
CHECK(font.m0() == 4);
CHECK(font.m1() == 4);
CHECK(font.bitCountW() == 8);
CHECK(font.bitCountH() == 8);
CHECK(font.bitCountX() == 8);
CHECK(font.bitCountY() == 8);
CHECK(font.bitCountD() == 8);
CHECK(font.fontBoundingBoxWidth() == 1);
CHECK(font.fontBoundingBoxHeight() == 2);
CHECK(font.fontBoundingBoxXOffset() == 3);
CHECK(font.fontBoundingBoxYOffset() == 4);
CHECK(font.ascent() == 5);
CHECK(font.descent() == 6);
CHECK(font.ascentOfParentheses() == 7);
CHECK(font.descentOfParentheses() == 8);
CHECK(font.arrayOffsetUpperA() == 0);
CHECK(font.arrayOffsetLowerA() == 0);
CHECK(font.arrayOffset0x0100() == 2);
CHECK(font.doesIgnoreUnknownGlyphs() == false);
CHECK(font.lineHeight() == 3);
}
TEST_CASE("TestFontReader.CanHandleUnicodeNextIsZero") {
auto font = monoformat::FontReader{std::as_bytes(std::span{SampleFontData})};
auto glyph = font.retrieveGlyphData(0x2603);
REQUIRE(!!glyph == false);
CHECK(glyph.error() == monoformat::LookupError::GlyphNotFound);
}