A class to verify that an actual value lies between two boundary values. More...
Public Member Functions | |
ExpectationBoundary (const String &name, VerifiableList *parent=0) | |
Constructs the expectation. | |
void | setActual (const T &value) |
Sets the actual value. | |
void | setExpected (const T &lower, const T &upper) |
Sets the expectation value boundaries. | |
void | setExpectedDelta (const T &median, const T &delta) |
Sets the expectation value boundaries. | |
virtual void | reset () |
Resets the internal state completely. | |
virtual void | clearActual () |
Resets the internal state to reflect that there is no actual value set. | |
virtual void | setExpectNothing () |
Tell the object to expect nothing to happen to it, perhaps because the test is exercising the handling of an error. | |
virtual void | verify () |
Verify that the expected value is within the allowed bounds. | |
Protected Member Functions | |
virtual void | clearExpectation () |
Clears the expectation list. |
A class to verify that an actual value lies between two boundary values.
Since it uses operator<() and operator==() for verification it can handle all objects that implement those operators not just numerics.
Definition at line 49 of file ExpectationBoundary.h.
mockpp::ExpectationBoundary< T >::ExpectationBoundary | ( | const String & | name, | |
VerifiableList * | parent = 0 | |||
) | [inline] |
Constructs the expectation.
name | human readable description about the expectation | |
parent | parent verifiable |
Definition at line 65 of file ExpectationBoundary.h.
void mockpp::ExpectationBoundary< T >::setActual | ( | const T & | value | ) | [inline] |
Sets the actual value.
value | the actual value |
Definition at line 76 of file ExpectationBoundary.h.
void mockpp::ExpectationBoundary< T >::setExpected | ( | const T & | lower, | |
const T & | upper | |||
) | [inline] |
Sets the expectation value boundaries.
lower | lowest value | |
upper | highest value |
Definition at line 91 of file ExpectationBoundary.h.
void mockpp::ExpectationBoundary< T >::setExpectedDelta | ( | const T & | median, | |
const T & | delta | |||
) | [inline] |
Sets the expectation value boundaries.
Differs from the normal setExpected() method only in the parameters. Since this method is not activated by default, you must add the following lines to your source code before #include'ing ExpectationBoundery.h to activate it.
#undef MOCKPP_BOUNDARY_DELTA // after inclusion of mockpp.h! #define MOCKPP_BOUNDARY_DELTA 1
Additionally operator+() and operator-() must exist for your expected objects, that's the reason why it is disabled by default.
median | expected value | |
delta | allowed difference range |
Definition at line 117 of file ExpectationBoundary.h.
virtual void mockpp::ExpectationBoundary< T >::setExpectNothing | ( | ) | [inline, virtual] |
Tell the object to expect nothing to happen to it, perhaps because the test is exercising the handling of an error.
The Expectation will fail if any actual values are set.
Note that this is not the same as not setting any expectations, in which case verify() will do nothing.
Implements mockpp::Expectation.
Definition at line 160 of file ExpectationBoundary.h.
virtual void mockpp::ExpectationBoundary< T >::verify | ( | ) | [inline, virtual] |
Verify that the expected value is within the allowed bounds.
If it fails, an AssertionFailedError is thrown
Implements mockpp::AbstractExpectation< T >.
Definition at line 171 of file ExpectationBoundary.h.