Add test cases to unit_test_sprites.cpp#164
Open
kyriesk wants to merge 2 commits into
Open
Conversation
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 code uses descriptive
TEST_CASEnames andSECTIONlabels, making the test scenarios easy to understand. - Maintainability: High. The tests leverage existing SplashKit functions and assets, making them easy to maintain as the core library evolves.
Functionality
- Correctness: The tests effectively validate multiple aspects of sprite collisions:
- Directional Detection: Correctly identifies if and from which direction a collision occurs between sprites and between a sprite and a rectangle.
- Collision Resolution: Verifies that
resolve_collisioncorrectly moves sprites out of a collision state and returns the appropriate success/failure boolean. - Ray Casting: Tests the
sprite_ray_collisionfunction for both intersecting and non-intersecting scenarios.
- Impact on Existing Functionality: No impact on existing code as this PR only adds new test cases.
Testing
- Test Coverage: This PR provides valuable coverage for the collision-related functions in the sprite module, which are critical for game development workflows.
- Test Results: All logic within the tests is sound. The tests correctly load existing assets (
rocket_sprt.png,background.png) and clean up resources usingfree_sprite().
Documentation
- Documentation: Inline documentation is sufficient; the test structure itself serves as documentation for the expected behavior of the collision functions.
Pull Request Details
- PR Description: The addition of these tests clearly addresses a gap in the current unit test suite.
- Checklist Completion: All relevant items reviewed.
kottochii
approved these changes
May 10, 2026
kottochii
left a comment
There was a problem hiding this comment.
Tested the changes and had a read through. The test cases make sense.
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
This pull request adds comprehensive unit tests for three collision-related functions in the sprite module that were previously untested in the unit test suite. The tests adapt test scenarios from
test_sprites.cpp(sktest) into proper unit tests using the Catch2 framework.The new tests ensure that:
calculate_collision_directioncorrectly determines the direction of collision between sprites and geometric shapesresolve_collisionproperly resolves collisions by moving objects out of collision statessprite_ray_collisionaccurately detects when sprites intersect with raysFixes #(issue related to missing collision tests)
Type of change
Changes Made
Added 5 new test cases to
coresdk/src/test/unit_tests/unit_test_sprites.cpp:collision direction between sprites (6 sub-tests)
collision direction between sprite and rectangle (2 sub-tests)
collision resolution between sprites (3 sub-tests)
collision resolution between sprite and rectangle (2 sub-tests)
sprite ray collision detection (6 sub-tests)
Added required headers:
collisions.handgeometry.hHow Has This Been Tested?
The tests have been written following the existing patterns in
unit_test_sprites.cppand use:TEST_CASEandSECTIONmacrosREQUIREandREQUIRE_FALSEmacrosAll tests use existing resources (rocket_sprt.png, background.png, frog.png) that are already available in the test resources directory.
All tests were run and verified to pass:
Testing Checklist
Checklist
Additional Notes