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
2 changes: 1 addition & 1 deletion Modules/Core/Common/test/itkOctreeTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ itkOctreeTest(int, char *[])
if (mapped != y)
{
std::cerr << "Error comparing Input and Output of Octree" << std::endl;
return -1;
return EXIT_FAILURE;
}
++ri;
++ri2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "itkBinaryDilateImageFilter.h"
#include "itkBinaryBallStructuringElement.h"
#include "itkSimpleFilterWatcher.h"
#include "itkTestingMacros.h"

int
itkBinaryDilateImageFilterTest(int, char *[])
Expand Down Expand Up @@ -143,33 +144,26 @@ itkBinaryDilateImageFilterTest(int, char *[])
std::cout << "filter->GetDilateValue(): " << value << std::endl;

// Execute the filter
try
{
ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());

filter->Update();
// Create an iterator for going through the image output
myIteratorType it2(outputImage, outputImage->GetBufferedRegion());

// Print the content of the result image
std::cout << "Result " << std::endl;
i = 0;
while (!it2.IsAtEnd())
{
std::cout << it2.Get() << " ";
++it2;
// Create an iterator for going through the image output
myIteratorType it2(outputImage, outputImage->GetBufferedRegion());

// Print the content of the result image
std::cout << "Result " << std::endl;
i = 0;
while (!it2.IsAtEnd())
{
std::cout << it2.Get() << " ";
++it2;

if (++i % 20 == 0)
{
std::cout << std::endl;
}
if (++i % 20 == 0)
{
std::cout << std::endl;
}
}

catch (const itk::ExceptionObject & e)
{
std::cerr << "Exception caught during filter Update\n" << e;
return -1;
}

// All objects should be automatically destroyed at this point

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "itkBinaryErodeImageFilter.h"
#include "itkBinaryBallStructuringElement.h"
#include "itkSimpleFilterWatcher.h"
#include "itkTestingMacros.h"

int
itkBinaryErodeImageFilterTest(int, char *[])
Expand Down Expand Up @@ -143,32 +144,24 @@ itkBinaryErodeImageFilterTest(int, char *[])
std::cout << "filter->GetErodeValue(): " << value << std::endl;

// Execute the filter
try
{

filter->Update();
// Create an iterator for going through the image output
myIteratorType it2(outputImage, outputImage->GetBufferedRegion());
ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());

// Print the content of the result image
std::cout << "Result " << std::endl;
i = 0;
while (!it2.IsAtEnd())
{
std::cout << it2.Get() << " ";
++it2;

if (++i % 20 == 0)
{
std::cout << std::endl;
}
}
}
// Create an iterator for going through the image output
myIteratorType it2(outputImage, outputImage->GetBufferedRegion());

catch (const itk::ExceptionObject & e)
// Print the content of the result image
std::cout << "Result " << std::endl;
i = 0;
while (!it2.IsAtEnd())
{
std::cerr << "Exception caught during filter Update\n" << e;
return -1;
std::cout << it2.Get() << " ";
++it2;

if (++i % 20 == 0)
{
std::cout << std::endl;
}
}

// All objects should be automatically destroyed at this point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "itkErodeObjectMorphologyImageFilter.h"
#include "itkBinaryBallStructuringElement.h"
#include "itkSimpleFilterWatcher.h"
#include "itkTestingMacros.h"

int
itkErodeObjectMorphologyImageFilterTest(int, char *[])
Expand Down Expand Up @@ -158,31 +159,23 @@ itkErodeObjectMorphologyImageFilterTest(int, char *[])
std::cout << "filter->GetErodeValue(): " << value << std::endl;

// Execute the filter
try
{
filter->Update();
// Create an iterator for going through the image output
myIteratorType it2(outputImage, outputImage->GetBufferedRegion());

// Print the content of the result image
std::cout << "Result " << std::endl;
i = 0;
while (!it2.IsAtEnd())
{
std::cout << it2.Get() << " ";
++it2;
ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());

if (++i % 20 == 0)
{
std::cout << std::endl;
}
}
}
// Create an iterator for going through the image output
myIteratorType it2(outputImage, outputImage->GetBufferedRegion());

catch (const itk::ExceptionObject & e)
// Print the content of the result image
std::cout << "Result " << std::endl;
i = 0;
while (!it2.IsAtEnd())
{
std::cerr << "Exception caught during filter Update\n" << e;
return -1;
std::cout << it2.Get() << " ";
++it2;

if (++i % 20 == 0)
{
std::cout << std::endl;
}
}

// All objects should be automatically destroyed at this point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ itkNormalizedCorrelationImageFilterTest(int argc, char * argv[])
if (argc < 4)
{
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " InputImage MaskImage OutputImage\n";
return -1;
return EXIT_FAILURE;
}

constexpr unsigned int Dimension = 2;
Expand Down Expand Up @@ -99,20 +99,8 @@ itkNormalizedCorrelationImageFilterTest(int argc, char * argv[])
writer->SetInput(threshold->GetOutput());
writer->SetFileName(argv[3]);

try
{
writer->Update();
}
catch (const itk::ExceptionObject & e)
{
std::cerr << "Exception detected: " << e.GetDescription();
return -1;
}
catch (...)
{
std::cerr << "Some other exception occurred" << std::endl;
return -2;
}
ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());


return EXIT_SUCCESS;
}
45 changes: 16 additions & 29 deletions Modules/Filtering/ImageCompare/test/itkSTAPLEImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,20 @@ Stapler<VDimension>::Execute()
// Set the inputs
for (i = 0; i < number_of_files; ++i)
{
try
{
reader = itk::ImageFileReader<InputImageType>::New();
reader->SetFileName(m_Files[i].c_str());
reader->Update();
m_Stapler->SetInput(itk::Math::CastWithRangeCheck<unsigned int>(i), reader->GetOutput());
}
catch (const itk::ExceptionObject & e)
{
std::cerr << e << std::endl;
return -1;
}
}
reader = itk::ImageFileReader<InputImageType>::New();
reader->SetFileName(m_Files[i].c_str());

try
{
writer->SetFileName(m_OutputFile.c_str());
writer->SetInput(m_Stapler->GetOutput());
writer->Update();
}
catch (const itk::ExceptionObject & e)
{
std::cerr << e << std::endl;
return -2;
ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update());

m_Stapler->SetInput(itk::Math::CastWithRangeCheck<unsigned int>(i), reader->GetOutput());
}

return 0;
writer->SetFileName(m_OutputFile.c_str());
writer->SetInput(m_Stapler->GetOutput());

ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());

return EXIT_SUCCESS;
}


Expand All @@ -207,7 +194,7 @@ itkSTAPLEImageFilterTest(int argc, char * argv[])
<< " file_dimensionality output.mhd foreground_value confidence_weight "
"file1 file2 ... fileN"
<< std::endl;
return -1;
return EXIT_FAILURE;
}

if (::std::stoi(argv[1]) == 2)
Expand All @@ -221,7 +208,7 @@ itkSTAPLEImageFilterTest(int argc, char * argv[])
else
{
std::cerr << "Only 2D and 3D data is currently supported" << std::endl;
return -2;
return EXIT_FAILURE;
}

for (i = 0; i < argc - 5; ++i)
Expand All @@ -235,10 +222,10 @@ itkSTAPLEImageFilterTest(int argc, char * argv[])

// Execute the stapler
int ret = stapler->Execute();
if (ret != 0)
if (ret != EXIT_SUCCESS)
{
std::cerr << "Stapler failed! Returned error code " << ret << "." << std::endl;
return -3;
std::cerr << "Stapler failed!" << std::endl;
return EXIT_FAILURE;
}

double avg_p = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ itkLaplacianRecursiveGaussianImageFilterTest(int argc, char * argv[])
{
std::cerr << "Usage: " << std::endl;
std::cerr << itkNameOfTestExecutableMacro(argv) << " inputImage outputImage " << std::endl;
return -1;
return EXIT_FAILURE;
}

const char * inputFilename = argv[1];
Expand Down Expand Up @@ -99,16 +99,8 @@ itkLaplacianRecursiveGaussianImageFilterTest(int argc, char * argv[])
bool bNormalizeAcrossScale = lapFilter->GetNormalizeAcrossScale();
std::cout << "lapFilter->GetNormalizeAcrossScale(): " << bNormalizeAcrossScale << std::endl;

try
{
writer->Update();
}
catch (const itk::ExceptionObject & err)
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());


return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ itkMaskNeighborhoodOperatorImageFilterTest(int argc, char * argv[])
if (argc < 3)
{
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " InputImage OutputImage\n";
return -1;
return EXIT_FAILURE;
}

constexpr unsigned int Dimension = 2;
Expand Down Expand Up @@ -128,20 +128,7 @@ itkMaskNeighborhoodOperatorImageFilterTest(int argc, char * argv[])
writer->SetInput(rescaler->GetOutput());
writer->SetFileName(argv[2]);

try
{
writer->Update();
}
catch (const itk::ExceptionObject & e)
{
std::cerr << "Exception detected: " << e.GetDescription();
return -1;
}
catch (...)
{
std::cerr << "Some other exception occurred" << std::endl;
return -2;
}
ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());

return EXIT_SUCCESS;
}
Loading