Skip to content

Commit

Permalink
STYLE: Improve style in miscellaneous LabelMap module tests
Browse files Browse the repository at this point in the history
Improve style in miscellaneous `LabelMap` module tests:
- Use the `ITK_TEST_SET_GET_BOOLEAN` macro to test boolean ivars and
  avoid boilerplate code.
- Stick to the ITK coding style to name constants (start names with
  capitals).
- Make the test argument check message be as compact as possible and
  avoid spanning over several lines unnecessarily.
- Remove uninformative comments in tests.
  • Loading branch information
jhlegarreta authored and dzenanz committed Jan 2, 2023
1 parent e9bc06e commit 3d6a2e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
Expand Up @@ -35,20 +35,18 @@ itkBinaryReconstructionLabelMapFilterTest(int argc, char * argv[])
if (argc != 5)
{
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv);
std::cerr << " input marker output";
std::cerr << " fg";
std::cerr << std::endl;
std::cerr << " input marker output fg" << std::endl;
return EXIT_FAILURE;
}

constexpr unsigned int dim = 3;
constexpr unsigned int Dimension = 3;

using PixelType = unsigned char;
using AttributeValueType = bool;

using ImageType = itk::Image<PixelType, dim>;
using ImageType = itk::Image<PixelType, Dimension>;

using AttributeLabelObjectType = itk::AttributeLabelObject<PixelType, dim, AttributeValueType>;
using AttributeLabelObjectType = itk::AttributeLabelObject<PixelType, Dimension, AttributeValueType>;
using LabelMapType = itk::LabelMap<AttributeLabelObjectType>;

using ReaderType = itk::ImageFileReader<ImageType>;
Expand All @@ -65,7 +63,6 @@ itkBinaryReconstructionLabelMapFilterTest(int argc, char * argv[])
using LabelReconstructionType = itk::BinaryReconstructionLabelMapFilter<LabelMapType, ImageType>;
auto reconstruction = LabelReconstructionType::New();

// testing get and set macros for Lambda
int fg = std::stoi(argv[4]);
reconstruction->SetForegroundValue(fg);
ITK_TEST_SET_GET_VALUE(fg, reconstruction->GetForegroundValue());
Expand Down
Expand Up @@ -50,29 +50,17 @@ itkLabelShapeOpeningImageFilterTest1(int argc, char * argv[])

opening->SetInput(reader->GetOutput());

// testing get/set BackgroundValue macro
int BackgroundValue = (std::stoi(argv[3]));
opening->SetBackgroundValue(BackgroundValue);
ITK_TEST_SET_GET_VALUE(BackgroundValue, opening->GetBackgroundValue());

// testing get and set macros for Lambda
double lambda = std::stod(argv[4]);
opening->SetLambda(lambda);
ITK_TEST_SET_GET_VALUE(lambda, opening->GetLambda());

// testing boolean macro for ReverseOrdering
opening->ReverseOrderingOn();
ITK_TEST_SET_GET_VALUE(true, opening->GetReverseOrdering());

opening->ReverseOrderingOff();
ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering());

// testing get and set macros or ReverseOrdering
bool reverseOrdering = std::stoi(argv[5]);
opening->SetReverseOrdering(reverseOrdering);
ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering());
ITK_TEST_SET_GET_BOOLEAN(opening, ReverseOrdering, reverseOrdering);

// testing get and set macros for Attribute
LabelOpeningType::AttributeType attribute = std::stoi(argv[6]);
opening->SetAttribute(attribute);
ITK_TEST_SET_GET_VALUE(attribute, opening->GetAttribute());
Expand Down

0 comments on commit 3d6a2e1

Please sign in to comment.