diff --git a/doc/example/getting_started.cpp b/doc/example/getting_started.cpp index f3cf2d4..ff732c4 100644 --- a/doc/example/getting_started.cpp +++ b/doc/example/getting_started.cpp @@ -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 ); +} +//] +} diff --git a/doc/getting_started.qbk b/doc/getting_started.qbk index bc90904..82c613f 100644 --- a/doc/getting_started.qbk +++ b/doc/getting_started.qbk @@ -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. 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]