Ocean
|
This class implements a helper class to validate tests. More...
Public Member Functions | |
Validation ()=default | |
Default constructor, by default the verified has succeeded. More... | |
Validation (RandomGenerator &randomGenerator) | |
Creates a new validation object associated with a random generator, by default the verified has succeeded. More... | |
~Validation () | |
Destructs this validation object. More... | |
void | expectTrue (const bool value) |
Informs this validation object that a value is expected to be True. More... | |
void | expectTrue (const bool value, const char *file, const int line) |
Informs this validation object that a value is expected to be True. More... | |
void | expectFalse (const bool value) |
Informs this validation object that a value is expected to be False. More... | |
void | expectFalse (const bool value, const char *file, const int line) |
Informs this validation object that a value is expected to be False. More... | |
template<typename T > | |
void | expectEqual (const T &value0, const T &value1) |
Informs this validation object that a value is expected to be equal to another value. More... | |
template<typename T > | |
void | expectEqual (const T &value0, const T &value1, const char *file, const int line) |
Informs this validation object that a value is expected to be equal to another value. More... | |
template<typename T > | |
void | expectLess (const T &value0, const T &value1) |
Informs this validation object that a value is expected to be less than another value. More... | |
template<typename T > | |
void | expectLess (const T &value0, const T &value1, const char *file, const int line) |
Informs this validation object that a value is expected to be less than another value. More... | |
template<typename T > | |
void | expectLessEqual (const T &value0, const T &value1) |
Informs this validation object that a value is expected to be less than or equal to another value. More... | |
template<typename T > | |
void | expectLessEqual (const T &value0, const T &value1, const char *file, const int line) |
Informs this validation object that a value is expected to be less than or equal to another value. More... | |
template<typename T > | |
void | expectGreater (const T &value0, const T &value1) |
Informs this validation object that a value is expected to be greater than another value. More... | |
template<typename T > | |
void | expectGreater (const T &value0, const T &value1, const char *file, const int line) |
Informs this validation object that a value is expected to be greater than another value. More... | |
template<typename T > | |
void | expectGreaterEqual (const T &value0, const T &value1) |
Informs this validation object that a value is expected to be greater than or equal to another value. More... | |
template<typename T > | |
void | expectGreaterEqual (const T &value0, const T &value1, const char *file, const int line) |
Informs this validation object that a value is expected to be greater than or equal to another value. More... | |
template<typename T > | |
void | expectInsideRange (const T &lower, const T &value, const T &upper) |
Informs this validation object that a value is expected to be inside a range. More... | |
template<typename T > | |
void | expectInsideRange (const T &lower, const T &value, const T &upper, const char *file, const int line) |
Informs this validation object that a value is expected to be inside a range. More... | |
void | setFailed () |
Explicitly sets the validation to be failed. More... | |
void | setFailed (const char *file, const int line) |
Explicitly sets the validation to be failed. More... | |
bool | succeeded () const |
Returns if this validation has succeeded. More... | |
std::string | randomGeneratorOutput () const |
Returns a string containing the random generator's initial seed, if any. More... | |
Protected Member Functions | |
Validation (const Validation &)=delete | |
Disabled copy constructor. More... | |
void | setSucceededFalse () |
Sets the succeeded state to false. More... | |
Protected Attributes | |
bool | succeeded_ = true |
True, if the validation has succeeded; False, if the validation has failed. More... | |
RandomGenerator * | randomGenerator_ = nullptr |
Optional random generator object which will be used during validation. More... | |
bool | succeededChecked_ = false |
True, if the success state of this validation has been checked. More... | |
This class implements a helper class to validate tests.
The following example shows how to use Validation and calling the functions directly.
In case of an error, no further information will be provided:
The following example shows how to use Validation and calling the functions directly but also providing FILE and LINE macro parameters.
In case of an error, additional in information about the location will be provided:
The following example shows how to use Validation while not calling the object's functions directly but using the corresponding macros.
In case of an error, additional in information about the location will be provided:
|
default |
Default constructor, by default the verified has succeeded.
|
inlineexplicit |
Creates a new validation object associated with a random generator, by default the verified has succeeded.
randomGenerator | The random generator which will be used during verification |
|
inline |
Destructs this validation object.
|
protecteddelete |
Disabled copy constructor.
|
inline |
Informs this validation object that a value is expected to be equal to another value.
In case the both values are not identical, this validation object will not succeed.
value0 | The first value to compare |
value1 | The second value to compare |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be equal to another value.
In case the both values are not identical, this validation object will not succeed.
This function will also write a message to the error log.
value0 | The first value to compare |
value1 | The second value to compare |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be False.
In case the value is True, this validation object will not succeed.
value | The value to be expected False |
|
inline |
Informs this validation object that a value is expected to be False.
In case the value is True, this validation object will not succeed.
This function will also write a message to the error log.
value | The value to be expected False |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
|
inline |
Informs this validation object that a value is expected to be greater than another value.
In case 'value0 > value1' is false, the validation object will not succeed.
value0 | The first value to compare |
value1 | The second value to compare |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be greater than another value.
In case 'value0 > value1' is false, the validation object will not succeed.
This function will also write a message to the error log.
value0 | The first value to compare |
value1 | The second value to compare |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be greater than or equal to another value.
In case 'value0 >= value1' is false, the validation object will not succeed.
value0 | The first value to compare |
value1 | The second value to compare |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be greater than or equal to another value.
In case 'value0 >= value1' is false, the validation object will not succeed.
This function will also write a message to the error log.
value0 | The first value to compare |
value1 | The second value to compare |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be inside a range.
In case 'lower <= value && value <= upper' is false, the validation object will not succeed.
lower | The lower bound of the range (inclusive) |
value | The value to be checked |
upper | The upper bound of the range (inclusive) |
T | The data type of the value |
|
inline |
Informs this validation object that a value is expected to be inside a range.
In case 'lower <= value && value <= upper' is false, the validation object will not succeed. This function will also write a message to the error log.
lower | The lower bound of the range (inclusive) |
value | The value to be checked |
upper | The upper bound of the range (inclusive) |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
T | The data type of the value |
|
inline |
Informs this validation object that a value is expected to be less than another value.
In case 'value0 < value1' is false, the validation object will not succeed.
value0 | The first value to compare |
value1 | The second value to compare |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be less than another value.
In case 'value0 < value1' is false, the validation object will not succeed.
This function will also write a message to the error log.
value0 | The first value to compare |
value1 | The second value to compare |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be less than or equal to another value.
In case 'value0 <= value1' is false, the validation object will not succeed.
value0 | The first value to compare |
value1 | The second value to compare |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be less than or equal to another value.
In case 'value0 <= value1' is false, the validation object will not succeed.
This function will also write a message to the error log.
value0 | The first value to compare |
value1 | The second value to compare |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
T | The data type of both values |
|
inline |
Informs this validation object that a value is expected to be True.
In case the value is False, this validation object will not succeed.
value | The value to be expected True |
|
inline |
Informs this validation object that a value is expected to be True.
In case the value is False, this validation object will not succeed.
This function will also write a message to the error log.
value | The value to be expected True |
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
|
inline |
Returns a string containing the random generator's initial seed, if any.
|
inline |
Explicitly sets the validation to be failed.
|
inline |
Explicitly sets the validation to be failed.
This function will also write a message to the error log.
file | The source file in which the function call happens, e.g., FILE, must be valid |
line | The line in the source file in which the function call happens, e.g., LINE, must be valid |
|
inlineprotected |
Sets the succeeded state to false.
|
inline |
Returns if this validation has succeeded.
|
protected |
Optional random generator object which will be used during validation.
|
protected |
True, if the validation has succeeded; False, if the validation has failed.
|
mutableprotected |
True, if the success state of this validation has been checked.