Line2: increase test coverage (backport #807) - #826
Merged
Conversation
1. Set with Vector2 parameters: Verified setting start/end points
using Vector2 instances.
2. CrossProduct: Added explicit tests for both Line2 and Vector2
cross products. Expect CrossProduct of parallel lines is 0.
3. OnSegment and Within: Tested points on segment, collinear points
outside bounds, non-collinear points within bounding box, and endpoints.
4. Intersect Branch Coverage:
• Parallel collinear non-overlapping line segments.
• Collinear lines where only the second endpoint lies on the segment.
• Line extensions that intersect outside X or Y bounding ranges.
• Intersect overload taking no output point.
5. Operators: Expanded operator== and operator!= self-comparison checks.
6. Template Types: Added test cases for Line2i (int) and Line2f (float).
Assisted-by: Gemini 3.6 Flash
Fix type conversion warnings
* Set: use static_cast<T>
* Length: use simpler approach from Line3::Length
along with static_cast<T>
Signed-off-by: Steve Peters <scpeters@intrinsic.ai>
(cherry picked from commit 268039c)
mergify
Bot
requested review from
adityapande-1995 and
scpeters
as code owners
August 25, 2026 08:42
19 tasks
ahcorde
approved these changes
Aug 25, 2026
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.
🦟 Bug fix
Improve test coverage of Line2 class
Summary
This increases test coverage based on suggestions from Gemini. After observing some windows C4244 compiler warnings, I fixed them in 2a719e4:
Set(double, double, double, double)by wrapping withstatic_cast<T>Length()by using the simpler implementation fromLine3.hhwrapped withstatic_cast<T>:gz-math/include/gz/math/Line3.hh
Lines 135 to 138 in 396f5a5
Summary of test coverage improvements
Backport Policy
Checklist
codecheckpassed (See contributing)Assisted-by: Gemini 3.6 Flash
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.
This is an automatic backport of pull request #807 done by [Mergify](https://mergify.com).