Skip to content

ENH: Convert 26 more ITKCommon CTests to GoogleTest#5875

Closed
hjmjohnson wants to merge 40 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:common-finish-convert-to-gtest
Closed

ENH: Convert 26 more ITKCommon CTests to GoogleTest#5875
hjmjohnson wants to merge 40 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:common-finish-convert-to-gtest

Conversation

@hjmjohnson
Copy link
Member

Summary

Note: This PR depends on #5874 (simplified-conversion-to-gtest) and should be merged after that one. Once #5874 is merged, the base branch of this PR should be updated to main.

Continues the GTest conversion effort from #5874, converting 26 additional no-argument CTests in Modules/Core/Common/test/ to GoogleTest format.

Each test is converted in a separate commit. Where a *GTest.cxx already existed, new TEST() blocks were appended. Where no GTest file existed, a new *GTest.cxx was created. All diagnostic std::cout output is preserved. Assertions (EXPECT_EQ, EXPECT_NEAR, EXPECT_TRUE, etc.) are added wherever the original test would have returned EXIT_FAILURE.

Tests converted (26)

Original CTest GTest file
itkHashTableTest itkHashTableGTest.cxx (augmented)
itkPixelAccessTest itkPixelAccessGTest.cxx
itkStdStreamStateSaveTest itkStdStreamStateSaveGTest.cxx
itkExceptionObjectTest itkExceptionObjectGTest.cxx (augmented)
itkDecoratorTest itkDecoratorGTest.cxx
itkImportContainerTest itkImportContainerGTest.cxx
itkAnnulusOperatorTest itkAnnulusOperatorGTest.cxx
itkDerivativeOperatorTest itkDerivativeOperatorGTest.cxx
itkCovariantVectorGeometryTest itkCovariantVectorGeometryGTest.cxx
itkCommandObserverObjectTest itkCommandObserverObjectGTest.cxx
itkCrossHelperTest itkCrossHelperGTest.cxx
itkGaussianDerivativeOperatorTest itkGaussianDerivativeOperatorGTest.cxx
itkBSplineKernelFunctionTest itkBSplineKernelFunctionGTest.cxx
VNLSparseLUSolverTraitsTest VNLSparseLUSolverTraitsGTest.cxx
itkArrayTest itkArrayGTest.cxx (augmented)
itkArray2DTest itkArray2DGTest.cxx (augmented)
itkFixedArrayTest itkFixedArrayGTest.cxx (augmented)
itkMersenneTwisterRandomVariateGeneratorTest itkMersenneTwisterRandomVariateGeneratorGTest.cxx (augmented)
itkAdaptorComparisonTest itkAdaptorComparisonGTest.cxx
itkFilterDispatchTest itkFilterDispatchGTest.cxx
itkFloodFillIteratorTest itkFloodFillIteratorGTest.cxx
itkFloodFilledSpatialFunctionTest itkFloodFilledSpatialFunctionGTest.cxx
itkThreadedImageRegionPartitionerTest itkThreadedImageRegionPartitionerGTest.cxx
itkThreadedIndexedContainerPartitionerTest itkThreadedIndexedContainerPartitionerGTest.cxx
itkImageTransformTest itkImageTransformGTest.cxx
itkImportImageTest itkImportImageGTest.cxx

Test plan

  • All 155 ITKCommon tests pass locally (ctest -L ITKCommon)
  • Each conversion verified individually with ctest -R <TestName>

🤖 Generated with Claude Code

hjmjohnson and others added 15 commits March 6, 2026 18:02
Replace legacy CTest driver test with GoogleTest framework.
Adds EXPECT_EQ assertions for ITK major, minor, and patch versions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework.
Adds EXPECT_EQ assertions verifying each vector element value.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework.
Adds assertions for event derivation, self-matching, unrelated event
rejection, and event name verification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework.
Adds EXPECT_GT/EXPECT_GE assertions that modified time increases after
calling Modified() and that bounding box time reflects point changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Splits into
separate test cases per type (char, short, int, long, long long, float,
double) and adds EXPECT_EQ/EXPECT_TRUE assertions after double-swap
round-trips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Splits into
separate test cases for fixed-width, least, fast, and max/pointer integer
types with EXPECT_TRUE assertions on size and signedness.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Consolidate itkMathRoundTest, itkMathRoundTest2, and
itkMathRoundProfileTest1 into a single GoogleTest file. The profiling
test was purely diagnostic (no assertions) and its coverage is now
subsumed by the typed round tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ckGTest

Replace legacy CTest driver test with GoogleTest framework. Splits into
separate test cases per target type with EXPECT_TRUE assertions. Uses
EXPECT_THROW to verify range overflow detection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Adds a
TypeTraits test verifying static_assert conditions at runtime, and a
ThreadSafeMonotonicity test with EXPECT_EQ/EXPECT_LE assertions
verifying that multi-threaded Modified() calls assign unique,
consecutive modified times.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Splits into
separate test cases: EmptyBoxDefaults, OneDimensionalBox,
ThreeDimensionalIsInside, ComputeCorners, and DeepCopy. Adds EXPECT_EQ,
EXPECT_TRUE/FALSE, and EXPECT_NEAR assertions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Adds
EXPECT_EQ assertions verifying the 15 neighborhood pixel values at the
image boundary corner with ConstantBoundaryCondition(0), and verifies
ZeroFluxNeumannBoundaryCondition traversal completes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Preserves
the abort event diagnostic output. Adds EXPECT_TRUE assertions verifying
that the ProcessAborted exception is thrown and that the abort event
callback is called.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Preserves
all diagnostic console output showing ownership transfer messages.
Adds EXPECT_TRUE/FALSE assertions verifying IsOwner() state after
TakeOwnership, copy construction, and Reset operations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace legacy CTest driver test with GoogleTest framework. Splits into
two test cases: BuildLineFromVector and BuildLineFromIndices. Replaces
manual error-checking with EXPECT_EQ assertions on line length and per-element
index values.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nGTest

Replace itkHeavisideStepFunctionTest1, itkSinRegularizedHeavisideStepFunctionTest1,
and itkAtanRegularizedHeavisideStepFunctionTest1 legacy CTest driver tests with
GoogleTest framework. Combines into one file with three test cases:
ExactHeaviside, SinRegularized, and AtanRegularized. Preserves diagnostic loop
output over [-2, 2]. Replaces ITK_TRY_EXPECT_EXCEPTION with EXPECT_THROW and
ITK_TEST_SET_GET_VALUE with EXPECT_EQ. Adds boundary assertions at x=0 and
validates EvaluateDerivative matches pi/2 and 2/pi for Sin and Atan variants.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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 Mar 7, 2026
hjmjohnson and others added 2 commits March 7, 2026 07:09
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hjmjohnson hjmjohnson force-pushed the common-finish-convert-to-gtest branch from 633ebce to 857b3c8 Compare March 7, 2026 13:48
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hjmjohnson hjmjohnson force-pushed the common-finish-convert-to-gtest branch from 857b3c8 to fd6d2d6 Compare March 7, 2026 14:11
hjmjohnson and others added 6 commits March 7, 2026 08:13
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
hjmjohnson and others added 16 commits March 7, 2026 08:13
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hjmjohnson hjmjohnson force-pushed the common-finish-convert-to-gtest branch from fd6d2d6 to 03a58cd Compare March 7, 2026 14:14
@hjmjohnson hjmjohnson marked this pull request as ready for review March 7, 2026 20:14
Comment on lines +65 to +67
void
Execute(const DispatchBase &);
void Execute(Dispatch<2>);
Copy link
Contributor

@N-Dekker N-Dekker Mar 8, 2026

Choose a reason for hiding this comment

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

Strange formatting hick-up! Is this from clang-format? Or is clang-format by-passed somehow?

@N-Dekker
Copy link
Contributor

N-Dekker commented Mar 8, 2026

Thanks Hans. But I'm sorry, I feel that pull requests with more than 2000 changes are very hard to review carefully 🤷 I would not want to trust AI blindly.

@hjmjohnson
Copy link
Member Author

Thanks Hans. But I'm sorry, I feel that pull requests with more than 2000 changes are very hard to review carefully 🤷 I would not want to trust AI blindly.

@N-Dekker What would you prefer? I can make 26 different pull requests really easily, but that is going

@hjmjohnson hjmjohnson closed this Mar 8, 2026
@N-Dekker
Copy link
Contributor

N-Dekker commented Mar 8, 2026

@hjmjohnson Thanks Hans. I think it would help if we could first just have conversions that can be compared line-by-line with the original Test.cxx files. I think those are the ones that are not "augmented".

More specifically, I think those are the cases where an old Test.cxx is converted to a new GTest.cxx (not to an existing GTest.cxx) In those cases, Git moves the revision history from the old Test.cxx onto the new GTest.cxx.

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