ENH: Convert 8 ImageIntensity tests to GoogleTest#6197
Conversation
|
| 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]
Reviews (1): Last reviewed commit: "ENH: Convert itkEqualTest to itkEqualGTe..." | Re-trigger Greptile
…vert-filtering-tests-to-gtest-batch1
Mechanical conversion of 8 no-argument legacy CTests in
Modules/Filtering/ImageIntensity/test/to GoogleTest, per theconvert-to-gtestskill workflow ("one commit, one change" — N-Dekker).itkRoundImageFilterTeste4b9ee6eitkSquareImageFilterTest396bcad6itkLessTestafa3f1fbitkNotEqualTest79a6e66fitkGreaterTest0ebef44aitkGreaterEqualTestf200baeeitkLessEqualTestb82d4b86itkEqualTestd678cf4bEach conversion is a single commit with
git mvrename (81-83% similarity, history preserved throughgit log --follow),ITK_EXERCISE_BASIC_OBJECT_METHODS→ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS,ITK_TRY_EXPECT_NO_EXCEPTION→ASSERT_NO_THROW, and return-on-failure →ASSERT_EQ(..., EXIT_SUCCESS). No logic refactoring, no comment removal, no spurious[[maybe_unused]].Verification
pre-commit run --all-filesexit 0 on the final tipITKImageIntensityTests(legacy) andITKImageIntensityGTestssetsEqualconversion preserves itsBogushelper 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 patternNet: +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 singleASSERT_EQ).