Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new checking macros #1273

Open
jhlegarreta opened this issue Sep 25, 2019 · 1 comment

Comments

@jhlegarreta
Copy link
Member

commented Sep 25, 2019

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;
  }

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.

@dzenanz

This comment has been minimized.

Copy link
Member

commented Sep 26, 2019

The most logical place would be itkMacro.h. And the bulk of the work would be changing the code to use the new macro.

Also, use of a macro instead of try/catch block in the examples would be confusing for new users, who are familiar with C++ try/catch but not (yet) familiar with ITK conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.