Utils::CalitkoMocks::Testing::ExpectedFunctionTest Class Reference

Inherits TestFixture.

Inheritance diagram for Utils::CalitkoMocks::Testing::ExpectedFunctionTest:

Inheritance graph
[legend]
Collaboration diagram for Utils::CalitkoMocks::Testing::ExpectedFunctionTest:

Collaboration graph
[legend]
List of all members.

Detailed Description

Tests for class ExpectedFunction.

ExpectedFunction is a template class representing a functions. A number of different template specializations are defined for functions taking from none to nine parameters. Adding further template instantiations can easily be done using a single line macro (see DEFINE_EXPECTED_FUNCTION() in ExpectationDriver.h).

Since all instantiations are defined using the same macro template it is not necessary to fully test all different instantiations. We have chosen to perform the following tests:

Todo:
What if we need to pass to the function a non-const reference, which should be modifed before the stubbed value is returned.

What is with const pointer to the host class and with const functions? It is now solved ugly by adding a new ctor to ExpectedFunction.

Definition at line 69 of file ExpectedFunctionTest.cpp.

Public Types

typedef BoundFunction< ExpectedFunctionTest,
void(int &)> 
VoidVoidCallType
typedef BoundFunction< ExpectedFunctionTest,
int()> 
VoidVoidCall2Type

Public Member Functions

void testVoidVoidChecked ()
 Verify that verifyChecked() doesn't throw if check() was called.
void testVoidVoidNotChecked ()
 Verify that verifyChecked() does throw if check() was not called.
void testIntIntOk ()
 Test that both expectated parameter value and return value are correct.
void testIntIntCallFails ()
 An exception should be thrown for an unexpected parameter value.
void testIntIntReturnFails ()
 Expecting a wrong return value should fail.
void testIntIntNoReturnSetFail ()
 If no return value was set using willReturn() an exception is thrown.
void testIntIntNoReturnSetFailWithContext ()
 Verify that if set, the correct contexts is specified in the exception.
void testIntRefVoidOk ()
 Test an instantiation returning an int &.
void testVoidConstIntRefOk ()
 Test an instantiation taking a const int &.
void testVoidIntRefOk ()
 An int & parameter expectation passes if the same identity is provided.
void testVoidIntRefNotSameIdentity ()
 Not passing the same identity for an int & should fail.
void VoidVoidCall (int &a)
void testVoidVoidWithCallsOk ()
 Test a void() expectation calling two bound functions.
int VoidVoidCall2 ()
void testVoidVoidWithCallReturnIncorrect ()
 Test an expectation calling a function, whose return expectation fails.

Private Member Functions

 CPPUNIT_TEST_SUITE (ExpectedFunctionTest)
 CPPUNIT_TEST (testVoidVoidChecked)
 CPPUNIT_TEST (testVoidVoidNotChecked)
 CPPUNIT_TEST (testIntIntOk)
 CPPUNIT_TEST (testIntIntCallFails)
 CPPUNIT_TEST_FAIL (testIntIntReturnFails)
 CPPUNIT_TEST (testIntIntNoReturnSetFail)
 CPPUNIT_TEST (testIntIntNoReturnSetFailWithContext)
 CPPUNIT_TEST (testIntRefVoidOk)
 CPPUNIT_TEST (testVoidConstIntRefOk)
 CPPUNIT_TEST (testVoidIntRefOk)
 CPPUNIT_TEST_FAIL (testVoidIntRefNotSameIdentity)
 CPPUNIT_TEST (testVoidVoidWithCallsOk)
 CPPUNIT_TEST (testVoidVoidWithCallReturnIncorrect)
 CPPUNIT_TEST_SUITE_END ()


Member Typedef Documentation

typedef BoundFunction<ExpectedFunctionTest, int ()> Utils::CalitkoMocks::Testing::ExpectedFunctionTest::VoidVoidCall2Type
 

Definition at line 237 of file ExpectedFunctionTest.cpp.

typedef BoundFunction<ExpectedFunctionTest, void (int &)> Utils::CalitkoMocks::Testing::ExpectedFunctionTest::VoidVoidCallType
 

Definition at line 214 of file ExpectedFunctionTest.cpp.


Member Function Documentation

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testVoidVoidWithCallReturnIncorrect   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testVoidVoidWithCallsOk   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testVoidIntRefOk   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testVoidConstIntRefOk   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testIntRefVoidOk   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testIntIntNoReturnSetFailWithContext   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testIntIntNoReturnSetFail   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testIntIntCallFails   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testIntIntOk   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testVoidVoidNotChecked   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST testVoidVoidChecked   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST_FAIL testVoidIntRefNotSameIdentity   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST_FAIL testIntIntReturnFails   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST_SUITE ExpectedFunctionTest   )  [private]
 

Utils::CalitkoMocks::Testing::ExpectedFunctionTest::CPPUNIT_TEST_SUITE_END  )  [private]
 

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testIntIntCallFails  )  [inline]
 

An exception should be thrown for an unexpected parameter value.

Definition at line 119 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testIntIntNoReturnSetFail  )  [inline]
 

If no return value was set using willReturn() an exception is thrown.

Definition at line 143 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testIntIntNoReturnSetFailWithContext  )  [inline]
 

Verify that if set, the correct contexts is specified in the exception.

Definition at line 158 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testIntIntOk  )  [inline]
 

Test that both expectated parameter value and return value are correct.

Definition at line 111 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testIntIntReturnFails  )  [inline]
 

Expecting a wrong return value should fail.

Definition at line 135 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testIntRefVoidOk  )  [inline]
 

Test an instantiation returning an int &.

Definition at line 175 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testVoidConstIntRefOk  )  [inline]
 

Test an instantiation taking a const int &.

The values of the objects referenced should be the same by value but not by address. ExpectedFunction stores an object of type T for a parameter of type T &.

Definition at line 190 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testVoidIntRefNotSameIdentity  )  [inline]
 

Not passing the same identity for an int & should fail.

Definition at line 205 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testVoidIntRefOk  )  [inline]
 

An int & parameter expectation passes if the same identity is provided.

Definition at line 197 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testVoidVoidChecked  )  [inline]
 

Verify that verifyChecked() doesn't throw if check() was called.

Definition at line 89 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testVoidVoidNotChecked  )  [inline]
 

Verify that verifyChecked() does throw if check() was not called.

Definition at line 97 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testVoidVoidWithCallReturnIncorrect  )  [inline]
 

Test an expectation calling a function, whose return expectation fails.

Definition at line 239 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::testVoidVoidWithCallsOk  )  [inline]
 

Test a void() expectation calling two bound functions.

Definition at line 216 of file ExpectedFunctionTest.cpp.

void Utils::CalitkoMocks::Testing::ExpectedFunctionTest::VoidVoidCall int &  a  )  [inline]
 

Definition at line 213 of file ExpectedFunctionTest.cpp.

int Utils::CalitkoMocks::Testing::ExpectedFunctionTest::VoidVoidCall2  )  [inline]
 

Definition at line 236 of file ExpectedFunctionTest.cpp.


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