Skip to content

Commit

Permalink
STYLE: Check properly FEM module test input arguments
Browse files Browse the repository at this point in the history
Check properly the input arguments in the `FEM` module tests to conform to the ITK SW
Guide style guidelines:
- Look for the necessary number of arguments.
- Remove the argument checking where the only argument is the program
  name.
- Use a consistent message about arguments being missing when an
  insufficient number of arguments is provided.
- Be clear about the input arguments expected: provide a minimal
  descriptive name for each of them in the error message if arguments
  are missing.
  • Loading branch information
jhlegarreta committed Jan 23, 2024
1 parent 444acec commit 60067a6
Show file tree
Hide file tree
Showing 28 changed files with 165 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearLineStressTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearQuadrilateralMembraneTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkFEMLinearSystemWrapperItpack.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearQuadrilateralStrainItpackTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearQuadrilateralStrainTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkFEMElement2DC0LinearQuadrilateralStress.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearQuadrilateralStressTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 2)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " outputFileName" << std::endl;
return EXIT_FAILURE;
}

itk::FEMFactoryBase::RegisterDefaultTypes();

constexpr unsigned int Dimension = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearTriangleMembraneTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearTriangleStrainTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0LinearTriangleStressTest(int argc, char * argv[])
{
if (argc != 3)
{
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
// the initialization of the itk::FEMFactoryBase::GetFactory()
if (argc < 1)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
return EXIT_FAILURE;
}
itk::FEMFactoryBase::GetFactory()->RegisterDefaultTypes();

using Solver2DType = itk::fem::Solver<2>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0QuadraticTriangleStrainTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC0QuadraticTriangleStressTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
7 changes: 5 additions & 2 deletions Modules/Numerics/FEM/test/itkFEMElement2DC1BeamTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement2DC1BeamTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
7 changes: 5 additions & 2 deletions Modules/Numerics/FEM/test/itkFEMElement2DTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMLinearSystemWrapperDenseVNL.h"
#include "itkFEMLinearSystemWrapperItpack.h"
#include "itkTestingMacros.h"

using Solver2DType = itk::fem::Solver<2>;

Expand All @@ -38,11 +39,13 @@ PrintK1(Solver2DType * S, int s);
int
itkFEMElement2DTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 2)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement3DC0LinearHexahedronMembraneTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement3DC0LinearHexahedronStrainTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
#include "itkFEMSolver.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement3DC0LinearTetrahedronMembraneTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
#include "itkSpatialObject.h"
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMSpatialObjectWriter.h"
#include "itkTestingMacros.h"

int
itkFEMElement3DC0LinearTetrahedronStrainTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName outputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
7 changes: 5 additions & 2 deletions Modules/Numerics/FEM/test/itkFEMElement3DTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "itkFEMSpatialObjectReader.h"
#include "itkFEMLinearSystemWrapperDenseVNL.h"
#include "itkFEMLinearSystemWrapperItpack.h"
#include "itkTestingMacros.h"

using SolverType = itk::fem::Solver<3>;

Expand All @@ -39,11 +40,13 @@ PrintK1(SolverType * S, int s);
int
itkFEMElement3DTest(int argc, char * argv[])
{
if (argc < 1)
if (argc != 3)
{
std::cerr << "Missing Spatial Object Filename" << std::endl;
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
8 changes: 8 additions & 0 deletions Modules/Numerics/FEM/test/itkFEMFactoryTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
*=========================================================================*/

#include "itkFEMFactoryBase.h"
#include "itkTestingMacros.h"

int
main(int argc, char ** argv)
{
if (argc != 2)
{
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputFileName" << std::endl;
return EXIT_FAILURE;
}

// Need to register default FEM object types,
// and setup spatialReader to recognize FEM types
// which is all currently done as a HACK in
Expand Down
Loading

0 comments on commit 60067a6

Please sign in to comment.