diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 5e7cbfe3..7dcc58c5 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -300,44 +300,86 @@ The macros in the `MOCK_METHODn` family differ from `MOCK_METHOD`: Old macros and their new equivalents: - - - - - +
Simple
Old `MOCK_METHOD1(Foo, bool(int))`
New `MOCK_METHOD(bool, Foo, (int))`
+ + + + + + + + + - + + + + + + + + + - - + + + + + + + + + - + + + + + + + + + - - + + + + + + + + + - - - + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + +
Simple
OldMOCK_METHOD1(Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int))
Const Method
Old -`MOCK_CONST_METHOD1(Foo, bool(int))`
New -`MOCK_METHOD(bool, Foo, (int), (const))`
Const Method
OldMOCK_CONST_METHOD1(Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int), (const))
Method in a Class Template
Old `MOCK_METHOD1_T(Foo, bool(int))`
New -`MOCK_METHOD(bool, Foo, (int))`
Method in a Class Template
OldMOCK_METHOD1_T(Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int))
Const Method in a Class Template
Old - `MOCK_CONST_METHOD1_T(Foo, bool(int))`
New - `MOCK_METHOD(bool, Foo, (int), (const))`
Const Method in a Class Template
OldMOCK_CONST_METHOD1_T(Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int), (const))
Method with Call Type
Old -`MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))`
New `MOCK_METHOD(bool, Foo, (int), -(Calltype(STDMETHODCALLTYPE)))`
Method with Call Type
OldMOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int), (Calltype(STDMETHODCALLTYPE)))
Const Method with Call Type
Old `MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))`
New `MOCK_METHOD(bool, Foo, (int), (const, -Calltype(STDMETHODCALLTYPE)))`
Const Method with Call Type
OldMOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int), (const, Calltype(STDMETHODCALLTYPE)))
Method with Call Type in a Class Template
Old `MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, -bool(int))`
New `MOCK_METHOD(bool, Foo, (int), -(Calltype(STDMETHODCALLTYPE)))`
Const Method with Call Type in a Class Template
Old `MOCK_CONST_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, -Foo, bool(int))`
New `MOCK_METHOD(bool, Foo, -(int), (const, Calltype(STDMETHODCALLTYPE)))`
Method with Call Type in a Class Template
OldMOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int), (Calltype(STDMETHODCALLTYPE)))
Const Method with Call Type in a Class Template
OldMOCK_CONST_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))
NewMOCK_METHOD(bool, Foo, (int), (const, Calltype(STDMETHODCALLTYPE)))
### The Nice, the Strict, and the Naggy {#NiceStrictNaggy} @@ -4081,23 +4123,20 @@ If you are writing a function that returns an `ACTION` object, you'll need to know its type. The type depends on the macro used to define the action and the parameter types. The rule is relatively simple: + + | Given Definition | Expression | Has Type | | ----------------------------- | ------------------- | --------------------- | | `ACTION(Foo)` | `Foo()` | `FooAction` | -| `ACTION_TEMPLATE(Foo,` | `Foo()` : t_m>` : -: `AND_0_VALUE_PARAMS())` : : : +| `ACTION_TEMPLATE(Foo, HAS_m_TEMPLATE_PARAMS(...), AND_0_VALUE_PARAMS())` | `Foo()` | `FooAction` | | `ACTION_P(Bar, param)` | `Bar(int_value)` | `BarActionP` | -| `ACTION_TEMPLATE(Bar,` | `Bar` | `FooActionP` : -: `AND_1_VALUE_PARAMS(p1))` : : : -| `ACTION_P2(Baz, p1, p2)` | `Baz(bool_value,` | `BazActionP2` : -| `ACTION_TEMPLATE(Baz,` | `Baz` | `FooActionP2` : -: `AND_2_VALUE_PARAMS(p1, p2))` : `int_value)` : : +| `ACTION_TEMPLATE(Bar, HAS_m_TEMPLATE_PARAMS(...), AND_1_VALUE_PARAMS(p1))` | `Bar(int_value)` | `BarActionP` | +| `ACTION_P2(Baz, p1, p2)` | `Baz(bool_value, int_value)` | `BazActionP2` | +| `ACTION_TEMPLATE(Baz, HAS_m_TEMPLATE_PARAMS(...), AND_2_VALUE_PARAMS(p1, p2))` | `Baz(bool_value, int_value)` | `BazActionP2` | | ... | ... | ... | + + Note that we have to pick different suffixes (`Action`, `ActionP`, `ActionP2`, and etc) for actions with different numbers of value parameters, or the action definitions cannot be overloaded on the number of them.