Peano
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

Referenced by tarch::tests::TestCaseCollection::addTestCase(), tarch::tests::TreeTestCaseCollection::addTestCase(), tarch::tests::TreeTestCaseCollection::addTestCase(), exahype2::fv::rusanov::tests::ApplySplit1DRiemannToPatchTest::ApplySplit1DRiemannToPatchTest(), exahype2::fd::tests::CCZ4KernelTest::CCZ4KernelTest(), exahype2::dg::tests::CellIntegralTest::CellIntegralTest(), toolbox::multiprecision::tests::CompressedFloatingPointNumbersTest::CompressedFloatingPointNumbersTest(), exahype2::fv::rusanov::tests::CopyPatchTest::CopyPatchTest(), exahype2::dg::tests::DGUtilsTest::DGUtilsTest(), tarch::la::tests::DynamicMatrixTest::DynamicMatrixTest(), tarch::la::tests::GramSchmidtTest::GramSchmidtTest(), peano4::grid::tests::GridControlEventTest::GridControlEventTest(), peano4::grid::tests::GridTraversalEventGeneratorTest::GridTraversalEventGeneratorTest(), toolbox::blockstructured::tests::IandRInMatricesTest::IandRInMatricesTest(), toolbox::blockstructured::tests::IandRSecondOrderTest::IandRSecondOrderTest(), toolbox::blockstructured::tests::IandRThirdOrderTest::IandRThirdOrderTest(), toolbox::blockstructured::tests::IandRVolumetricTest::IandRVolumetricTest(), exahype2::fv::tests::InterpolationRestrictionTest::InterpolationRestrictionTest(), toolbox::blockstructured::tests::InterpolationTest::InterpolationTest(), tarch::la::tests::LUDecompositionTest::LUDecompositionTest(), tarch::la::tests::MatrixTest::MatrixTest(), tarch::la::tests::MatrixVectorTest::MatrixVectorTest(), toolbox::particles::tests::MultiscaleTransitionsTest::MultiscaleTransitionsTest(), peano4::parallel::tests::NodeTest::NodeTest(), peano4::utils::tests::ParallelDForTest::ParallelDForTest(), peano4::parallel::tests::PingPongTest::PingPongTest(), exahype2::dg::rusanov::tests::RiemannTest::RiemannTest(), exahype2::dg::tests::RiemannTest::RiemannTest(), tarch::la::tests::ScalarTest::ScalarTest(), exahype2::fd::tests::SommerfeldBCTest::SommerfeldBCTest(), peano4::grid::tests::SpacetreeTest::SpacetreeTest(), peano4::stacks::tests::STDVectorStackOverObjectsWithSmartPointersTest::STDVectorStackOverObjectsWithSmartPointersTest(), toolbox::finiteelements::tests::StencilFactoryTest::StencilFactoryTest(), tarch::mpi::tests::StringTest::StringTest(), tarch::tests::TestCaseCollection::TestCaseCollection(), tarch::tests::TestCaseCollection::TestCaseCollection(), toolbox::particles::assignmentchecks::tests::TestHelpers::TestHelpers(), toolbox::particles::tests::TestHelpers::TestHelpers(), tarch::tests::TreeTestCaseCollection::TreeTestCaseCollection(), tarch::la::tests::VectorTest::VectorTest(), and tarch::plotter::griddata::unstructured::vtk::tests::VTKBinaryFileTestCase::VTKBinaryFileTestCase().

Here is the caller graph for this function:

◆ 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.

References _error, _errors, and _testCaseName.

◆ ~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.

References _errors.

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.

References _testCaseName.

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::dg::rusanov::tests::RiemannTest, exahype2::dg::tests::CellIntegralTest, exahype2::dg::tests::DGUtilsTest, exahype2::dg::tests::RiemannTest, exahype2::fd::tests::CCZ4KernelTest, exahype2::fd::tests::SommerfeldBCTest, exahype2::fv::rusanov::tests::ApplySplit1DRiemannToPatchTest, exahype2::fv::rusanov::tests::CopyPatchTest, exahype2::fv::tests::InterpolationRestrictionTest, peano4::grid::tests::GridControlEventTest, peano4::grid::tests::GridTraversalEventGeneratorTest, peano4::grid::tests::SpacetreeTest, peano4::parallel::tests::NodeTest, peano4::parallel::tests::PingPongTest, peano4::stacks::tests::STDVectorStackOverObjectsWithSmartPointersTest, peano4::utils::tests::ParallelDForTest, tarch::la::tests::DynamicMatrixTest, tarch::la::tests::GramSchmidtTest, tarch::la::tests::LUDecompositionTest, tarch::la::tests::MatrixTest, tarch::la::tests::MatrixVectorTest, tarch::la::tests::ScalarTest, tarch::la::tests::VectorTest, tarch::mpi::tests::StringTest, tarch::plotter::griddata::unstructured::vtk::tests::VTKBinaryFileTestCase, tarch::tests::TestCaseCollection, tarch::tests::TreeTestCaseCollection, toolbox::blockstructured::tests::IandRInMatricesTest, toolbox::blockstructured::tests::IandRSecondOrderTest, toolbox::blockstructured::tests::IandRThirdOrderTest, toolbox::blockstructured::tests::IandRVolumetricTest, toolbox::blockstructured::tests::InterpolationTest, toolbox::finiteelements::tests::StencilFactoryTest, toolbox::multiprecision::tests::CompressedFloatingPointNumbersTest, toolbox::particles::assignmentchecks::tests::TestHelpers, 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.

Referenced by TestCase().

◆ _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.

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

◆ _testCaseName

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

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