Skip to content

Add test cases to unit_test_text.cpp#165

Open
kyriesk wants to merge 1 commit intothoth-tech:mainfrom
kyriesk:unit-test/font
Open

Add test cases to unit_test_text.cpp#165
kyriesk wants to merge 1 commit intothoth-tech:mainfrom
kyriesk:unit-test/font

Conversation

@kyriesk
Copy link
Copy Markdown

@kyriesk kyriesk commented May 8, 2026

Description

This PR adapts font-related tests from test_text.cpp (sktest) into comprehensive unit tests for unit_test_text.cpp (skunit_tests). Previously, font functionality testing was only available in the manual sktest suite. This change brings robust, automated unit test coverage for the font API, including:

  • Font style manipulation (NORMAL_FONT, BOLD_FONT, ITALIC_FONT, UNDERLINE_FONT)
  • Font size loading and verification
  • Font retrieval and availability checking
  • Multiple style transitions and edge cases

Fixes # (none - feature enhancement)

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

The new unit tests have been structured following the Catch2 framework conventions already in use by skunit_tests. Tests cover:

  1. Font Style Tests: Verify that all font styles can be set and retrieved correctly

    • Testing individual style setting (BOLD_FONT, ITALIC_FONT, UNDERLINE_FONT)
    • Testing style cycling through all available styles
    • Testing style setting both by font reference and by font name
  2. Font Size Tests: Verify font size preloading and availability checking

    • Confirming default size (64) is available
    • Preloading multiple sizes (12, 24, 36, 48, 99)
    • Verifying preloaded sizes are accessible
    • Testing both font reference and font name methods
  3. Font Availability Tests: Verify font loading and retrieval

    • Checking non-existent fonts report as unavailable
    • Confirming loaded fonts can be checked by name and reference

Testing Checklist

  • Tested with skunit_tests

All tests were run and verified to pass:

cd projects/cmake
cmake --preset Linux
cmake --build build/
cd ../../bin
./skunit_tests "[text]"

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have requested a review from ... on the Pull Request

Copy link
Copy Markdown

@222448082Ashen 222448082Ashen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General Information

  • Type of Change: New feature (Unit Testing)

Code Quality

  • Repository: Correct. The PR is targeted at splashkit-core.
  • Readability: High. The code follows the established Catch2 pattern used throughout the repository. Sections are well-named and logic is easy to follow.
  • Maintainability: High. The tests are modular and can be easily extended as new text features are added.

Functionality

  • Correctness: The tests accurately verify the core functionality of the text module, including:
    • Font loading and retrieval (load_font, font_named).
    • Availability checks (has_font).
    • Font style manipulation (set_font_style, get_font_style).
    • Font size management (font_has_size, font_load_size).
  • Impact on Existing Functionality: No impact on existing library functionality as these are strictly test additions.

Testing

  • Test Coverage: This PR significantly improves test coverage for the text module.
  • Test Results: Logic check confirms the tests are valid. (Note: Local execution in this environment was limited by missing graphics context, but the code adheres to successful patterns seen in unit_test_geometry.cpp and others).

Documentation

  • Documentation: The code is self-documenting through clear test case and section naming.

Pull Request Details

  • PR Description: The purpose of the PR (improving test coverage for text) is clear from the file content.
  • Checklist Completion: All relevant items reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants