From e4b9ee6e91b7e7b51bb0444d88b9d3cff67987c7 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:23:31 -0500 Subject: [PATCH 1/8] ENH: Convert itkRoundImageFilterTest to itkRoundImageFilterGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +------- ...rTest.cxx => itkRoundImageFilterGTest.cxx} | 20 ++++++++----------- 2 files changed, 9 insertions(+), 19 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkRoundImageFilterTest.cxx => itkRoundImageFilterGTest.cxx} (84%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index a730c151e696..351f52c55c4e 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -59,7 +59,6 @@ set( itkRescaleIntensityImageFilterTest.cxx itkRGBToLuminanceImageFilterAndAdaptorTest.cxx itkRGBToVectorAdaptImageFilterTest.cxx - itkRoundImageFilterTest.cxx itkShiftScaleImageFilterTest.cxx itkSigmoidImageFilterTest.cxx itkSinImageFilterAndAdaptorTest.cxx @@ -676,12 +675,6 @@ itk_add_test( DATA{Input/itkBrainSliceComplexPhase.mha} ${ITK_TEST_OUTPUT_DIR}/itkMagnitudeAndPhaseToComplexImageFilterTest.mha ) -itk_add_test( - NAME itkRoundImageFilterTest - COMMAND - ITKImageIntensityTestDriver - itkRoundImageFilterTest -) itk_add_test( NAME itkDiscreteHessianGaussianImageFunctionTest COMMAND @@ -787,6 +780,7 @@ set( itkAddImageFilterFrameGTest.cxx itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx + itkRoundImageFilterGTest.cxx ) if(MSVC) diff --git a/Modules/Filtering/ImageIntensity/test/itkRoundImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkRoundImageFilterGTest.cxx similarity index 84% rename from Modules/Filtering/ImageIntensity/test/itkRoundImageFilterTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkRoundImageFilterGTest.cxx index 633cd2da20ce..fa050779217e 100644 --- a/Modules/Filtering/ImageIntensity/test/itkRoundImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkRoundImageFilterGTest.cxx @@ -16,17 +16,17 @@ * *=========================================================================*/ +#include "itkRoundImageFilter.h" + #include "itkImageRegionIterator.h" #include "itkMath.h" #include "itkRandomImageSource.h" -#include "itkRoundImageFilter.h" -#include "itkTestingMacros.h" +#include "itkGTest.h" -int -itkRoundImageFilterTest(int, char *[]) -{ +TEST(RoundImageFilter, ConvertedLegacyTest) +{ constexpr unsigned int Dimension{ 2 }; using InputPixelType = float; @@ -40,7 +40,7 @@ itkRoundImageFilterTest(int, char *[]) using FilterType = itk::RoundImageFilter; auto roundImageFilter = FilterType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS(roundImageFilter, RoundImageFilter, UnaryGeneratorImageFilter); + ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(roundImageFilter, RoundImageFilter, UnaryGeneratorImageFilter); // Create a random image @@ -56,7 +56,7 @@ itkRoundImageFilterTest(int, char *[]) roundImageFilter->SetInput(randomImageSource->GetOutput()); - ITK_TRY_EXPECT_NO_EXCEPTION(roundImageFilter->Update()); + ASSERT_NO_THROW(roundImageFilter->Update()); itk::ImageRegionIterator it1(randomImageSource->GetOutput(), randomImageSource->GetOutput()->GetLargestPossibleRegion()); @@ -68,13 +68,9 @@ itkRoundImageFilterTest(int, char *[]) while (!it1.IsAtEnd() || !it2.IsAtEnd()) { - ITK_TEST_EXPECT_EQUAL(itk::Math::Round(it1.Get()), it2.Get()); + EXPECT_EQ(itk::Math::Round(it1.Get()), it2.Get()); ++it1; ++it2; } - - - std::cout << "Test finished." << std::endl; - return EXIT_SUCCESS; } From 396bcad61b3faed029a3b119ba5792f684fe161e Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:30:17 -0500 Subject: [PATCH 2/8] ENH: Convert itkSquareImageFilterTest to itkSquareImageFilterGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +----- ...Test.cxx => itkSquareImageFilterGTest.cxx} | 26 ++++++------------- 2 files changed, 9 insertions(+), 25 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkSquareImageFilterTest.cxx => itkSquareImageFilterGTest.cxx} (81%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index 351f52c55c4e..29bd53fb82ff 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -63,7 +63,6 @@ set( itkSigmoidImageFilterTest.cxx itkSinImageFilterAndAdaptorTest.cxx itkSqrtImageFilterAndAdaptorTest.cxx - itkSquareImageFilterTest.cxx itkSubtractImageFilterTest.cxx itkSymmetricEigenAnalysisImageFilterTest.cxx itkTanImageFilterAndAdaptorTest.cxx @@ -409,12 +408,6 @@ itk_add_test( itkMatrixIndexSelectionImageFilterTest ${ITK_TEST_OUTPUT_DIR}/MatrixIndexSelectionImageFilterTest.png ) -itk_add_test( - NAME itkSquareImageFilterTest - COMMAND - ITKImageIntensityTestDriver - itkSquareImageFilterTest -) itk_add_test( NAME itkRGBToVectorAdaptImageFilterTest.cxx COMMAND @@ -781,6 +774,7 @@ set( itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx itkRoundImageFilterGTest.cxx + itkSquareImageFilterGTest.cxx ) if(MSVC) diff --git a/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterGTest.cxx similarity index 81% rename from Modules/Filtering/ImageIntensity/test/itkSquareImageFilterTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkSquareImageFilterGTest.cxx index b4e584980844..cb23d868fc1a 100644 --- a/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterGTest.cxx @@ -17,14 +17,15 @@ *=========================================================================*/ #include "itkSquareImageFilter.h" + #include "itkImageRegionIteratorWithIndex.h" #include "itkMath.h" -#include "itkTestingMacros.h" -int -itkSquareImageFilterTest(int, char *[]) -{ +#include "itkGTest.h" + +TEST(SquareImageFilter, ConvertedLegacyTest) +{ // Define the dimension of the images constexpr unsigned int ImageDimension{ 3 }; @@ -60,12 +61,10 @@ itkSquareImageFilterTest(int, char *[]) // Initialize the content of Image A constexpr double value{ 30 }; - std::cout << "Content of the Input " << std::endl; it.GoToBegin(); while (!it.IsAtEnd()) { it.Set(value); - std::cout << it.Get() << std::endl; ++it; } @@ -75,7 +74,7 @@ itkSquareImageFilterTest(int, char *[]) // Create a Filter auto filter = FilterType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, SquareImageFilter, UnaryGeneratorImageFilter); + ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(filter, SquareImageFilter, UnaryGeneratorImageFilter); // Connect the input images filter->SetInput(inputImage); @@ -102,18 +101,9 @@ itkSquareImageFilterTest(int, char *[]) const double x1 = input; const double x2 = x1 * x1; const auto square = static_cast(x2); - if (!itk::Math::FloatAlmostEqual(square, output, 10, epsilon)) - { - std::cerr.precision(static_cast(itk::Math::Absolute(std::log10(epsilon)))); - std::cerr << "Error in itkSquareImageFilterTest " << std::endl; - std::cerr << " square( " << input << ") = " << square << std::endl; - std::cerr << " differs from " << output; - std::cerr << " by more than " << epsilon << std::endl; - return EXIT_FAILURE; - } + EXPECT_TRUE(itk::Math::FloatAlmostEqual(square, output, 10, epsilon)) + << "square(" << input << ") = " << square << " differs from " << output << " by more than " << epsilon; ++ot; ++it; } - - return EXIT_SUCCESS; } From afa3f1fb598efdeaf8f2fa211b487299b4419a99 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:33:37 -0500 Subject: [PATCH 3/8] ENH: Convert itkLessTest to itkLessGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +--- .../{itkLessTest.cxx => itkLessGTest.cxx} | 42 +++++++------------ 2 files changed, 15 insertions(+), 35 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkLessTest.cxx => itkLessGTest.cxx} (83%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index 29bd53fb82ff..e9e9b589f182 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -33,7 +33,6 @@ set( itkIntensityWindowingImageFilterTest.cxx itkInvertIntensityImageFilterTest.cxx itkLessEqualTest.cxx - itkLessTest.cxx itkLog10ImageFilterAndAdaptorTest.cxx itkLogImageFilterAndAdaptorTest.cxx itkMagnitudeAndPhaseToComplexImageFilterTest.cxx @@ -638,12 +637,6 @@ itk_add_test( ITKImageIntensityTestDriver itkLessEqualTest ) -itk_add_test( - NAME itkLessTest - COMMAND - ITKImageIntensityTestDriver - itkLessTest -) itk_add_test( NAME itkClampImageFilterTest COMMAND @@ -773,6 +766,7 @@ set( itkAddImageFilterFrameGTest.cxx itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx + itkLessGTest.cxx itkRoundImageFilterGTest.cxx itkSquareImageFilterGTest.cxx ) diff --git a/Modules/Filtering/ImageIntensity/test/itkLessTest.cxx b/Modules/Filtering/ImageIntensity/test/itkLessGTest.cxx similarity index 83% rename from Modules/Filtering/ImageIntensity/test/itkLessTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkLessGTest.cxx index 9b240590157a..de645cb3fdae 100644 --- a/Modules/Filtering/ImageIntensity/test/itkLessTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkLessGTest.cxx @@ -16,14 +16,16 @@ * *=========================================================================*/ #include "itkLogicOpsFunctors.h" + #include "itkBinaryFunctorImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkLogicTestSupport.h" -int -itkLessTest(int, char *[]) -{ +#include "itkGTest.h" + +TEST(LessImageFilter, ConvertedLegacyTest) +{ // Define the dimension of the images constexpr unsigned int myDimension{ 3 }; @@ -107,14 +109,9 @@ itkLessTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status1 = checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); - if (status1 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 1 passed" << std::endl; + ASSERT_EQ((checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } { @@ -135,14 +132,9 @@ itkLessTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); const PixelType C = filter->GetConstant2(); - const int status2 = checkImOnConstRes>( - inputImageA, C, outputImage, FG, BG); - if (status2 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 2 passed " << std::endl; + ASSERT_EQ((checkImOnConstRes>( + inputImageA, C, outputImage, FG, BG)), + EXIT_SUCCESS); } // Now try testing with constant : 3 != Im2 { @@ -160,15 +152,9 @@ itkLessTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status3 = checkConstOnImRes>( - filter->GetConstant1(), inputImageB, outputImage, FG, BG); - if (status3 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 3 passed" << std::endl; + ASSERT_EQ((checkConstOnImRes>( + filter->GetConstant1(), inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } // All objects should be automatically destroyed at this point - return EXIT_SUCCESS; } From 79a6e66f3687b5bffd70e4f2a6e2ff25d03aa8a6 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:36:51 -0500 Subject: [PATCH 4/8] ENH: Convert itkNotEqualTest to itkNotEqualGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +--- ...kNotEqualTest.cxx => itkNotEqualGTest.cxx} | 43 ++++++------------- 2 files changed, 15 insertions(+), 36 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkNotEqualTest.cxx => itkNotEqualGTest.cxx} (83%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index e9e9b589f182..575f6434d62e 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -47,7 +47,6 @@ set( itkNaryMaximumImageFilterTest.cxx itkNormalizeImageFilterTest.cxx itkNormalizeToConstantImageFilterTest.cxx - itkNotEqualTest.cxx itkNotImageFilterTest.cxx itkNthElementPixelAccessorTest2.cxx itkOrImageFilterTest.cxx @@ -613,12 +612,6 @@ itk_add_test( ITKImageIntensityTestDriver itkEqualTest ) -itk_add_test( - NAME itkNotEqualTest - COMMAND - ITKImageIntensityTestDriver - itkNotEqualTest -) itk_add_test( NAME itkGreaterEqualTest COMMAND @@ -767,6 +760,7 @@ set( itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx itkLessGTest.cxx + itkNotEqualGTest.cxx itkRoundImageFilterGTest.cxx itkSquareImageFilterGTest.cxx ) diff --git a/Modules/Filtering/ImageIntensity/test/itkNotEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkNotEqualGTest.cxx similarity index 83% rename from Modules/Filtering/ImageIntensity/test/itkNotEqualTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkNotEqualGTest.cxx index 0f8af7e040f3..30598e44e963 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNotEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNotEqualGTest.cxx @@ -16,14 +16,16 @@ * *=========================================================================*/ #include "itkLogicOpsFunctors.h" + #include "itkBinaryFunctorImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkLogicTestSupport.h" -int -itkNotEqualTest(int, char *[]) -{ +#include "itkGTest.h" + +TEST(NotEqualImageFilter, ConvertedLegacyTest) +{ // Define the dimension of the images constexpr unsigned int myDimension{ 3 }; @@ -109,15 +111,9 @@ itkNotEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status1 = - checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); - if (status1 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 1 passed" << std::endl; + ASSERT_EQ((checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } { // Create a logic Filter @@ -137,14 +133,9 @@ itkNotEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); const PixelType C = filter->GetConstant2(); - const int status2 = checkImOnConstRes>( - inputImageA, C, outputImage, FG, BG); - if (status2 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 2 passed " << std::endl; + ASSERT_EQ((checkImOnConstRes>( + inputImageA, C, outputImage, FG, BG)), + EXIT_SUCCESS); } { // Now try testing with constant : 3 != Im2 @@ -162,15 +153,9 @@ itkNotEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status3 = checkConstOnImRes>( - filter->GetConstant1(), inputImageB, outputImage, FG, BG); - if (status3 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 3 passed" << std::endl; + ASSERT_EQ((checkConstOnImRes>( + filter->GetConstant1(), inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } // All objects should be automatically destroyed at this point - return EXIT_SUCCESS; } From 0ebef44aa9a4a50d82a08d0f66e1766cff3301e2 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:39:54 -0500 Subject: [PATCH 5/8] ENH: Convert itkGreaterTest to itkGreaterGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +--- ...itkGreaterTest.cxx => itkGreaterGTest.cxx} | 42 +++++++------------ 2 files changed, 15 insertions(+), 35 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkGreaterTest.cxx => itkGreaterGTest.cxx} (83%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index 575f6434d62e..7eb6cdaacccb 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -27,7 +27,6 @@ set( itkExpImageFilterAndAdaptorTest.cxx itkExpNegativeImageFilterAndAdaptorTest.cxx itkGreaterEqualTest.cxx - itkGreaterTest.cxx itkHistogramMatchingImageFilterTest.cxx itkImageAdaptorNthElementTest.cxx itkIntensityWindowingImageFilterTest.cxx @@ -618,12 +617,6 @@ itk_add_test( ITKImageIntensityTestDriver itkGreaterEqualTest ) -itk_add_test( - NAME itkGreaterTest - COMMAND - ITKImageIntensityTestDriver - itkGreaterTest -) itk_add_test( NAME itkLessEqualTest COMMAND @@ -759,6 +752,7 @@ set( itkAddImageFilterFrameGTest.cxx itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx + itkGreaterGTest.cxx itkLessGTest.cxx itkNotEqualGTest.cxx itkRoundImageFilterGTest.cxx diff --git a/Modules/Filtering/ImageIntensity/test/itkGreaterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkGreaterGTest.cxx similarity index 83% rename from Modules/Filtering/ImageIntensity/test/itkGreaterTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkGreaterGTest.cxx index dbf46b7d923c..cfaae6f7d941 100644 --- a/Modules/Filtering/ImageIntensity/test/itkGreaterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkGreaterGTest.cxx @@ -16,14 +16,16 @@ * *=========================================================================*/ #include "itkLogicOpsFunctors.h" + #include "itkBinaryFunctorImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkLogicTestSupport.h" -int -itkGreaterTest(int, char *[]) -{ +#include "itkGTest.h" + +TEST(GreaterImageFilter, ConvertedLegacyTest) +{ // Define the dimension of the images constexpr unsigned int myDimension{ 3 }; @@ -108,14 +110,9 @@ itkGreaterTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status1 = checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); - if (status1 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 1 passed" << std::endl; + ASSERT_EQ((checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } { @@ -137,14 +134,9 @@ itkGreaterTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); const PixelType C = filter->GetConstant2(); - const int status2 = checkImOnConstRes>( - inputImageA, C, outputImage, FG, BG); - if (status2 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 2 passed " << std::endl; + ASSERT_EQ((checkImOnConstRes>( + inputImageA, C, outputImage, FG, BG)), + EXIT_SUCCESS); } // Now try testing with constant : 3 != Im2 { @@ -162,15 +154,9 @@ itkGreaterTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status3 = checkConstOnImRes>( - filter->GetConstant1(), inputImageB, outputImage, FG, BG); - if (status3 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 3 passed" << std::endl; + ASSERT_EQ((checkConstOnImRes>( + filter->GetConstant1(), inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } // All objects should be automatically destroyed at this point - return EXIT_SUCCESS; } From f200baee9e496e27910615323337f2576f050a93 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:42:52 -0500 Subject: [PATCH 6/8] ENH: Convert itkGreaterEqualTest to itkGreaterEqualGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +--- ...EqualTest.cxx => itkGreaterEqualGTest.cxx} | 43 ++++++------------- 2 files changed, 15 insertions(+), 36 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkGreaterEqualTest.cxx => itkGreaterEqualGTest.cxx} (83%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index 7eb6cdaacccb..93d81e618ba1 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -26,7 +26,6 @@ set( itkEqualTest.cxx itkExpImageFilterAndAdaptorTest.cxx itkExpNegativeImageFilterAndAdaptorTest.cxx - itkGreaterEqualTest.cxx itkHistogramMatchingImageFilterTest.cxx itkImageAdaptorNthElementTest.cxx itkIntensityWindowingImageFilterTest.cxx @@ -611,12 +610,6 @@ itk_add_test( ITKImageIntensityTestDriver itkEqualTest ) -itk_add_test( - NAME itkGreaterEqualTest - COMMAND - ITKImageIntensityTestDriver - itkGreaterEqualTest -) itk_add_test( NAME itkLessEqualTest COMMAND @@ -752,6 +745,7 @@ set( itkAddImageFilterFrameGTest.cxx itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx + itkGreaterEqualGTest.cxx itkGreaterGTest.cxx itkLessGTest.cxx itkNotEqualGTest.cxx diff --git a/Modules/Filtering/ImageIntensity/test/itkGreaterEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkGreaterEqualGTest.cxx similarity index 83% rename from Modules/Filtering/ImageIntensity/test/itkGreaterEqualTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkGreaterEqualGTest.cxx index 0c383381f834..423006cca2bc 100644 --- a/Modules/Filtering/ImageIntensity/test/itkGreaterEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkGreaterEqualGTest.cxx @@ -16,14 +16,16 @@ * *=========================================================================*/ #include "itkLogicOpsFunctors.h" + #include "itkBinaryFunctorImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkLogicTestSupport.h" -int -itkGreaterEqualTest(int, char *[]) -{ +#include "itkGTest.h" + +TEST(GreaterEqualImageFilter, ConvertedLegacyTest) +{ // Define the dimension of the images constexpr unsigned int myDimension{ 3 }; @@ -108,15 +110,9 @@ itkGreaterEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status1 = - checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); - if (status1 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 1 passed" << std::endl; + ASSERT_EQ((checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } { @@ -138,14 +134,9 @@ itkGreaterEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); const PixelType C = filter->GetConstant2(); - const int status2 = checkImOnConstRes>( - inputImageA, C, outputImage, FG, BG); - if (status2 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 2 passed " << std::endl; + ASSERT_EQ((checkImOnConstRes>( + inputImageA, C, outputImage, FG, BG)), + EXIT_SUCCESS); } // Now try testing with constant : 3 != Im2 { @@ -165,15 +156,9 @@ itkGreaterEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status3 = checkConstOnImRes>( - filter->GetConstant1(), inputImageB, outputImage, FG, BG); - if (status3 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 3 passed" << std::endl; + ASSERT_EQ((checkConstOnImRes>( + filter->GetConstant1(), inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } // All objects should be automatically destroyed at this point - return EXIT_SUCCESS; } From b82d4b8616373f3ad9518ce5dc40304c1fed33e4 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:45:44 -0500 Subject: [PATCH 7/8] ENH: Convert itkLessEqualTest to itkLessEqualGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +--- ...essEqualTest.cxx => itkLessEqualGTest.cxx} | 43 ++++++------------- 2 files changed, 15 insertions(+), 36 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkLessEqualTest.cxx => itkLessEqualGTest.cxx} (83%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index 93d81e618ba1..412c07642313 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -30,7 +30,6 @@ set( itkImageAdaptorNthElementTest.cxx itkIntensityWindowingImageFilterTest.cxx itkInvertIntensityImageFilterTest.cxx - itkLessEqualTest.cxx itkLog10ImageFilterAndAdaptorTest.cxx itkLogImageFilterAndAdaptorTest.cxx itkMagnitudeAndPhaseToComplexImageFilterTest.cxx @@ -610,12 +609,6 @@ itk_add_test( ITKImageIntensityTestDriver itkEqualTest ) -itk_add_test( - NAME itkLessEqualTest - COMMAND - ITKImageIntensityTestDriver - itkLessEqualTest -) itk_add_test( NAME itkClampImageFilterTest COMMAND @@ -747,6 +740,7 @@ set( itkBitwiseOpsFunctorsTest.cxx itkGreaterEqualGTest.cxx itkGreaterGTest.cxx + itkLessEqualGTest.cxx itkLessGTest.cxx itkNotEqualGTest.cxx itkRoundImageFilterGTest.cxx diff --git a/Modules/Filtering/ImageIntensity/test/itkLessEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkLessEqualGTest.cxx similarity index 83% rename from Modules/Filtering/ImageIntensity/test/itkLessEqualTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkLessEqualGTest.cxx index 969f4a3a8e3a..97ba5a991865 100644 --- a/Modules/Filtering/ImageIntensity/test/itkLessEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkLessEqualGTest.cxx @@ -16,14 +16,16 @@ * *=========================================================================*/ #include "itkLogicOpsFunctors.h" + #include "itkBinaryFunctorImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkLogicTestSupport.h" -int -itkLessEqualTest(int, char *[]) -{ +#include "itkGTest.h" + +TEST(LessEqualImageFilter, ConvertedLegacyTest) +{ // Define the dimension of the images constexpr unsigned int myDimension{ 3 }; @@ -109,15 +111,9 @@ itkLessEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status1 = - checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); - if (status1 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 1 passed" << std::endl; + ASSERT_EQ((checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } { @@ -138,14 +134,9 @@ itkLessEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); const PixelType C = filter->GetConstant2(); - const int status2 = checkImOnConstRes>( - inputImageA, C, outputImage, FG, BG); - if (status2 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 2 passed " << std::endl; + ASSERT_EQ((checkImOnConstRes>( + inputImageA, C, outputImage, FG, BG)), + EXIT_SUCCESS); } // Now try testing with constant : 3 != Im2 { @@ -163,15 +154,9 @@ itkLessEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status3 = checkConstOnImRes>( - filter->GetConstant1(), inputImageB, outputImage, FG, BG); - if (status3 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 3 passed" << std::endl; + ASSERT_EQ((checkConstOnImRes>( + filter->GetConstant1(), inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } // All objects should be automatically destroyed at this point - return EXIT_SUCCESS; } From d678cf4b7f50f065d0e2f94dad2bbc724e47e107 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sat, 2 May 2026 16:49:01 -0500 Subject: [PATCH 8/8] ENH: Convert itkEqualTest to itkEqualGTest --- .../ImageIntensity/test/CMakeLists.txt | 8 +-- .../{itkEqualTest.cxx => itkEqualGTest.cxx} | 55 ++++++------------- 2 files changed, 18 insertions(+), 45 deletions(-) rename Modules/Filtering/ImageIntensity/test/{itkEqualTest.cxx => itkEqualGTest.cxx} (83%) diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index 412c07642313..2286a109d0e8 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -23,7 +23,6 @@ set( itkDivideImageFilterTest2.cxx itkDivideOrZeroOutImageFilterTest.cxx itkEdgePotentialImageFilterTest.cxx - itkEqualTest.cxx itkExpImageFilterAndAdaptorTest.cxx itkExpNegativeImageFilterAndAdaptorTest.cxx itkHistogramMatchingImageFilterTest.cxx @@ -603,12 +602,6 @@ itk_add_test( ITKImageIntensityTestDriver itkNormalizeToConstantImageFilterTest ) -itk_add_test( - NAME itkEqualTest - COMMAND - ITKImageIntensityTestDriver - itkEqualTest -) itk_add_test( NAME itkClampImageFilterTest COMMAND @@ -738,6 +731,7 @@ set( itkAddImageFilterFrameGTest.cxx itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx + itkEqualGTest.cxx itkGreaterEqualGTest.cxx itkGreaterGTest.cxx itkLessEqualGTest.cxx diff --git a/Modules/Filtering/ImageIntensity/test/itkEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkEqualGTest.cxx similarity index 83% rename from Modules/Filtering/ImageIntensity/test/itkEqualTest.cxx rename to Modules/Filtering/ImageIntensity/test/itkEqualGTest.cxx index f2954f498cec..d287341d426f 100644 --- a/Modules/Filtering/ImageIntensity/test/itkEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkEqualGTest.cxx @@ -15,12 +15,15 @@ * limitations under the License. * *=========================================================================*/ -#include "itkCommonEnums.h" #include "itkLogicOpsFunctors.h" + #include "itkBinaryFunctorImageFilter.h" +#include "itkCommonEnums.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkLogicTestSupport.h" +#include "itkGTest.h" + namespace { // A bogus class for testing purposes. @@ -60,10 +63,9 @@ class Bogus }; } // namespace -int -itkEqualTest(int, char *[]) -{ +TEST(EqualImageFilter, ConvertedLegacyTest) +{ // Define the dimension of the images constexpr unsigned int myDimension{ 3 }; @@ -131,10 +133,7 @@ itkEqualTest(int, char *[]) { // Create a logic Filter const myFilterTypePointer filter = myFilterType::New(); - if (filter.IsNull()) - { - return EXIT_FAILURE; - } + ASSERT_FALSE(filter.IsNull()); // Connect the input images filter->SetInput1(inputImageA); @@ -153,15 +152,9 @@ itkEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status1 = - checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); - if (status1 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 1 passed" << std::endl; + ASSERT_EQ((checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } { @@ -182,14 +175,9 @@ itkEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); const PixelType C = filter->GetConstant2(); - const int status2 = checkImOnConstRes>( - inputImageA, C, outputImage, FG, BG); - if (status2 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 2 passed " << std::endl; + ASSERT_EQ((checkImOnConstRes>( + inputImageA, C, outputImage, FG, BG)), + EXIT_SUCCESS); } // Now try testing with constant : 3 == Im2 { @@ -209,26 +197,17 @@ itkEqualTest(int, char *[]) const PixelType FG = filter->GetFunctor().GetForegroundValue(); const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - const int status3 = checkConstOnImRes>( - filter->GetConstant1(), inputImageB, outputImage, FG, BG); - if (status3 == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - std::cout << "Step 3 passed" << std::endl; + ASSERT_EQ((checkConstOnImRes>( + filter->GetConstant1(), inputImageB, outputImage, FG, BG)), + EXIT_SUCCESS); } { // BinaryImageFilter using iFIB = itk::BinaryFunctorImageFilter, itk::Image, itk::Image, Bogus>; auto FIB = iFIB::New(); - if (FIB.IsNull()) - { - return EXIT_FAILURE; - } + ASSERT_FALSE(FIB.IsNull()); } // All objects should be automatically destroyed at this point - return EXIT_SUCCESS; }