Utils::CalitkoMocks::ExpectationPair< Foo > Struct Template Reference

#include <ExpectationsList.h> [code]

Collaboration diagram for Utils::CalitkoMocks::ExpectationPair< Foo >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename Foo>
struct Utils::CalitkoMocks::ExpectationPair< Foo >

Helper for expectation factories and willCall(), willEmit().

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


Constructor & Destructor Documentation

template<typename Foo>
Utils::CalitkoMocks::ExpectationPair< Foo >::ExpectationPair ExpectationsList< Foo > &  l,
auto_ptr< Foo >  f
[inline]
 

Definition at line 154 of file ExpectationsList.h.

template<typename Foo>
Utils::CalitkoMocks::ExpectationPair< Foo >::ExpectationPair const ExpectationPair< Foo > &  other  )  [inline]
 

Definition at line 156 of file ExpectationsList.h.


Member Data Documentation

template<typename Foo>
auto_ptr<Foo> Utils::CalitkoMocks::ExpectationPair< Foo >::function [mutable]
 

Definition at line 152 of file ExpectationsList.h.

template<typename Foo>
ExpectationsList<Foo>& Utils::CalitkoMocks::ExpectationPair< Foo >::list
 

Definition at line 151 of file ExpectationsList.h.


The documentation for this struct was generated from the following file: