From e1fcee1652641e6a36b1bc21ba5e4017411cd9a1 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 15 Dec 2025 19:48:41 -0600 Subject: [PATCH] chore(test): add GxuFontCreateFont tests --- .github/workflows/pr.yml | 4 ++-- .github/workflows/push.yml | 4 ++-- test/Test.cpp | 15 ++++++++++++++- test/gx/font/GxuFont.cpp | 22 ++++++++++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 207a047..2faaae3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -64,5 +64,5 @@ jobs: working-directory: build - name: Test - run: ./dist/bin/${{ matrix.config.test_path }} - working-directory: build + run: ../../build/dist/bin/${{ matrix.config.test_path }} + working-directory: test/fixture diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 29fb381..75a965e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -67,5 +67,5 @@ jobs: working-directory: build - name: Test - run: ./dist/bin/${{ matrix.config.test_path }} - working-directory: build + run: ../../build/dist/bin/${{ matrix.config.test_path }} + working-directory: test/fixture diff --git a/test/Test.cpp b/test/Test.cpp index 0c7c351..81ab8f1 100644 --- a/test/Test.cpp +++ b/test/Test.cpp @@ -1,2 +1,15 @@ -#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_RUNNER #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; +} diff --git a/test/gx/font/GxuFont.cpp b/test/gx/font/GxuFont.cpp index 9c6788e..93c6a6d 100644 --- a/test/gx/font/GxuFont.cpp +++ b/test/gx/font/GxuFont.cpp @@ -2,6 +2,28 @@ #include #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]") { SECTION("does not recognize non-quoted code") { const char* str = "test1";