mockpp::ConstraintList< T > Class Template Reference
[Basic Mock Objects]

A class to verify lists of constraints, one after the other as they occur. More...

Inheritance diagram for mockpp::ConstraintList< T >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef bool(Constraint< T >::* Checker )(const T &arg) const

Public Member Functions

 ConstraintList (const String &name, VerifiableList *parent=0)
 Constructs the expectation.
virtual ~ConstraintList ()
 Destroys the expectation.
virtual void verify ()
 Verify that the expected values equal the expected ones.
void addActual (const T &actualItem)
 Adds another actual value to the list.
template<class I >
void addActual (I items, I end)
 Adds a sequence of actual values to the list.
ConstraintListaddExpected (const ConstraintHolder< T > &constraint)
 Adds another constraint to the list.
ConstraintListaddExpected (const T &expectedItem)
 Adds another exact expectation value to the list.
void balanceActual ()
 Simulate one correct item regarding the expectation list.
template<class I >
ConstraintListaddExpected (I items, I end)
 Adds a sequence of expectation values to the list.
virtual void clearActual ()
 Resets the internal state to reflect that there is no actual value set.
virtual void reset ()
 Resets the internal state completely.
unsigned size () const
 Returns the amount of expectation values.
virtual void setExpectNothing ()
 Tell the object to expect nothing to happen to it, perhaps because the test is exercising the handling of an error.

Protected Member Functions

virtual void clearExpectation ()
 Clears the expectation list.
void checkImmediateValue (const T &actualItem) const
 Checks if the actual value matches the expectation.
void checkImmediateValue (const T &actualItem, unsigned pos, Checker checker) const
 Checks if the actual value matches the expectation.

Detailed Description

template<class T>
class mockpp::ConstraintList< T >

A class to verify lists of constraints, one after the other as they occur.

This class is similar to ExpectationList but does not compare exactly but based on one of the constraint classes.

Definition at line 57 of file ConstraintList.h.


Constructor & Destructor Documentation

template<class T>
mockpp::ConstraintList< T >::ConstraintList ( const String name,
VerifiableList parent = 0 
) [inline]

Constructs the expectation.

Parameters:
name human readable description about the expectation
parent parent verifiable

Definition at line 65 of file ConstraintList.h.


Member Function Documentation

template<class T>
template<class I >
void mockpp::ConstraintList< T >::addActual ( items,
end 
) [inline]

Adds a sequence of actual values to the list.

Parameters:
items start iterator
end terminating iterator (note: one element "behind" as always with STL)

Definition at line 133 of file ConstraintList.h.

template<class T>
void mockpp::ConstraintList< T >::addActual ( const T &  actualItem  )  [inline]

Adds another actual value to the list.

Parameters:
actualItem new value

Definition at line 118 of file ConstraintList.h.

template<class T>
template<class I >
ConstraintList& mockpp::ConstraintList< T >::addExpected ( items,
end 
) [inline]

Adds a sequence of expectation values to the list.

Parameters:
items start iterator
end terminating iterator (note: one element "behind" as always with STL)
Returns:
reference to itself for chaining

Definition at line 186 of file ConstraintList.h.

template<class T>
ConstraintList& mockpp::ConstraintList< T >::addExpected ( const T &  expectedItem  )  [inline]

Adds another exact expectation value to the list.

Parameters:
expectedItem new value
Returns:
reference to itself for chaining

Definition at line 158 of file ConstraintList.h.

template<class T>
ConstraintList& mockpp::ConstraintList< T >::addExpected ( const ConstraintHolder< T > &  constraint  )  [inline]

Adds another constraint to the list.

Parameters:
constraint pointer to new constraint
Returns:
reference to itself for chaining

Definition at line 144 of file ConstraintList.h.

template<class T>
void mockpp::ConstraintList< T >::balanceActual (  )  [inline]

Simulate one correct item regarding the expectation list.

Useful after recovering from an error at another place.

Definition at line 168 of file ConstraintList.h.

template<class T>
void mockpp::ConstraintList< T >::checkImmediateValue ( const T &  actualItem,
unsigned  pos,
Checker  checker 
) const [inline, protected]

Checks if the actual value matches the expectation.

Note: in a list there can be any number of elements of a given value and the order of the elements must match exactly. If it fails, an AssertionFailedError is thrown

Parameters:
actualItem actual item to verify
pos current index

Definition at line 270 of file ConstraintList.h.

template<class T>
void mockpp::ConstraintList< T >::checkImmediateValue ( const T &  actualItem  )  const [inline, protected, virtual]

Checks if the actual value matches the expectation.

Note: in a list there can be any number of elements of a given value and the order of the elements must match exactly. If it fails, an AssertionFailedError is thrown

Parameters:
actualItem actual item to verify

Implements mockpp::AbstractExpectationCollection< T >.

Definition at line 257 of file ConstraintList.h.

template<class T>
virtual void mockpp::ConstraintList< T >::setExpectNothing (  )  [inline, virtual]

Tell the object to expect nothing to happen to it, perhaps because the test is exercising the handling of an error.

The Expectation will fail if any actual values are set.

Note that this is not the same as not setting any expectations, in which case verify() will do nothing.

Implements mockpp::Expectation.

Definition at line 230 of file ConstraintList.h.

template<class T>
unsigned mockpp::ConstraintList< T >::size (  )  const [inline]

Returns the amount of expectation values.

Returns:
number of expectation values

Definition at line 218 of file ConstraintList.h.

template<class T>
virtual void mockpp::ConstraintList< T >::verify (  )  [inline, virtual]

Verify that the expected values equal the expected ones.

Note: in a list there can be any number of elements of a given value and the order of the elements must match exactly. If it fails, an AssertionFailedError is thrown

Implements mockpp::AbstractExpectation< T >.

Definition at line 86 of file ConstraintList.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines

Generated on Tue Jan 5 09:49:06 2010 for mockpp by  doxygen 1.6.1