All of the expectation objects share a similar approach: setting up a set of expectations at the beginning of a test and compare with actual values while the test is running.
For that reason each of the different expectation classes has at least
setExpected()to set up the expected value.
setActual()for setting the actual value.
Additionally there are some methods to influence the verification process under certain circumstances:
Usually the actual value is immediately compared
when set. Sometimes you want to defer this until all the work is done.
After invoking this method you must call
manually at the end to verify all pending expectations.
If you want to prevent the occurrence of any actual values you should invoke this method at the beginning.
Please understand that this is different from not setting any expectations! Not setting an expectation yields in no error at all for any setting of an actual value since there is no value to compare with.
The most common application is the use of
which does an exact comparison. Your own data types should implement a meaningful
operator==() to be usable with mockpp.
Depending on your type
can replace the former operator by supplying a template which does the following
!(x < y) && !(y < x).
The following example creates an expectation value for int values.
ExpectationValue <int> ev ("verifyValue", 0); ev.setExpected(1234); ev.setActual(4321);