Add matrix unit tests#156
Open
ekam313 wants to merge 1 commit into
Open
Conversation
kyriesk
approved these changes
Apr 1, 2026
kyriesk
left a comment
There was a problem hiding this comment.
Peer Review
I tested the unit_test_matrix.cpp on my local machine using a WSL setup, and all tests passed without issues. The code follows SplashKit’s coding standards and behaves functional.
222448082Ashen
approved these changes
May 8, 2026
222448082Ashen
left a comment
There was a problem hiding this comment.
General Information
- Type of Change: New feature (Unit Testing)
Code Quality
- Repository: Correct. The PR is made to
splashkit-core. - Readability: High. The tests are well-organized by functionality and use a clear, property-based verification approach (e.g., verifying that a matrix multiplied by its inverse yields the identity matrix).
- Maintainability: High. The tests rely on standard SplashKit types and formatting functions, making them robust against internal implementation changes as long as the API and output format remain stable.
Functionality
- Correctness: The tests comprehensively cover the
matrix_2dmodule:- Identity Property: Verifies
identity_matrix()and that multiplying by identity is a no-op. - Inverse Operations: Correctly tests that inversion works for scaling, rotation, translation, and combinations thereof.
- Edge Cases: Verifies that
scale_matrix(1)andtranslation_matrix(0, 0)correctly return identity matrices. - Formatting: Explicitly tests the
matrix_to_stringoutput, which is crucial for debugging tools that rely on this format.
- Identity Property: Verifies
- Impact on Existing Functionality: No impact on library code.
Testing
- Test Coverage: This PR fills a significant gap in the unit test suite, as matrix operations are foundational to many other SplashKit modules (sprites, geometry, etc.).
- Test Results: Logic check: The string comparison for
matrix_to_stringaligns perfectly with thesetw(8)andsetprecision(3)implementation found inmatrix_2d.cpp.
Documentation
- Documentation: The test code is clear and self-documenting.
Pull Request Details
- Checklist Completion: All relevant items reviewed.
Recommendations & Observations
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added Catch2 unit tests for matrix-related functions by converting the old manual matrix checks into automated assertions in
coresdk/src/test/unit_tests/unit_test_matrix.cpp.The new tests cover:
identity_matrixmatrix_inversematrix_to_stringscale_matrixrotation_matrixtranslation_matrixmatrix_multiplyThis improves automated test coverage for matrix functionality and replaces manual output checking with repeatable u\nit tests.
Fixes # (issue)
Type of change
How Has This Been Tested?
Tested on Windows using MSYS2 MinGW64.
Commands used:
Checklist
Checklist