Skip to content

Conversation

@222448082Ashen
Copy link

@222448082Ashen 222448082Ashen commented Dec 21, 2025

Description

Added automated unit tests for ray intersection functions, migrating interactive tests from test_geometry.cpp to proper unit tests that can run in CI/CD pipelines.

Changes:

  • Added unit tests for rectangle_ray_intersection in unit_test_geometry.cpp
  • Added unit tests for circle_ray_intersection in unit_test_geometry.cpp
  • Added unit tests for triangle_ray_intersection in unit_test_geometry.cpp
  • Added unit tests for quad_ray_intersection in unit_test_geometry.cpp
  • Added unit tests for bitmap_ray_collision in unit_test_bitmap.cpp
  • Added test for detecting closest intersection among multiple shapes
  • Added necessary includes for geometry headers and physics

Motivation:
The ray intersection functionality previously only had interactive visual tests that required manual inspection. These new automated tests enable continuous integration testing and prevent regressions.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (update or new)

How Has This Been Tested?

Test Details:

  • All tests are automated using Catch2 framework
  • Tests validate both boolean return values and output parameters (hit points, distances)
  • Edge cases tested: rays pointing away, parallel rays, rays from inside shapes
  • Multiple shape priority testing validates distance-based collision detection

To reproduce:

# From MSYS2 MinGW64 terminal
cd projects/cmake
cmake -G "Unix Makefiles" .
make
cd ../../bin

# Run all unit tests
./skunit_tests

# Run only ray intersection tests
./skunit_tests "[ray_intersection]"
./skunit_tests "[ray_collision]"

Testing Checklist

  • Tested with sktest (not applicable - these are unit tests)
  • Tested with skunit_tests (syntax validated, ready for build/test)

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

Introduces comprehensive unit tests for ray intersection with rectangles, circles, triangles, and quads in unit_test_geometry.cpp, including hit point and distance checks. Adds bitmap ray collision detection tests in unit_test_bitmap.cpp, covering various scenarios and bitmap cells. These tests improve coverage for ray-based collision and intersection logic.
Expanded the pull request template to include details about new automated unit tests for ray intersection functions, replacing manual interactive tests. Added sections for test details, reproduction steps, and updated checklists to reflect the new testing approach.
@222448082Ashen 222448082Ashen changed the title Unit test/geometry Add automated unit tests for ray intersection and collision functions Dec 21, 2025
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.

1 participant