Skip to content

Add new checking macros #1273

@jhlegarreta

Description

@jhlegarreta

Description

The ITK SW Guide states in the Messages in Tests subsection of its Coding Style Guide appendix:

  • What an ideal/informative message for missing parameters would be
  • What an ideal/informative message for regression checks would be.

Their adoption seems low. May be proposing macros to ease the process, reduce verbosity and reduce boilerplate code would help.

This does also apply to Examples.

Expected behavior

Missing parameter and regression check messages in tests and examples be consistent, e.g.:

if( argc != 3 )
  {
  std::cerr << "Missing parameters." << std::endl;
  std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv);
  std::cerr << " inputImage outputImage" << std::endl;
  return EXIT_FAILURE;
  }

or

bool tf = colors->SetColor( 0, 0, 0, 0, name );
if( tf != true )
  {
  std::cerr << "Test failed!" << std::endl;
  std::cerr << "Error in itk::ColorTable::SetColor" << std::endl;
  std::cerr << "Expected: " << true << ", but got: "
    << tf << std::endl;
  return EXIT_FAILURE;
  }

Printing the provided argument count and the argument values could also be considered, like in https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/NIFTI/test/itkNiftiReadWriteDirectionTest.cxx#L35

Actual behavior

Missing parameter and regression check messages in tests and examples are not consistent, e.g

  if (argc < 1)
  {
    std::cerr << "Missing Arguments: " << itkNameOfTestExecutableMacro(argv) << std::endl;
    return EXIT_FAILURE;
  }

Cases (Usage vs usage), etc.

and regressions are still less consistent.

Additional Information

Some of the names of the macros, e.g. itkNameOfTestExecutableMacro would need to be changed so that they honor also their use in ITK Examples.

And this would also mean placing these macros in a file other than itkTestingMacros.h, since they would also serve for the Examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:EnhancementImprovement of existing methods or implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions