InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

Add new checking macros

Open
#1,273 6 comments 1 reaction 0 assignees View on GitHub
type:Enhancement
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

### Description

The ITK SW Guide states in the `Messages in Tests` subsection of its [Coding Style Guide](https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide/blob/master/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex) 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`](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/TestKernel/include/itkTestingMacros.h), since they would also serve for the **Examples**.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.