mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Document how actions store data by copy
This commit is contained in:
parent
41de7236c4
commit
d1e0c96ff3
3 changed files with 30 additions and 4 deletions
|
|
@ -15,6 +15,7 @@ Not yet released
|
||||||
* Added inline to generated MOCK_FUNCTION
|
* Added inline to generated MOCK_FUNCTION
|
||||||
* Documented limitation concerning MOCK_METHOD_TPL
|
* Documented limitation concerning MOCK_METHOD_TPL
|
||||||
* Fixed mocking protected member function
|
* Fixed mocking protected member function
|
||||||
|
* Document how actions store data by copy
|
||||||
|
|
||||||
[section 1.2.6]
|
[section 1.2.6]
|
||||||
Released 24 May 2014
|
Released 24 May 2014
|
||||||
|
|
|
||||||
|
|
@ -798,6 +798,25 @@ BOOST_AUTO_TEST_CASE( demonstrates_configuring_actions )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace action_example_2
|
||||||
|
{
|
||||||
|
//[ action_example_2
|
||||||
|
MOCK_CLASS( mock_class )
|
||||||
|
{
|
||||||
|
MOCK_METHOD( method, 0, int&() )
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( demonstrates_configuring_actions_with_references )
|
||||||
|
{
|
||||||
|
mock_class c;
|
||||||
|
int i = 0;
|
||||||
|
MOCK_EXPECT( c.method ).returns( boost::ref( i ) ); // wrap i to store a reference
|
||||||
|
c.method() = 42; // really change i and not just the stored copy
|
||||||
|
BOOST_CHECK_EQUAL( 42, i ); // indeed
|
||||||
|
}
|
||||||
|
//]
|
||||||
|
}
|
||||||
|
|
||||||
namespace verification_example_1
|
namespace verification_example_1
|
||||||
{
|
{
|
||||||
//[ verification_example_1
|
//[ verification_example_1
|
||||||
|
|
|
||||||
|
|
@ -488,17 +488,23 @@ An action performs additional treatments after an expectation has been deemed va
|
||||||
|
|
||||||
Synopsis :
|
Synopsis :
|
||||||
|
|
||||||
MOCK_EXPECT( identifier ).returns( value );
|
MOCK_EXPECT( identifier ).returns( value ); // stored internally by copy
|
||||||
MOCK_EXPECT( identifier ).moves( value );
|
MOCK_EXPECT( identifier ).moves( value ); // stored internally by copy
|
||||||
MOCK_EXPECT( identifier ).throws( exception );
|
MOCK_EXPECT( identifier ).throws( exception ); // stored internally by copy
|
||||||
MOCK_EXPECT( identifier ).calls( functor ); // gets assigned to a boost::function and throws std::invalid_argument if empty
|
MOCK_EXPECT( identifier ).calls( functor ); // stored internally by copy, throws std::invalid_argument if empty
|
||||||
|
|
||||||
[note The returns and moves actions are not available for mock methods returning void, including constructors and destructors.]
|
[note The returns and moves actions are not available for mock methods returning void, including constructors and destructors.]
|
||||||
|
|
||||||
|
[note Actions are captured by copy, boost::ref and boost::cref can however be used to turn the copies into references.]
|
||||||
|
|
||||||
Example :
|
Example :
|
||||||
|
|
||||||
[action_example_1]
|
[action_example_1]
|
||||||
|
|
||||||
|
Example with references :
|
||||||
|
|
||||||
|
[action_example_2]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue