Skip to content

BUG: Check upper threshold default in itkBinaryThresholdImageFilterTest - #7008

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:bug-binary-threshold-test-upper-default
Oct 30, 2026
Merged

hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:bug-binary-threshold-test-upper-default

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

The "upper threshold" check in itkBinaryThresholdImageFilterTest read the lower threshold and expected its default. It now checks GetUpperThresholdInput() against NumericTraits<InputPixelType>::max(), which the filter's constructor sets, and the copy-pasted failure message names the right getter.

How this was found and tested

Found while converting this test to GoogleTest: the conversion reproduced
the defect faithfully, so the fix belongs in the legacy test first and the
conversion follows it. Built and ran locally (AppleClang, Release) along
with every other test in the affected modules: all pass.

AI assistance (Claude Code) was used to find the defect and draft the fix;
the change was reviewed and tested locally.

The upper threshold check read the lower threshold and expected its
default. The filter initializes the upper threshold to max().
@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Filtering Issues affecting the Filtering module labels Oct 25, 2026
@hjmjohnson
hjmjohnson marked this pull request as ready for review October 25, 2026 13:46
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge.

Summary

Fixes the upper-default check in itkBinaryThresholdImageFilterTest.

  • The test checks the upper threshold against its maximum default.

No actionable issues found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "BUG: Check upper threshold default in it..." · Reviewed by Greptile

@hjmjohnson
hjmjohnson requested a review from blowekamp October 30, 2026 12:29

@blowekamp blowekamp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good.

This looks like a prime example of this manual testing type is not so good. Could an ITK_TEST macro be used instead?

This looks like a prime example of why the concise style of GTest is preferred. There was an effort to migrate many tests go GTest infrastructure, how did this test relate? It couldn't be migrated because of an input image?

@hjmjohnson

Copy link
Copy Markdown
Member Author

@blowekamp Thanks for the review. Agreed on both points.

This test takes no arguments and no input image, so nothing blocked migration. It is already converted to GoogleTest in my staged batch of no-argument CTest conversions (one commit per test, being upstreamed gradually): hjmjohnson/ITK@43b60e8cd4a on gtest-staging-B. There the hand-written blocks become EXPECT_EQ, and the default check is EXPECT_EQ(upperThreshold1->Get(), itk::NumericTraits<InputPixelType>::max()).

ITK_TEST_EXPECT_EQUAL would also have shortened these blocks, but with the GoogleTest conversion queued I kept this PR to the minimal fix, so it can merge on its own before the conversion lands.

@hjmjohnson
hjmjohnson merged commit c718a2c into InsightSoftwareConsortium:main Oct 30, 2026
20 checks passed
@hjmjohnson

Copy link
Copy Markdown
Member Author

@blowekamp Follow-up with the GoogleTest conversion of this test: #7040 (stacked on this PR). It follows the earlier bulk no-argument CTest conversions already merged (for example #6246, #6369, #6197, #6200), and the remaining ones are staged one commit per test on the gtest-staging-A/B/C branches of hjmjohnson/ITK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants