Skip to content

Line2: increase test coverage (backport #807) - #827

Merged
ahcorde merged 2 commits into
gz-math8from
mergify/bp/gz-math8/pr-807
Aug 25, 2026
Merged

Line2: increase test coverage (backport #807)#827
ahcorde merged 2 commits into
gz-math8from
mergify/bp/gz-math8/pr-807

Conversation

@mergify

@mergify mergify Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦟 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:

  • Fix warnings in Set(double, double, double, double) by wrapping with static_cast<T>
  • Fix warning in Length() by using the simpler implementation from Line3.hh wrapped with static_cast<T>:

public: T Length() const
{
return this->pts[0].Distance(this->pts[1]);
}

Summary of test coverage improvements

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

Backport Policy

  • This is safe to backport to the following versions:
    • Jetty
    • Ionic
    • Harmonic
    • Fortress
  • This should not be backported
  • I am not sure
  • Other (fill in yourself)

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the fix (as needed)
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Assisted-by" to your commits. (See this policy for more info.)

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-by and Generated-by messages.

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

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)

# Conflicts:
#	src/python_pybind11/test/Line2_TEST.py
@mergify
mergify Bot requested a review from scpeters as a code owner August 25, 2026 08:42
@mergify mergify Bot added the conflicts label Aug 25, 2026
@mergify
mergify Bot requested a review from adityapande-1995 as a code owner August 25, 2026 08:42
@mergify

mergify Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 268039c has failed:

On branch mergify/bp/gz-math8/pr-807
Your branch is up to date with 'origin/gz-math8'.

You are currently cherry-picking commit 268039c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   include/gz/math/Line2.hh
	modified:   src/Line2_TEST.cc

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/python_pybind11/test/Line2_TEST.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify Bot added the conflicts label Aug 25, 2026
@mergify mergify Bot mentioned this pull request Aug 25, 2026
19 tasks
@github-actions github-actions Bot added the 🏛️ ionic Gazebo Ionic label Aug 25, 2026
Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development Aug 25, 2026
@ahcorde
ahcorde merged commit 59cc2c2 into gz-math8 Aug 25, 2026
15 checks passed
@ahcorde
ahcorde deleted the mergify/bp/gz-math8/pr-807 branch August 25, 2026 14:10
@github-project-automation github-project-automation Bot moved this from In review to Done in Core development Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants