|
Ocean
|
This class implements a simple test result accumulator. More...
#include <TestResult.h>
Public Member Functions | |
| TestResult ()=default | |
| Default constructor. | |
| TestResult (const std::string &testName) | |
| Constructor with test name. | |
| ~TestResult () | |
| Destructs this test result object. | |
| TestResult & | operator= (bool value) |
| Assignment operator for bool values. | |
| bool | succeeded () const |
| Returns whether this test result has succeeded. | |
| bool | succeededSoFar () const |
| Returns whether this test result has succeeded so far without marking it as checked. | |
| bool | anyTestExecuted () const |
| Returns whether any test was executed. | |
| const std::string & | testName () const |
| Returns the name of the test. | |
Protected Member Functions | |
| TestResult (const TestResult &)=delete | |
| Disabled copy constructor. | |
| TestResult (TestResult &&)=delete | |
| Disabled move constructor. | |
| TestResult & | operator= (const TestResult &)=delete |
| Disabled copy assignment operator. | |
| TestResult & | operator= (TestResult &&)=delete |
| Disabled move assignment operator. | |
Protected Attributes | |
| std::string | testName_ |
| The name of the test. | |
| bool | succeeded_ = true |
| True if the test has succeeded; false if any test has failed. | |
| bool | anyTestExecuted_ = false |
| True if at least one test was executed. | |
| bool | succeededChecked_ = false |
| True if the success state of this result has been checked via succeeded(). | |
This class implements a simple test result accumulator.
The test result starts as succeeded (true) and can only be set to failed (false), never back to succeeded. This is useful for accumulating multiple test results where any failure marks the entire test as failed. Additionally, at least one test must be executed for the result to succeed.
Usage example:
|
default |
Default constructor.
|
inlineexplicit |
Constructor with test name.
| testName | The name of the test, used for logging output |
|
inline |
Destructs this test result object.
|
protecteddelete |
Disabled copy constructor.
|
protecteddelete |
Disabled move constructor.
|
inline |
Returns whether any test was executed.
|
inline |
Assignment operator for bool values.
Only accepts false values; true values are ignored to prevent accidental resetting of a failed state. Marks that a test was executed.
| value | The boolean value to assign; only false will change the state |
|
protecteddelete |
Disabled copy assignment operator.
|
protecteddelete |
Disabled move assignment operator.
|
inline |
Returns whether this test result has succeeded.
This function must be called before the object is destroyed (checked in debug mode).
|
inline |
Returns whether this test result has succeeded so far without marking it as checked.
|
inline |
Returns the name of the test.
|
protected |
True if at least one test was executed.
|
protected |
True if the test has succeeded; false if any test has failed.
|
mutableprotected |
True if the success state of this result has been checked via succeeded().
|
protected |
The name of the test.