Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 4 additions & 28 deletions Modules/Core/Common/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ set(
itkDataObjectTest.cxx
itkDirectoryTest.cxx
itkExceptionObjectTest.cxx
itkExtractImage3Dto2DTest.cxx
itkExtractImageTest.cxx
itkFileOutputWindowTest.cxx
itkFixedArrayTest2.cxx
itkFloatingPointExceptionsTest.cxx
itkGaussianSpatialFunctionTest.cxx
itkImageAdaptorPipeLineTest.cxx
itkImageComputeOffsetAndIndexTest.cxx
itkImageDuplicatorTest.cxx
itkImageDuplicatorTest2.cxx
Expand Down Expand Up @@ -111,7 +108,6 @@ set(
itkObjectFactoryTest2.cxx
itkObjectFactoryTest3.cxx
itkObjectFactoryOnlyNewTest.cxx
itkMinimumMaximumImageCalculatorTest.cxx
itkSliceIteratorTest.cxx
itkImageRegionExclusionIteratorWithIndexTest.cxx
itkImageFillBufferTest.cxx
Expand Down Expand Up @@ -191,24 +187,6 @@ if(ITK_BUILD_SHARED_LIBS)
add_dependencies(ITKCommon2TestDriver FactoryTestLib)
endif()

itk_add_test(
NAME itkImageAdaptorPipeLineTest
COMMAND
ITKCommon1TestDriver
itkImageAdaptorPipeLineTest
)
itk_add_test(
NAME itkExtractImage3Dto2DTest
COMMAND
ITKCommon1TestDriver
itkExtractImage3Dto2DTest
)
itk_add_test(
NAME itkExtractImageTest
COMMAND
ITKCommon1TestDriver
itkExtractImageTest
)
itk_add_test(
NAME itkColorTableTest1
COMMAND
Expand Down Expand Up @@ -254,12 +232,6 @@ itk_add_test(
itkMultipleLogOutputTest
${TEMP}/test_multi.txt
)
itk_add_test(
NAME itkMinimumMaximumImageCalculatorTest
COMMAND
ITKCommon2TestDriver
itkMinimumMaximumImageCalculatorTest
)
itk_add_test(
NAME itkFixedArrayTest2
COMMAND
Expand Down Expand Up @@ -1510,13 +1482,16 @@ set(
itkDiffusionTensor3DGTest.cxx
itkEventObjectGTest.cxx
itkExceptionObjectGTest.cxx
itkExtractImage3Dto2DGTest.cxx
itkExtractImageGTest.cxx
itkFilterDispatchGTest.cxx
itkFixedArrayGTest.cxx
itkFloodFilledSpatialFunctionGTest.cxx
itkFloodFillIteratorGTest.cxx
itkGaussianDerivativeOperatorGTest.cxx
itkHashTableGTest.cxx
itkHeavisideStepFunctionGTest.cxx
itkImageAdaptorPipeLineGTest.cxx
itkImageBaseGTest.cxx
itkImageBufferRangeGTest.cxx
itkImageGTest.cxx
Expand All @@ -1541,6 +1516,7 @@ set(
itkMatrixGTest.cxx
itkMersenneTwisterRandomVariateGeneratorGTest.cxx
itkMetaDataDictionaryGTest.cxx
itkMinimumMaximumImageCalculatorGTest.cxx
itkModifiedTimeGTest.cxx
itkNeighborhoodAllocatorGTest.cxx
itkNumberToStringGTest.cxx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
*
*=========================================================================*/

#include <iostream>
#include "itkExtractImageFilter.h"
#include "itkRandomImageSource.h"
#include "itkMath.h"
#include "itkGTest.h"

int
itkExtractImage3Dto2DTest(int, char *[])
TEST(ExtractImage3Dto2D, ConvertedLegacyTest)
{
using Image3DType = itk::Image<unsigned char, 3>;
using Image2DType = itk::Image<unsigned char, 2>;
Expand Down Expand Up @@ -65,10 +63,7 @@ itkExtractImage3Dto2DTest(int, char *[])
const Image2DType::Pointer extractedImage = extract->GetOutput();
Image2DType::DirectionType identity;
identity.SetIdentity();
if (extractedImage->GetDirection() != identity)
{
return EXIT_FAILURE;
}
EXPECT_EQ(extractedImage->GetDirection(), identity);

// check CollapseToSubmatrix
extract = ExtractType::New();
Expand All @@ -86,13 +81,8 @@ itkExtractImage3Dto2DTest(int, char *[])
// remove first column/row, should obtain :
// 0 1
// 1 0
if (itk::Math::NotExactlyEquals(extract->GetOutput()->GetDirection()[0][0], 0) ||
itk::Math::NotExactlyEquals(extract->GetOutput()->GetDirection()[1][1], 0) ||
itk::Math::NotExactlyEquals(extract->GetOutput()->GetDirection()[0][1], 1) ||
itk::Math::NotExactlyEquals(extract->GetOutput()->GetDirection()[1][0], 1))
{
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
EXPECT_EQ(extract->GetOutput()->GetDirection()[0][0], 0);
EXPECT_EQ(extract->GetOutput()->GetDirection()[1][1], 0);
EXPECT_EQ(extract->GetOutput()->GetDirection()[0][1], 1);
EXPECT_EQ(extract->GetOutput()->GetDirection()[1][0], 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
*
*=========================================================================*/

#include <iostream>
#include "itkExtractImageFilter.h"
#include "itkFileOutputWindow.h"
#include "itkStreamingImageFilter.h"
#include "itkRandomImageSource.h"
#include "itkCastImageFilter.h"
#include "itkTestingMacros.h"
#include "itkGTest.h"
#include <set>

namespace
{
bool
void
ExtractImageInPlaceTest()
{
// This is to test the InPlace option
Expand All @@ -54,7 +53,7 @@ ExtractImageInPlaceTest()
extract->UpdateLargestPossibleRegion();

// check that the it was not run in-place
ITK_TEST_EXPECT_TRUE(source->GetOutput()->GetBufferedRegion().GetSize() != zeroSize);
EXPECT_NE(source->GetOutput()->GetBufferedRegion().GetSize(), zeroSize);

// add a filter between which will produce the requested region, and
// enable in-place operation
Expand All @@ -68,26 +67,23 @@ ExtractImageInPlaceTest()


// this buffer should still be ok
ITK_TEST_EXPECT_TRUE(source->GetOutput()->GetBufferedRegion().GetSize() != zeroSize);
EXPECT_NE(source->GetOutput()->GetBufferedRegion().GetSize(), zeroSize);

// this should have been taken by the in-place;
ITK_TEST_EXPECT_TRUE(filter->GetOutput()->GetBufferedRegion().GetSize() == zeroSize);
EXPECT_EQ(filter->GetOutput()->GetBufferedRegion().GetSize(), zeroSize);

// try with in-place disabled
extract->InPlaceOff();
extract->UpdateLargestPossibleRegion();


// these buffers should still be ok
ITK_TEST_EXPECT_TRUE(source->GetOutput()->GetBufferedRegion().GetSize() != zeroSize);
ITK_TEST_EXPECT_TRUE(filter->GetOutput()->GetBufferedRegion().GetSize() != zeroSize);

return EXIT_SUCCESS;
EXPECT_NE(source->GetOutput()->GetBufferedRegion().GetSize(), zeroSize);
EXPECT_NE(filter->GetOutput()->GetBufferedRegion().GetSize(), zeroSize);
}
} // namespace

int
itkExtractImageTest(int, char *[])
TEST(ExtractImage, ConvertedLegacyTest)
{
const itk::FileOutputWindow::Pointer fow = itk::FileOutputWindow::New();
fow->SetInstance(fow);
Expand Down Expand Up @@ -204,8 +200,7 @@ itkExtractImageTest(int, char *[])
}
else
{
std::cout << "ExtractImageFilter case 1 failed." << std::endl;
return EXIT_FAILURE;
FAIL() << "ExtractImageFilter case 1 failed.";
}

extract->GetOutput()->Print(std::cout);
Expand Down Expand Up @@ -284,8 +279,7 @@ itkExtractImageTest(int, char *[])
}
else
{
std::cout << "ExtractImageFilter case 2 failed." << std::endl;
return EXIT_FAILURE;
FAIL() << "ExtractImageFilter case 2 failed.";
}

// Case 3: Try extracting a single row
Expand Down Expand Up @@ -329,8 +323,7 @@ itkExtractImageTest(int, char *[])
}
else
{
std::cout << "ExtractImageFilter case 3 failed." << std::endl;
return EXIT_FAILURE;
FAIL() << "ExtractImageFilter case 3 failed.";
}

// Test streaming enumeration for ExtractImageFilterEnums::DirectionCollapseStrategy elements
Expand All @@ -345,5 +338,5 @@ itkExtractImageTest(int, char *[])
std::cout << "STREAMED ENUM VALUE ExtractImageFilterEnums::DirectionCollapseStrategy: " << ee << std::endl;
}

return ExtractImageInPlaceTest();
ExtractImageInPlaceTest();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#include "itkRedPixelAccessor.h"
#include "itkAddImageFilter.h"
#include "itkStdStreamStateSave.h"
#include "itkGTest.h"

int
itkImageAdaptorPipeLineTest(int, char *[])
TEST(ImageAdaptorPipeLine, ConvertedLegacyTest)
{
// Save the format stream variables for std::cout
// They will be restored when coutState goes out of scope
Expand Down Expand Up @@ -231,10 +231,5 @@ itkImageAdaptorPipeLineTest(int, char *[])
//-------------------------------------------------------------
auto myGraftedAdaptor = myAdaptorType::New();
myGraftedAdaptor->Graft(myAdaptor);
if (myGraftedAdaptor->GetPixelContainer() != myAdaptor->GetPixelContainer())
{
std::cerr << "Graft test failed." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
EXPECT_EQ(myGraftedAdaptor->GetPixelContainer(), myAdaptor->GetPixelContainer()) << "Graft test failed.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

#include "itkMinimumMaximumImageCalculator.h"
#include "itkObject.h"
#include "itkTestingMacros.h"
#include "itkGTest.h"

int
itkMinimumMaximumImageCalculatorTest(int, char *[])
TEST(MinimumMaximumImageCalculator, ConvertedLegacyTest)
{

using SizeType = itk::Size<3>;
Expand Down Expand Up @@ -83,18 +82,18 @@ itkMinimumMaximumImageCalculatorTest(int, char *[])
// Create and initialize the calculator
auto calculator = MinMaxCalculatorType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(calculator, MinimumMaximumImageCalculator, Object);
ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS(calculator, MinimumMaximumImageCalculator, Object);

calculator->SetImage(image);
calculator->Compute();

// Test minimum of intensity
ITK_TEST_SET_GET_VALUE(minimum, calculator->GetMinimum());
ITK_TEST_SET_GET_VALUE(minIntensityValueIndex, calculator->GetIndexOfMinimum());
EXPECT_EQ(minimum, calculator->GetMinimum());
EXPECT_EQ(minIntensityValueIndex, calculator->GetIndexOfMinimum());

// Test maximum of intensity
ITK_TEST_SET_GET_VALUE(maximum, calculator->GetMaximum());
ITK_TEST_SET_GET_VALUE(maxIntensityValueIndex, calculator->GetIndexOfMaximum());
EXPECT_EQ(maximum, calculator->GetMaximum());
EXPECT_EQ(maxIntensityValueIndex, calculator->GetIndexOfMaximum());

// Set the region over which perform the computations
constexpr itk::Size<3> regionSize{ { 4, 4, 4 } };
Expand All @@ -118,15 +117,12 @@ itkMinimumMaximumImageCalculatorTest(int, char *[])
calculator->ComputeMinimum();

// Test minimum of intensity
ITK_TEST_SET_GET_VALUE(minimum, calculator->GetMinimum());
ITK_TEST_SET_GET_VALUE(minIntensityValueIndex, calculator->GetIndexOfMinimum());
EXPECT_EQ(minimum, calculator->GetMinimum());
EXPECT_EQ(minIntensityValueIndex, calculator->GetIndexOfMinimum());

calculator->ComputeMaximum();

// Test maximum of intensity
ITK_TEST_SET_GET_VALUE(maximum, calculator->GetMaximum());
ITK_TEST_SET_GET_VALUE(maxIntensityValueIndex, calculator->GetIndexOfMaximum());


return EXIT_SUCCESS;
EXPECT_EQ(maximum, calculator->GetMaximum());
EXPECT_EQ(maxIntensityValueIndex, calculator->GetIndexOfMaximum());
}
Loading