Skip to content

ENH: Convert 8 ImageIntensity tests to GoogleTest#6197

Merged
dzenanz merged 8 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:convert-filtering-tests-to-gtest-batch1
May 4, 2026
Merged

ENH: Convert 8 ImageIntensity tests to GoogleTest#6197
dzenanz merged 8 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:convert-filtering-tests-to-gtest-batch1

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Mechanical conversion of 8 no-argument legacy CTests in Modules/Filtering/ImageIntensity/test/ to GoogleTest, per the convert-to-gtest skill workflow ("one commit, one change" — N-Dekker).

Test Commit
itkRoundImageFilterTest e4b9ee6e
itkSquareImageFilterTest 396bcad6
itkLessTest afa3f1fb
itkNotEqualTest 79a6e66f
itkGreaterTest 0ebef44a
itkGreaterEqualTest f200baee
itkLessEqualTest b82d4b86
itkEqualTest d678cf4b

Each conversion is a single commit with git mv rename (81-83% similarity, history preserved through git log --follow), ITK_EXERCISE_BASIC_OBJECT_METHODSITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS, ITK_TRY_EXPECT_NO_EXCEPTIONASSERT_NO_THROW, and return-on-failure → ASSERT_EQ(..., EXIT_SUCCESS). No logic refactoring, no comment removal, no spurious [[maybe_unused]].

Verification
  • All 8 GTests build and pass locally (each <1ms)
  • pre-commit run --all-files exit 0 on the final tip
  • CMakeLists alphabetic ordering preserved on both ITKImageIntensityTests (legacy) and ITKImageIntensityGTests sets
  • The Equal conversion preserves its Bogus helper class and the 4th sub-block (BinaryFunctorImageFilter instantiation check); all other 7 follow the standard 3-step image-on-image / image-on-constant / constant-on-image pattern

Net: +111 / -267 (conversions are leaner than the originals because the if (status == EXIT_FAILURE) { return EXIT_FAILURE; std::cout << "Step N passed" << std::endl; } boilerplate collapses to a single ASSERT_EQ).

@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation 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 May 3, 2026
@hjmjohnson hjmjohnson marked this pull request as ready for review May 3, 2026 12:41
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 3, 2026

Greptile Summary

Mechanical conversion of 8 no-argument legacy CTests in Modules/Filtering/ImageIntensity/test/ to GoogleTest, following the project's convert-to-gtest workflow. Each file is renamed (itkFooTest.cxxitkFooGTest.cxx), the legacy entrypoint is replaced with a TEST(Foo, ConvertedLegacyTest) body, itkTestingMacros.h macros are swapped for their GTest equivalents, and the corresponding itk_add_test() / source-list entries are removed from CMakeLists.txt.

All 8 test suite names are unique, all ITK_EXERCISE_BASIC_OBJECT_METHODSITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS substitutions are correct, itkTestingMacros.h is removed where it is no longer used, and the GTest source list in CMakeLists.txt is in alphabetical order. The conversion is clean and consistent with project conventions.

Confidence Score: 5/5

This PR is safe to merge — it is a correct mechanical test conversion with no logic changes.

All 8 conversions follow the established convert-to-gtest workflow exactly: unique suite names, correct macro substitutions, itkTestingMacros.h removed where unused, ASSERT_NO_THROW/ASSERT_EQ/EXPECT_EQ used with appropriate fatality semantics, and CMakeLists.txt updated consistently. Pre-commit hooks (including clang-format) passed on the final tip. No logic, no API, and no public interface changes.

No files require special attention.

Important Files Changed

Filename Overview
Modules/Filtering/ImageIntensity/test/CMakeLists.txt Removes 8 legacy source entries and their itk_add_test() blocks; adds the 8 new *GTest.cxx files to the GTest driver in alphabetical order.
Modules/Filtering/ImageIntensity/test/itkEqualGTest.cxx Correct conversion: unique suite name EqualImageFilter, itkGTest.h added, ASSERT_FALSE(filter.IsNull()) replaces null-check returns, ASSERT_EQ(..., EXIT_SUCCESS) replaces status-check pattern; Bogus helper class and 4th sub-block preserved.
Modules/Filtering/ImageIntensity/test/itkRoundImageFilterGTest.cxx Correct conversion: itkTestingMacros.h removed, ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS used, ASSERT_NO_THROW wraps Update(), non-fatal EXPECT_EQ used inside iteration loop matching original semantics.
Modules/Filtering/ImageIntensity/test/itkSquareImageFilterGTest.cxx Correct conversion: itkTestingMacros.h removed, ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS substituted, diagnostic std::cout and std::cerr output collapsed into EXPECT_TRUE(...) << streaming message.
Modules/Filtering/ImageIntensity/test/itkGreaterEqualGTest.cxx Clean three-step conversion with unique suite name GreaterEqualImageFilter; pre-existing stale comment '3 != Im2' preserved as-is (not introduced by this PR).
Modules/Filtering/ImageIntensity/test/itkGreaterGTest.cxx Clean three-step conversion with unique suite name GreaterImageFilter.
Modules/Filtering/ImageIntensity/test/itkLessEqualGTest.cxx Clean three-step conversion with unique suite name LessEqualImageFilter.
Modules/Filtering/ImageIntensity/test/itkLessGTest.cxx Clean three-step conversion with unique suite name LessImageFilter.
Modules/Filtering/ImageIntensity/test/itkNotEqualGTest.cxx Clean three-step conversion with unique suite name NotEqualImageFilter.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Legacy itkFooTest.cxx\nint main returns EXIT_FAILURE/SUCCESS] -->|git mv + mechanical edit| B[New itkFooGTest.cxx\nTEST suite void body]

    B --> C1[Remove itkTestingMacros.h\nwhere no longer needed]
    B --> C2[ITK_EXERCISE_BASIC_OBJECT_METHODS\n→ ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS]
    B --> C3[ITK_TRY_EXPECT_NO_EXCEPTION\n→ ASSERT_NO_THROW]
    B --> C4[checkXxxRes + return EXIT_FAILURE\n→ ASSERT_EQ result EXIT_SUCCESS]
    B --> C5[Add #include itkGTest.h]

    D[CMakeLists.txt] --> D1[Remove from ITKImageIntensityTests\nsource list]
    D --> D2[Remove itk_add_test block]
    D --> D3[Add to ITKImageIntensityGTests\nsource list alphabetically]
Loading

Reviews (1): Last reviewed commit: "ENH: Convert itkEqualTest to itkEqualGTe..." | Re-trigger Greptile

@dzenanz dzenanz merged commit d9d8553 into InsightSoftwareConsortium:main May 4, 2026
16 checks passed
@hjmjohnson hjmjohnson added this to the ITK 6.0.0 milestone May 5, 2026
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
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:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots 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