Peano 4
Loading...
Searching...
No Matches
tarch::tests::TestCase Class Referenceabstract

Represents one test case. More...

#include <TestCase.h>

Inheritance diagram for tarch::tests::TestCase:
Collaboration diagram for tarch::tests::TestCase:

Public Member Functions

 TestCase (const std::string &testCaseName)
 Constructor.
 
virtual ~TestCase ()
 Destructor.
 
int getNumberOfErrors () const
 
std::string getTestCaseName () const
 
virtual void run ()=0
 This routine is triggered by the TestCaseCollection.
 

Protected Member Functions

 TestCase ()=delete
 

Protected Attributes

const std::string _testCaseName
 Name of the test case.
 
int _errors
 Error counter.
 
bool _error
 Indicate within macro if one specific validation failed.
 

Detailed Description

Represents one test case.

Every test case should be a subclass of this class implementing run(). Furthermore subtypes should use the assertion macros included to check any assumption. All the test cases are managed by the TestCaseCollection.

If you implement your own tests, inherit from this class, implement run() and add the test to a test case collection of your choice.

Implementation remarks

Whenever you write a test case implementation, we recommend to add the code block

#ifdef UseTestSpecificCompilerSettings
#pragma optimize("",off)
#endif

at the very beginning of your implementation and

#ifdef UseTestSpecificCompilerSettings
#pragma optimize("",on)
#endif

at the end of the implementation file.

Unit tests in libraries

If your unit test is part of a library, then simply registering the test is not enough, as the linker will remove the test again - assuming it is not invoked. I therefore decided not to rely on any automatic test case suites or so, but instead let the individual libraries build up their unit test suites manually. See the respective headers called UnitTests.

Author
Tobias Weinzierl

Definition at line 57 of file TestCase.h.

Constructor & Destructor Documentation

◆ TestCase() [1/2]

tarch::tests::TestCase::TestCase ( )
protecteddelete

◆ TestCase() [2/2]

tarch::tests::TestCase::TestCase ( const std::string & testCaseName)

Constructor.

Parameters
testCaseNameName of the test case. Should be a fully qualified name.

Definition at line 3 of file TestCase.cpp.

◆ ~TestCase()

tarch::tests::TestCase::~TestCase ( )
virtual

Destructor.

Definition at line 9 of file TestCase.cpp.

Member Function Documentation

◆ getNumberOfErrors()

int tarch::tests::TestCase::getNumberOfErrors ( ) const
Returns
Number of errors.

Definition at line 11 of file TestCase.cpp.

Referenced by main(), tarch::tests::TestCaseCollection::run(), and tarch::tests::TreeTestCaseCollection::run().

Here is the caller graph for this function:

◆ getTestCaseName()

std::string tarch::tests::TestCase::getTestCaseName ( ) const

Definition at line 15 of file TestCase.cpp.

Referenced by tarch::tests::TreeTestCaseCollection::addTestCase().

Here is the caller graph for this function:

◆ run()

virtual void tarch::tests::TestCase::run ( )
pure virtual

This routine is triggered by the TestCaseCollection.

Implemented in exahype2::fd::tests::SommerfeldBCTest, exahype2::fv::tests::InterpolationRestrictionTest, tarch::la::tests::LUDecompositionTest, tarch::la::tests::MatrixTest, tarch::la::tests::MatrixVectorTest, tarch::la::tests::ScalarTest, tarch::la::tests::VectorTest, tarch::plotter::griddata::unstructured::vtk::tests::VTKBinaryFileTestCase, tarch::tests::TestCaseCollection, tarch::tests::TreeTestCaseCollection, toolbox::multiprecision::tests::CompressedFloatingPointNumbersTest, exahype2::aderdg::tests::ADERDGTest, exahype2::dg::rusanov::tests::RiemannTest, exahype2::dg::tests::CellIntegralTest, exahype2::dg::tests::DGUtilsTest, exahype2::dg::tests::RiemannTest, exahype2::fv::rusanov::tests::ApplySplit1DRiemannToPatchTest, exahype2::fv::rusanov::tests::CopyPatchTest, exahype2::tests::KernelLaunchTest, peano4::grid::tests::GridControlEventTest, peano4::grid::tests::GridTraversalEventGeneratorTest, peano4::grid::tests::SpacetreeTest, peano4::parallel::tests::NodeTest, peano4::parallel::tests::PingPongTest, tarch::la::tests::DynamicMatrixTest, tarch::la::tests::GramSchmidtTest, tarch::mpi::tests::StringTest, toolbox::blockstructured::tests::InterpolationTest, toolbox::finiteelements::tests::StencilFactoryTest, toolbox::particles::tests::MultiscaleTransitionsTest, and toolbox::particles::tests::TestHelpers.

Referenced by main(), tarch::tests::TestCaseCollection::run(), and tarch::tests::TreeTestCaseCollection::run().

Here is the caller graph for this function:

Field Documentation

◆ _error

bool tarch::tests::TestCase::_error
protected

Indicate within macro if one specific validation failed.

Definition at line 73 of file TestCase.h.

◆ _errors

int tarch::tests::TestCase::_errors
protected

Error counter.

This counter is increased on errors iff you use the validate macros within your test cases.

Definition at line 68 of file TestCase.h.

◆ _testCaseName

const std::string tarch::tests::TestCase::_testCaseName
protected

Name of the test case.

Definition at line 62 of file TestCase.h.


The documentation for this class was generated from the following files: