diff --git a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt index a730c151e696..2286a109d0e8 100644 --- a/Modules/Filtering/ImageIntensity/test/CMakeLists.txt +++ b/Modules/Filtering/ImageIntensity/test/CMakeLists.txt @@ -23,17 +23,12 @@ set( itkDivideImageFilterTest2.cxx itkDivideOrZeroOutImageFilterTest.cxx itkEdgePotentialImageFilterTest.cxx - itkEqualTest.cxx itkExpImageFilterAndAdaptorTest.cxx itkExpNegativeImageFilterAndAdaptorTest.cxx - itkGreaterEqualTest.cxx - itkGreaterTest.cxx itkHistogramMatchingImageFilterTest.cxx itkImageAdaptorNthElementTest.cxx itkIntensityWindowingImageFilterTest.cxx itkInvertIntensityImageFilterTest.cxx - itkLessEqualTest.cxx - itkLessTest.cxx itkLog10ImageFilterAndAdaptorTest.cxx itkLogImageFilterAndAdaptorTest.cxx itkMagnitudeAndPhaseToComplexImageFilterTest.cxx @@ -48,7 +43,6 @@ set( itkNaryMaximumImageFilterTest.cxx itkNormalizeImageFilterTest.cxx itkNormalizeToConstantImageFilterTest.cxx - itkNotEqualTest.cxx itkNotImageFilterTest.cxx itkNthElementPixelAccessorTest2.cxx itkOrImageFilterTest.cxx @@ -59,12 +53,10 @@ set( itkRescaleIntensityImageFilterTest.cxx itkRGBToLuminanceImageFilterAndAdaptorTest.cxx itkRGBToVectorAdaptImageFilterTest.cxx - itkRoundImageFilterTest.cxx itkShiftScaleImageFilterTest.cxx itkSigmoidImageFilterTest.cxx itkSinImageFilterAndAdaptorTest.cxx itkSqrtImageFilterAndAdaptorTest.cxx - itkSquareImageFilterTest.cxx itkSubtractImageFilterTest.cxx itkSymmetricEigenAnalysisImageFilterTest.cxx itkTanImageFilterAndAdaptorTest.cxx @@ -410,12 +402,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 @@ -616,42 +602,6 @@ itk_add_test( ITKImageIntensityTestDriver itkNormalizeToConstantImageFilterTest ) -itk_add_test( - NAME itkEqualTest - COMMAND - ITKImageIntensityTestDriver - itkEqualTest -) -itk_add_test( - NAME itkNotEqualTest - COMMAND - ITKImageIntensityTestDriver - itkNotEqualTest -) -itk_add_test( - NAME itkGreaterEqualTest - COMMAND - ITKImageIntensityTestDriver - itkGreaterEqualTest -) -itk_add_test( - NAME itkGreaterTest - COMMAND - ITKImageIntensityTestDriver - itkGreaterTest -) -itk_add_test( - NAME itkLessEqualTest - COMMAND - ITKImageIntensityTestDriver - itkLessEqualTest -) -itk_add_test( - NAME itkLessTest - COMMAND - ITKImageIntensityTestDriver - itkLessTest -) itk_add_test( NAME itkClampImageFilterTest COMMAND @@ -676,12 +626,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 +731,14 @@ set( itkAddImageFilterFrameGTest.cxx itkArithmeticOpsFunctorsTest.cxx itkBitwiseOpsFunctorsTest.cxx + itkEqualGTest.cxx + itkGreaterEqualGTest.cxx + itkGreaterGTest.cxx + itkLessEqualGTest.cxx + itkLessGTest.cxx + itkNotEqualGTest.cxx + itkRoundImageFilterGTest.cxx + itkSquareImageFilterGTest.cxx ) if(MSVC) 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; }