1.2. Basic Expectations

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

Additionally there are some methods to influence the verification process under certain circumstances:

setFailOnVerify()
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 verify() manually at the end to verify all pending expectations.
setExpectNothing()
If you want to prevent the occurance of any actual values you should invoke this method at the beginning.
[Note]Attention

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.

1.2.1. Expectation Value

The most common application is the use of ExpectationValue which does an exact comparision. Your own data types should implement a meaningful operator==() to be usable with mockpp. The following example creates an expectation value for int values.


  ExpectationValue <int> ev ("verifyValue", 0);

  ev.setExpected(1234);
  ev.setActual(4321);