DUNE-FEM (unstable)
A Simple helper class to organize your test suite. More...
#include <dune/common/test/testsuite.hh>
Public Member Functions | |
| TestSuite (ThrowPolicy policy, std::string name="") | |
| Create TestSuite. More... | |
| TestSuite (std::string name="", ThrowPolicy policy=ThrowOnRequired) | |
| Create TestSuite. More... | |
| CollectorStream | check (bool condition, std::string name="") |
| Check condition. More... | |
| CollectorStream | require (bool condition, std::string name="") |
| Check a required condition. More... | |
| template<class Exception = AnyException, class Expression > | |
| CollectorStream | checkThrow (Expression &&expr, std::string name="") |
| Checks that the expression throws. More... | |
| template<class Expression > | |
| CollectorStream | checkNoThrow (Expression &&expr, std::string name="") |
| Checks that the expression doesn't throw. More... | |
| template<class Exception = AnyException, class Expression > | |
| CollectorStream | requireThrow (Expression &&expr, std::string name="") |
| Requires that the expression throws. More... | |
| template<class Expression > | |
| CollectorStream | requireNoThrow (Expression &&expr, std::string name="") |
| Requires that the expression doesn't throw. More... | |
| void | subTest (const TestSuite &subTest) |
| Collect data from a sub-TestSuite. More... | |
| operator bool () const | |
| Check if this TestSuite failed. More... | |
| std::string | name () const |
| Query name. More... | |
| bool | report () const |
| Print a summary of this TestSuite. More... | |
| int | exit () const |
| Exit the test. More... | |
Detailed Description
A Simple helper class to organize your test suite.
Usage: Construct a TestSuite and call check() or require() with the condition to check and probably a name for this check. These methods return a stream such that you can pipe in an explanation accompanied by respective data to give a reason for a test failure.
Constructor & Destructor Documentation
◆ TestSuite() [1/2]
|
inline |
◆ TestSuite() [2/2]
|
inline |
Member Function Documentation
◆ check()
|
inline |
Check condition.
This will throw an exception if the check fails and if the AlwaysThrow policy was used on creation.
- Parameters
-
condition Checks if this is true and increases the failure counter if not. name A name to identify this check. Defaults to ""
- Returns
- A CollectorStream that can be used to create a diagnostic message to be printed on failure.
References name().
Referenced by checkNoThrow(), and checkThrow().
◆ checkNoThrow()
|
inline |
Checks that the expression doesn't throw.
This will throw an exception if the check fails and if the AlwaysThrow policy was used on creation.
- Parameters
-
expr A nullary functor that is expected not to throw an exception on evaluation name A name to identify this check. Defaults to ""
- Returns
- A CollectorStream that can be used to create a diagnostic message to be printed on failure.
- Example:
- CollectorStream checkNoThrow(Expression &&expr, std::string name="")Checks that the expression doesn't throw.Definition: testsuite.hh:163
◆ checkThrow()
|
inline |
Checks that the expression throws.
This will throw an exception if the check fails and if the AlwaysThrow policy was used on creation.
- Parameters
-
expr A nullary functor that is expected to throw an exception on evaluation that is of type Exceptionor any exception if the template parameter is omitted.name A name to identify this check. Defaults to ""
- Returns
- A CollectorStream that can be used to create a diagnostic message to be printed on failure.
- Example:
- CollectorStream checkThrow(Expression &&expr, std::string name="")Checks that the expression throws.Definition: testsuite.hh:144
◆ exit()
|
inline |
Exit the test.
This will print a summary of the test and return an integer to be used on program exit.
- Returns
- 1 if any of the executed tests failed, otherwise 0.
References report().
◆ name()
|
inline |
Query name.
- Returns
- Name of this TestSuite
Referenced by check(), checkNoThrow(), checkThrow(), report(), require(), requireNoThrow(), and requireThrow().
◆ operator bool()
|
inlineexplicit |
Check if this TestSuite failed.
- Returns
- False if any of the executed tests failed, otherwise true.
◆ report()
|
inline |
◆ require()
|
inline |
Check a required condition.
This will always throw an exception if the check fails.
- Parameters
-
condition Checks if this is true and increases the failure counter if not. name A name to identify this check. Defaults to ""
- Returns
- A CollectorStream that can be used to create a diagnostic message to be printed on failure.
References name().
Referenced by requireNoThrow(), and requireThrow().
◆ requireNoThrow()
|
inline |
Requires that the expression doesn't throw.
This will throw an exception if the check fails.
- Parameters
-
expr A nullary functor that is expected not to throw an exception on evaluation name A name to identify this check. Defaults to ""
- Returns
- A CollectorStream that can be used to create a diagnostic message to be printed on failure.
- Example:
- CollectorStream requireNoThrow(Expression &&expr, std::string name="")Requires that the expression doesn't throw.Definition: testsuite.hh:202
◆ requireThrow()
|
inline |
Requires that the expression throws.
This will throw an exception if the check fails.
- Parameters
-
expr A nullary functor that is expected to throw an exception on evaluation that is of type Exceptionor any exception if the template parameter is omitted.name A name to identify this check. Defaults to ""
- Returns
- A CollectorStream that can be used to create a diagnostic message to be printed on failure.
- Example:
- CollectorStream requireThrow(Expression &&expr, std::string name="")Requires that the expression throws.Definition: testsuite.hh:183
◆ subTest()
|
inline |
The documentation for this class was generated from the following file:
- dune/common/test/testsuite.hh
|
Legal Statements / Impressum |
Hosted by TU Dresden & Uni Heidelberg |
generated with Hugo v0.111.3
(Nov 2, 23:43, 2025)