Text-Renderer/test/test_bitmap.cpp

27 lines
680 B
C++
Raw Permalink Normal View History

2020-01-07 13:23:25 +01:00
#include "Bitmap.hpp"
#include "Font.hpp"
#include <catch2/catch.hpp>
TEST_CASE("default values") {
Bitmap bitmap = Bitmap();
REQUIRE(bitmap.getWidth() == 0);
REQUIRE(bitmap.getHeight() == 0);
REQUIRE(bitmap.getBitsPerPixel() == 0);
2019-10-23 12:18:43 +02:00
}
TEST_CASE("load Bitmap") {
2019-10-24 11:48:26 +02:00
Bitmap bitmap = Bitmap("../res/font1.bmp");
2019-10-23 12:18:43 +02:00
REQUIRE(bitmap.getWidth() == 128);
REQUIRE(bitmap.getHeight() == 64);
REQUIRE(bitmap.getBitsPerPixel() == 24);
}
TEST_CASE("Font") {
2019-10-24 11:48:26 +02:00
Font font("../res/font1.bmp", "../res/font1.toml");
2019-10-23 12:18:43 +02:00
REQUIRE(font.width() == 5);
REQUIRE(font.height() == 7);
2019-12-17 12:06:44 +01:00
REQUIRE_FALSE(font.getPixel('a', 1,1));
2019-10-23 12:18:43 +02:00
REQUIRE(font.getPixel('a', 1,2));
}