Skip to content

Commit

Permalink
STYLE: Improve style in FMUG filter test file
Browse files Browse the repository at this point in the history
Improve style in `itk::itkFastMarchingUpwindGradientImageFilter` class
test file:
- Prefer surrounding with the `ITK_TRY_EXPECT_NO_EXCEPTION` macro the
  filter update commands.
- Rely on the `ITK_TEST_SET_GET_VALUE` macro to test the Set/Get methods
  and values.
  • Loading branch information
jhlegarreta authored and hjmjohnson committed Mar 31, 2022
1 parent 341050b commit a2c3268
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ itkFastMarchingUpwindGradientTest(int, char *[])
marcher->SetInput(speedImage);
double stoppingValue = 100.0;
marcher->SetStoppingValue(stoppingValue);
ITK_TEST_SET_GET_VALUE(stoppingValue, marcher->GetStoppingValue());

auto generateGradientImage = true;
ITK_TEST_SET_GET_BOOLEAN(marcher, GenerateGradientImage, generateGradientImage);
Expand All @@ -163,11 +164,12 @@ itkFastMarchingUpwindGradientTest(int, char *[])
marcher->SetTargetOffset(targetOffset);
ITK_TEST_SET_GET_VALUE(targetOffset, marcher->GetTargetOffset());


// turn on debugging
// marcher->DebugOn();

// update the marcher
marcher->Update();
ITK_TRY_EXPECT_NO_EXCEPTION(marcher->Update());

// check the results
using FloatGradientImage = FloatFMType::GradientImageType;
Expand Down Expand Up @@ -222,13 +224,6 @@ itkFastMarchingUpwindGradientTest(int, char *[])
}


// Test that the stopping value of the algorithm is the one passed in.
if (itk::Math::NotAlmostEquals(marcher->GetStoppingValue(), stoppingValue))
{
std::cerr << "ERROR: Output stopping value does not equal initial stopping value!" << std::endl;
passed = false;
}

// Set up target points.
// The algorithm will stop when it reaches these points.
// This point is closest to the AlivePoint:
Expand Down Expand Up @@ -341,7 +336,9 @@ itkFastMarchingUpwindGradientTest(int, char *[])

double newStoppingValue = 10.0;
marcher->SetStoppingValue(newStoppingValue);
marcher->Update();

ITK_TRY_EXPECT_NO_EXCEPTION(marcher->Update());


if (itk::Math::NotExactlyEquals(marcher->GetStoppingValue(), newStoppingValue))
{
Expand All @@ -352,7 +349,6 @@ itkFastMarchingUpwindGradientTest(int, char *[])

// Exercise other member functions
std::cout << "SpeedConstant: " << marcher->GetSpeedConstant() << std::endl;
std::cout << "StoppingValue: " << marcher->GetStoppingValue() << std::endl;
std::cout << "CollectPoints: " << marcher->GetCollectPoints() << std::endl;

marcher->SetNormalizationFactor(2.0);
Expand Down

0 comments on commit a2c3268

Please sign in to comment.