Skip to content

Commit 7997ef3

Browse files
jhlegarretahjmjohnson
authored andcommitted
STYLE: Use the itkNameOfTestExecutableMacro macro in tests
Use the `itkNameOfTestExecutableMacro` macro to get the test name and prevent the test from crashing when `argv[0]` is null. Use the macro for tests that had the name of the test hard-coded. Add the input argument check for tests that were missing it.
1 parent a10264a commit 7997ef3

File tree

65 files changed

+146
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+146
-66
lines changed

Modules/Core/Common/test/itkSymmetricSecondRankTensorImageReadTest.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
#include <fstream>
2020
#include "itkImageFileReader.h"
2121
#include "itkImageFileWriter.h"
22+
#include "itkTestingMacros.h"
2223

2324

2425
int
2526
itkSymmetricSecondRankTensorImageReadTest(int ac, char * av[])
2627
{
2728
if (ac < 1)
2829
{
29-
std::cerr << "Usage: " << av[0] << " Input\n";
30+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(av) << " Input\n";
3031
return EXIT_FAILURE;
3132
}
3233

Modules/Core/Common/test/itkSymmetricSecondRankTensorImageWriteReadTest.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <fstream>
2020
#include "itkImageFileReader.h"
2121
#include "itkImageFileWriter.h"
22+
#include "itkTestingMacros.h"
2223

2324

2425
// Write a 2D SymmetricSecondRankTensor image to file and read it back again.
@@ -27,7 +28,7 @@ itkSymmetricSecondRankTensorImageWriteReadTest(int ac, char * av[])
2728
{
2829
if (ac < 1)
2930
{
30-
std::cerr << "Usage: " << av[0] << " Input\n";
31+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(av) << " Input\n";
3132
return EXIT_FAILURE;
3233
}
3334

Modules/Core/Mesh/test/itkVTKPolyDataReaderTest.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*=========================================================================*/
1818

1919
#include "itkVTKPolyDataReader.h"
20+
#include "itkTestingMacros.h"
2021

2122
#include <iostream>
2223

@@ -25,7 +26,7 @@ itkVTKPolyDataReaderTest(int argc, char * argv[])
2526
{
2627
if (argc != 2)
2728
{
28-
std::cerr << "Usage: itkVTKPolyDataReaderTest inputFilename" << std::endl;
29+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFilename" << std::endl;
2930
return EXIT_FAILURE;
3031
}
3132

Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataIOQuadEdgeMeshTest.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "itkQuadEdgeMesh.h"
2020
#include "itkVTKPolyDataReader.h"
2121
#include "itkVTKPolyDataWriter.h"
22+
#include "itkTestingMacros.h"
2223

2324
#include <iostream>
2425

@@ -35,7 +36,7 @@ itkVTKPolyDataIOQuadEdgeMeshTest(int argc, char * argv[])
3536

3637
if (argc != 3)
3738
{
38-
std::cerr << "Usage: itkVTKPolyDataReaderTest inputFilename outputFilename" << std::endl;
39+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFilename outputFilename" << std::endl;
3940
return EXIT_FAILURE;
4041
}
4142
else

Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataReaderQuadEdgeMeshTest.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "itkQuadEdgeMesh.h"
2020
#include "itkVTKPolyDataReader.h"
21+
#include "itkTestingMacros.h"
2122

2223
#include <iostream>
2324

@@ -26,7 +27,7 @@ itkVTKPolyDataReaderQuadEdgeMeshTest(int argc, char * argv[])
2627
{
2728
if (argc != 2)
2829
{
29-
std::cerr << "Usage: itkVTKPolyDataReaderTest inputFilename" << std::endl;
30+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFilename" << std::endl;
3031
return EXIT_FAILURE;
3132
}
3233

Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest2.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "itkImageFileWriter.h"
2424
#include "itkChangeInformationImageFilter.h"
2525
#include "itkTestingComparisonImageFilter.h"
26+
#include "itkTestingMacros.h"
2627
#include <fstream>
2728

2829
using PixelType = float;
@@ -68,7 +69,7 @@ itkGradientAnisotropicDiffusionImageFilterTest2(int ac, char * av[])
6869
{
6970
if (ac < 3)
7071
{
71-
std::cerr << "Usage: " << av[0] << " InputImage OutputImage\n";
72+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(av) << " InputImage OutputImage\n";
7273
return -1;
7374
}
7475

Modules/Filtering/Convolution/test/itkNormalizedCorrelationImageFilterTest.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
#include "itkImageFileReader.h"
2626
#include "itkImageFileWriter.h"
2727
#include "itkSimpleFilterWatcher.h"
28+
#include "itkTestingMacros.h"
2829

2930
int
3031
itkNormalizedCorrelationImageFilterTest(int ac, char * av[])
3132
{
3233
if (ac < 4)
3334
{
34-
std::cerr << "Usage: " << av[0] << " InputImage MaskImage OutputImage\n";
35+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(av) << " InputImage MaskImage OutputImage\n";
3536
return -1;
3637
}
3738

Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest2.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
#include "itkImageFileReader.h"
2222
#include "itkImageFileWriter.h"
2323
#include "itkSimpleFilterWatcher.h"
24+
#include "itkTestingMacros.h"
2425

2526
int
2627
itkBilateralImageFilterTest2(int ac, char * av[])
2728
{
2829
if (ac < 3)
2930
{
30-
std::cerr << "Usage: " << av[0] << " InputImage OutputImage\n";
31+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(av) << " InputImage OutputImage\n";
3132
return -1;
3233
}
3334

Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest3.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
#include "itkBilateralImageFilter.h"
2121
#include "itkImageFileReader.h"
2222
#include "itkImageFileWriter.h"
23+
#include "itkTestingMacros.h"
2324

2425

2526
int
2627
itkBilateralImageFilterTest3(int ac, char * av[])
2728
{
2829
if (ac < 3)
2930
{
30-
std::cerr << "Usage: " << av[0] << " InputImage BaselineImage\n";
31+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(av) << " InputImage BaselineImage\n";
3132
return -1;
3233
}
3334

Modules/Filtering/ImageFilterBase/test/itkMaskNeighborhoodOperatorImageFilterTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ itkMaskNeighborhoodOperatorImageFilterTest(int ac, char * av[])
2929
{
3030
if (ac < 3)
3131
{
32-
std::cerr << "Usage: " << av[0] << " InputImage OutputImage\n";
32+
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(av) << " InputImage OutputImage\n";
3333
return -1;
3434
}
3535

0 commit comments

Comments
 (0)