chore(test): add GxuFontCreateFont tests

This commit is contained in:
fallenoak 2025-12-15 19:48:41 -06:00
parent 3889ee7b58
commit e1fcee1652
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
4 changed files with 40 additions and 5 deletions

View File

@ -64,5 +64,5 @@ jobs:
working-directory: build working-directory: build
- name: Test - name: Test
run: ./dist/bin/${{ matrix.config.test_path }} run: ../../build/dist/bin/${{ matrix.config.test_path }}
working-directory: build working-directory: test/fixture

View File

@ -67,5 +67,5 @@ jobs:
working-directory: build working-directory: build
- name: Test - name: Test
run: ./dist/bin/${{ matrix.config.test_path }} run: ../../build/dist/bin/${{ matrix.config.test_path }}
working-directory: build working-directory: test/fixture

View File

@ -1,2 +1,15 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_RUNNER
#include "catch.hpp" #include "catch.hpp"
#include "gx/font/FreeType.hpp"
int main(int argc, char* argv[]) {
// Global initialization
FreeTypeInitialize();
int result = Catch::Session().run( argc, argv );
// Global cleanup
// TODO
return result;
}

View File

@ -2,6 +2,28 @@
#include <cstdint> #include <cstdint>
#include "catch.hpp" #include "catch.hpp"
TEST_CASE("GxuFontCreateFont", "[gx]") {
SECTION("creates a font") {
const char* name = "font\\FRIZQT__.TTF";
CGxFont* face;
auto result = GxuFontCreateFont(name, 0.5f, face, 0x0);
REQUIRE(result != 0);
REQUIRE(face != nullptr);
GxuFontDestroyFont(face);
}
SECTION("fails to create a font that doesn't exist") {
const char* name = "font\\DOESNOTEXIST.TTF";
CGxFont* face;
auto result = GxuFontCreateFont(name, 0.5f, face, 0x0);
REQUIRE(result == 0);
REQUIRE(face == nullptr);
}
}
TEST_CASE("GxuDetermineQuotedCode", "[gx]") { TEST_CASE("GxuDetermineQuotedCode", "[gx]") {
SECTION("does not recognize non-quoted code") { SECTION("does not recognize non-quoted code") {
const char* str = "test1"; const char* str = "test1";