mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added error diagnostic for a missing action
This commit is contained in:
parent
474b0afcb8
commit
fd78c134b7
2 changed files with 46 additions and 0 deletions
|
|
@ -94,3 +94,36 @@ BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace action
|
||||||
|
{
|
||||||
|
//[ action_view
|
||||||
|
class view
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool display( int result ) = 0; // returns a boolean
|
||||||
|
};
|
||||||
|
//]
|
||||||
|
|
||||||
|
MOCK_BASE_CLASS( mock_view, view )
|
||||||
|
{
|
||||||
|
MOCK_METHOD( display, 1 )
|
||||||
|
};
|
||||||
|
|
||||||
|
class calculator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
calculator( view& v );
|
||||||
|
|
||||||
|
void add( int a, int b );
|
||||||
|
};
|
||||||
|
//[ action_test
|
||||||
|
BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
||||||
|
{
|
||||||
|
mock_view v;
|
||||||
|
calculator c( v );
|
||||||
|
MOCK_EXPECT( v.display ).once().with( 0 ); // missing returns( true )
|
||||||
|
c.add( 0, 0 );
|
||||||
|
}
|
||||||
|
//]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,19 @@ The first line tells that a set expectation has not been fulfilled. The file and
|
||||||
The following lines once again list the set expectations.
|
The following lines once again list the set expectations.
|
||||||
It means the two first calls correctly passed the expected values to the mock object, but then no third call happened.
|
It means the two first calls correctly passed the expected values to the mock object, but then no third call happened.
|
||||||
|
|
||||||
|
Finally an error looking like :
|
||||||
|
|
||||||
|
src/tests/turtle_test/Tutorial.cpp(73): error in "zero_plus_zero_is_zero": missing action: v.mock_view::display( 0 )
|
||||||
|
v once().with( 0 )
|
||||||
|
|
||||||
|
indicates that an [link turtle.reference.expectation.actions action] is missing because a mock function must be told what to do when called if it has a return type other than void, for instance given :
|
||||||
|
|
||||||
|
[action_view]
|
||||||
|
|
||||||
|
the following test case will raise a missing action error :
|
||||||
|
|
||||||
|
[action_test]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue