#include <ExpectationsList.h> [code]
Collaboration diagram for Utils::CalitkoMocks::ExpectationPair< Foo >:

The order of evaluation of subexpressions is (in most cases) undefined in the C++ standard. Since a single chained call is one expression, we cannot depend on the oder of evaluation of the parameters passed to each of the functions in the chain and these parameters should not produce side effects. This was the case before when the expectations factory methods added the new expectation to the ExpectationsList, which resulted in incorrect behavior.
The expectation factories have been modified to return ExpectationPair object, which contain a reference to the ExpectationsList and the new expectation. The functions willCall() and willEmit() should add the new expectation to the list:
ExpectationList <ExpectationFunction <void()> > list; auto_ptr <ExpectationFunction <void()> > foo (new ExpectationFunction (void())); ExpectationPair <void()> pair (list, foo); ... // later in willCall() or willEmit() pair.list.add (pair.function); // add the expectations in the correct order
This way we no longer depend on the order of parameter evaluation and the expectations are always registered dynamically in the correct order (same as the order of willCall()/willEmit() function invokation on the chain.
Definition at line 149 of file ExpectationsList.h.
Public Member Functions | |
| ExpectationPair (ExpectationsList< Foo > &l, auto_ptr< Foo > f) | |
| ExpectationPair (const ExpectationPair &other) | |
Public Attributes | |
| ExpectationsList< Foo > & | list |
| auto_ptr< Foo > | function |
|
||||||||||||||||
|
Definition at line 154 of file ExpectationsList.h. |
|
||||||||||
|
Definition at line 156 of file ExpectationsList.h. |
|
|||||
|
Definition at line 152 of file ExpectationsList.h. |
|
|||||
|
Definition at line 151 of file ExpectationsList.h. |