1.2.3. Constraint List

Another expectation class is ConstraintList. It is similar to the former ExpectationList but offers more flexibility by using constraint classes to check the validity of the actual parameters. Instead of a value you pass the according object which is then used to verify the actual value. The usage of the constraint classes is explained in the chapter about ChainingMockObjects.

  ConstraintList <int> cl ("verifyValue", 0);

  cl.addExpected(new IsGreaterOrEqual<int>(10)); 1
  cl.addExpected(new IsLessOrEqual<int>(20));    2



This constraint is valid for all actual parameters which are greater than or equal to 10.


This one is valid for all actual parameters which are less than or equal to 20.