Skip to content

Commit

Permalink
STYLE: Use the itkNameOfTestExecutableMacro macro in tests
Browse files Browse the repository at this point in the history
Use the `itkNameOfTestExecutableMacro` macro to get the test name.

Take advantage of the commit to improve the input argument check
message, conforming to the ITK SW Guide style guidelines, and re-using
messages where appropriate to avoid duplicating code.
  • Loading branch information
jhlegarreta authored and dzenanz committed Apr 16, 2022
1 parent 5ff58ba commit ff80a24
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
10 changes: 9 additions & 1 deletion Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@
*=========================================================================*/

#include "itkQuadEdgeMeshBoundaryEdgesMeshFunction.h"
#include "itkTestingMacros.h"


int
itkQuadEdgeMeshAddFaceTest1(int argc, char * argv[])
{
if (argc != 2)
{
std::cout << "Requires 1 argument" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " testType [0..5]:" << std::endl;
std::cerr << " 0-Test regular cases (i)." << std::endl;
std::cerr << " 1-Test regular cases (ii)." << std::endl;
std::cerr << " 2-Test merging two triangulations with opposite orientations." << std::endl;
std::cerr << " 3-Test adding a quadrangle." << std::endl;
std::cerr << " 4-Test adding a face with five edges." << std::endl;
std::cerr << " 5-Test adding with a Moebius strip." << std::endl;
return EXIT_FAILURE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@

#include "itkQuadEdgeMeshEulerOperatorJoinVertexFunction.h"
#include "itkQuadEdgeMeshEulerOperatorsTestHelper.h"
#include "itkTestingMacros.h"
#include <sstream>

int
itkQuadEdgeMeshEulerOperatorJoinVertexTest(int argc, char * argv[])
{
std::stringstream inputArgumentMessage;
inputArgumentMessage << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputType [0..5]:" << std::endl;
inputArgumentMessage << " 0-Test with a square mesh with only triangles." << std::endl;
inputArgumentMessage << " 1-Test with a square mesh with only quads." << std::endl;
inputArgumentMessage << " 2-Test with a tetraedron mesh with triangles." << std::endl;
inputArgumentMessage << " 3-Test with a samosa." << std::endl;
inputArgumentMessage << " 4-Test with an isolated edge." << std::endl;
inputArgumentMessage << " 5-Test with a square mesh with one centered hole" << std::endl;

if (argc < 2)
{
std::cout << "*** ERROR ***" << std::endl;
std::cout << "Requires one argument: " << std::endl;
std::cout << " 0-Test with a square mesh with only triangles." << std::endl;
std::cout << " 1-Test with a square mesh with only quads." << std::endl;
std::cout << " 2-Test with a tetraedron mesh with triangles." << std::endl;
std::cout << " 3-Test with a samosa." << std::endl;
std::cout << " 4-Test with an isolated edge." << std::endl;
std::cout << " 5-Test with a square mesh with one centered hole" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << inputArgumentMessage.str();
return EXIT_FAILURE;
}

Expand All @@ -41,14 +46,8 @@ itkQuadEdgeMeshEulerOperatorJoinVertexTest(int argc, char * argv[])

if ((InputType > 5) || (InputType < 0))
{
std::cout << "*** ERROR ***" << std::endl;
std::cout << "Requires one argument: " << std::endl;
std::cout << " 0-Test with a square mesh with only triangles." << std::endl;
std::cout << " 1-Test with a square mesh with only quads." << std::endl;
std::cout << " 2-Test with a tetraedron mesh with triangles." << std::endl;
std::cout << " 3-Test with a samosa." << std::endl;
std::cout << " 4-Test with an isolated edge." << std::endl;
std::cout << " 5-Test with a square mesh with one centered hole" << std::endl;
std::cerr << "Wrong parameter value." << std::endl;
std::cerr << inputArgumentMessage.str();
return EXIT_FAILURE;
}

Expand Down
4 changes: 3 additions & 1 deletion Modules/IO/Mesh/test/itkMeshFileReadWriteTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
#include "itkQuadEdgeMesh.h"

#include "itkMeshFileTestHelper.h"
#include "itkTestingMacros.h"

int
itkMeshFileReadWriteTest(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Invalid commands, You need input and output mesh file name " << std::endl;
std::cerr << "Missing Parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

Expand Down
3 changes: 2 additions & 1 deletion Modules/Video/Core/test/itkImageToVideoFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ itkImageToVideoFilterTest(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << argv[0];
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv);
std::cerr << " inputFile outputFile";
std::cerr << std::endl;
return EXIT_FAILURE;
Expand Down

0 comments on commit ff80a24

Please sign in to comment.