Skip to content

Commit

Permalink
STYLE: Improve itk::SimilarityIndexImageFilter class test file style
Browse files Browse the repository at this point in the history
Improve `itk::SimilarityIndexImageFilter` class test file style:
- Exercise the basic object methods using the
  `ITK_EXERCISE_BASIC_OBJECT_METHODS` macro.
- Use the `ITK_TRY_EXPECT_NO_EXCEPTION` macro to avoid boilerplate code
  when updating a filter that can trigger exceptions.
  • Loading branch information
jhlegarreta committed Oct 2, 2021
1 parent ed5c976 commit ada00b5
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "itkSimilarityIndexImageFilter.h"
#include "itkMath.h"
#include "itkTestingMacros.h"

int
itkSimilarityIndexImageFilterTest(int, char *[])
Expand Down Expand Up @@ -90,22 +91,14 @@ itkSimilarityIndexImageFilterTest(int, char *[])
using FilterType = itk::SimilarityIndexImageFilter<Image1Type, Image2Type>;
FilterType::Pointer filter = FilterType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, SimilarityIndexImageFilter, ImageToImageFilter);


filter->SetInput1(image1);
filter->SetInput2(image2);

try
{
filter->Update();
}
catch (const itk::ExceptionObject & err)
{
std::cout << "Caught an unexpected exception" << std::endl;
std::cout << err;
std::cout << "Test failed" << std::endl;
return EXIT_FAILURE;
}
ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());

filter->Print(std::cout);

// check results
FilterType::RealType trueOverlap = 0.5 / 0.75;
Expand Down

0 comments on commit ada00b5

Please sign in to comment.