Skip to content

ENH: Convert four no-arg Common tests to GoogleTest#6132

Merged
hjmjohnson merged 6 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:convert-common-gtests-2026-04-25
Apr 27, 2026
Merged

ENH: Convert four no-arg Common tests to GoogleTest#6132
hjmjohnson merged 6 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:convert-common-gtests-2026-04-25

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Mechanical CTest → GoogleTest conversion of four no-argument tests in Modules/Core/Common/test/. All four pass locally against ITKCommonGTestDriver.

Commit summary
# Test Pattern
1 itkImageAdaptorPipeLineTestitkImageAdaptorPipeLineGTest Single commit (rename + edit, 96% similarity)
2 itkExtractImage3Dto2DTestitkExtractImage3Dto2DGTest Single commit (rename + edit, 83% similarity)
3 itkExtractImageTestitkExtractImageGTest Two commits — pure rename then body edit (preserves git log --follow)
4 itkMinimumMaximumImageCalculatorTestitkMinimumMaximumImageCalculatorGTest Two commits — pure rename then body edit
Mechanical-conversion details
  • int itkFooTest(int, char *[])TEST(Foo, ConvertedLegacyTest).
  • if (...) return EXIT_FAILURE;EXPECT_* (or FAIL() << "msg" when the original printed a terminal error message).
  • ITK_TEST_SET_GET_VALUEEXPECT_EQ (the macro's expansion includes return EXIT_FAILURE, incompatible with TEST() void bodies).
  • ITK_TEST_EXPECT_TRUEEXPECT_TRUE (same reason).
  • return ExtractImageInPlaceTest() → call as void; helper signature changed from bool to void (it only contained EXPECT_TRUE checks).
  • Comments preserved verbatim. std::cout diagnostic prints kept.
  • New *GTest.cxx files added to ITKCommonGTests set (alphabetical position); legacy entries removed from ITKCommon{1,2}Tests and the corresponding itk_add_test(...) blocks deleted.
Local verification
[1690/1691] Linking CXX executable bin/ITKCommonGTestDriver
[==========] 4 tests from 4 test suites ran. (1 ms total)
[  PASSED  ] 4 tests.

Filter: --gtest_filter='ImageAdaptorPipeLine.*:ExtractImage*.*:MinimumMaximumImageCalculator.*'

@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:Core Issues affecting the Core module labels Apr 25, 2026
Comment thread Modules/Core/Common/test/itkExtractImage3Dto2DGTest.cxx Outdated
Comment thread Modules/Core/Common/test/itkExtractImageGTest.cxx Outdated
@hjmjohnson hjmjohnson force-pushed the convert-common-gtests-2026-04-25 branch from c1f2cf8 to 39d47a7 Compare April 25, 2026 02:29
Copy link
Copy Markdown
Member Author

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

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

The next batch of gtest conversions.

@hjmjohnson hjmjohnson force-pushed the convert-common-gtests-2026-04-25 branch from 39d47a7 to 9651bcb Compare April 25, 2026 02:41
@hjmjohnson hjmjohnson marked this pull request as ready for review April 25, 2026 02:43
@greptile-apps

This comment was marked as resolved.

Comment thread Modules/Core/Common/test/itkExtractImage3Dto2DGTest.cxx Outdated
Comment thread Modules/Core/Common/test/itkExtractImageGTest.cxx Outdated
@hjmjohnson hjmjohnson force-pushed the convert-common-gtests-2026-04-25 branch from 9651bcb to 52dd1cb Compare April 25, 2026 02:54
@hjmjohnson
Copy link
Copy Markdown
Member Author

/azp run ITK.Windows

@hjmjohnson hjmjohnson force-pushed the convert-common-gtests-2026-04-25 branch from 52dd1cb to a5e6834 Compare April 25, 2026 11:51
@hjmjohnson
Copy link
Copy Markdown
Member Author

Fixed Windows MSVC compile error in a5e6834 (squashed via git rebase --autosquash).

ITK_EXERCISE_BASIC_OBJECT_METHODS expands differently on MSVC vs GCC: the MSVC variant contains return EXIT_FAILURE; on class-name mismatch, which is illegal inside a TEST() body (void). Replaced the macro call with explicit Print() + two EXPECT_STREQ checks, and removed the now-orphaned #include "itkTestingMacros.h".

Verified locally: ITKCommonGTestDriver --gtest_filter='MinimumMaximumImageCalculator.*' passes.

/azp run ITK.Windows

@github-actions github-actions Bot added area:Python wrapping Python bindings for a class area:IO Issues affecting the IO module area:Segmentation Issues affecting the Segmentation module area:ThirdParty Issues affecting the ThirdParty module type:Data Changes to testing data labels Apr 25, 2026
@hjmjohnson hjmjohnson force-pushed the convert-common-gtests-2026-04-25 branch from a5e6834 to 2531f84 Compare April 25, 2026 12:22
@github-actions github-actions Bot removed area:Python wrapping Python bindings for a class area:IO Issues affecting the IO module area:Segmentation Issues affecting the Segmentation module area:ThirdParty Issues affecting the ThirdParty module type:Data Changes to testing data labels Apr 25, 2026
@hjmjohnson hjmjohnson force-pushed the convert-common-gtests-2026-04-25 branch from 2531f84 to 460fc8d Compare April 25, 2026 12:27
@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Apr 25, 2026

I think there is exercise_basic_object_gtest (or similarly named) macro.

@hjmjohnson
Copy link
Copy Markdown
Member Author

exercise_basic_object_gtest

I think there is exercise_basic_object_gtest (or similarly named) macro.

Yes. and I noted it for future conversions, so hopefully this does not show up again.

ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(calculator, MinimumMaximumImageCalculator, Object);

@hjmjohnson hjmjohnson enabled auto-merge April 25, 2026 13:35
@hjmjohnson hjmjohnson merged commit 74aa195 into InsightSoftwareConsortium:main Apr 27, 2026
15 checks passed
@hjmjohnson hjmjohnson added this to the ITK 6.0.0 milestone May 5, 2026
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
…vert-common-gtests-2026-04-25

ENH: Convert four no-arg Common tests to GoogleTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core 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