Skip to content

Conversation

@Broccoli811
Copy link

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

# 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
Copy link

@rory-cd rory-cd left a 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
clip_test_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;


Copy link

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));

Copy link

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.

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