|
dune-common 2.12-git
|
A Simple helper class to organize your test suite. More...
#include <dune/common/test/testsuite.hh>
Public Types | |
| enum | ThrowPolicy { AlwaysThrow , ThrowOnRequired } |
Static Protected Member Functions | |
| static std::string | composeMessage (std::string type, std::string name, std::string reason) |
| static void | announceCheckResult (bool throwException, std::string type, std::string name, std::string reason) |
Protected Attributes | |
| std::string | name_ |
| std::size_t | checks_ |
| std::size_t | failedChecks_ |
| bool | throwPolicy_ |
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.
Member Enumeration Documentation
◆ ThrowPolicy
Constructor & Destructor Documentation
◆ TestSuite() [1/2]
|
inline |
◆ TestSuite() [2/2]
|
inline |
Member Function Documentation
◆ announceCheckResult()
|
inlinestaticprotected |
◆ 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.
◆ 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
◆ composeMessage()
|
inlinestaticprotected |
◆ 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.
◆ name()
|
inline |
Query name.
- Returns
- Name of this TestSuite
◆ operator bool()
|
inlineexplicit |
Check if this TestSuite failed.
- Returns
- False if any of the executed tests failed, otherwise true.
◆ report()
|
inline |
Print a summary of this TestSuite.
- Returns
- False if any of the executed tests failed, otherwise true.
◆ 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.
◆ 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()
Collect data from a sub-TestSuite.
This will incorporate the accumulated results of the sub-TestSuite into this one. If the sub-TestSuite failed, i.e., contained failed checks, a summary will be printed.
Member Data Documentation
◆ checks_
|
protected |
◆ failedChecks_
|
protected |
◆ name_
|
protected |
◆ throwPolicy_
|
protected |
The documentation for this class was generated from the following file:
Legal Statements / Impressum | Hosted by TU Dresden & Uni Heidelberg | Generated by
1.9.8