-
Notifications
You must be signed in to change notification settings - Fork 40
Add Unit tests for clipping functions #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
# Description This PR adds new unit tests for SplashKit’s clipping functionality. These tests cover creating and removing clipping rectangles, handling multiple nested clipping regions, and verifying that drawing functions only affect the expected clipped area. This work addresses the current gap in our test suite, as `sktest` performs visual tests for clipping but `skunit_tests` does not yet define test cases yet. ## Type of change - [✓] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? The new tests create an off-screen bitmap, apply clipping rectangles, draw shapes, and then use `get_pixel` to confirm that only the clipped region was modified. Tests include: - Creating and removing a single clipping rectangle - Stacking multiple clipping rectangles (nested clips) - Ensuring that drawing operations affect only the active clipped area - Resetting the clip restores full drawing range Tests were run locally to verify succesful operations ## Testing Checklist - [✓] Tested with sktest - [✓] Tested with skunit_tests ## Checklist - [✓] My code follows the style guidelines of this project - [✓] I have performed a self-review of my own code - [✓] I have made corresponding changes to the documentation - [✓] My changes generate no new warnings
rory-cd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new tests are well structured and easy to follow. I have added some inline suggestions for optional minor improvements. Another consideration is whether current_clip() be tested here too? That would complete the whole set of clipping functions.
Either way, this PR increases coverage for a previously untested set of functions - nicely done!
General Information
Type of Change:
- New unit tests
Code Quality
- Repository: Pull Request is made to the correct repository
- Readability: Code is easy to read and follow
- Maintainability: Code can be easily maintained or extended in the future
Functionality
- Correctness: Code meets the requirements of the task
- Impact on Existing Functionality: Impact on existing functionality been considered and tested
Testing
- Test Coverage: Unit tests provided for new or modified code
- Test Results: All tests passed
Documentation
- Documentation: Both inline and applicable external documentation updated and clear
Pull Request Details
- PR Description: The problem being solved is clearly described
- Checklist Completion: All relevant checklist items have been reviewed and completed
|
|
||
| using namespace splashkit_lib; | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor improvement: Consider removing one of the blank lines, to follow convention from the other test files.
| fill_rectangle(COLOR_BLUE, 0, 0, 40, 40, option_draw_to(bmp)); | ||
|
|
||
| REQUIRE(pixel_is(bmp, 25, 15, COLOR_BLUE)); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor improvement: Consider adding REQUIRE(pixel_is(bmp, 25, 5, COLOR_WHITE));
The current assertions test samples:
- In the intersected area
- In the original area
- Outside the original area
The suggestion would test the new area where it doesn't intersect the original.
Description
This PR adds new unit tests for SplashKit’s clipping functionality.
These tests cover creating and removing clipping rectangles, handling multiple nested clipping regions, and verifying that drawing functions only affect the expected clipped area.
This work addresses the current gap in our test suite, as
sktestperforms visual tests for clipping butskunit_testsdoes not yet define test cases yet.Type of change
How Has This Been Tested?
The new tests create an off-screen bitmap, apply clipping rectangles, draw shapes, and then use
get_pixelto confirm that only the clipped region was modified. Tests include:Tests were run locally to verify succesful operations
Testing Checklist
Checklist