mirror of
https://github.com/google/googletest.git
synced 2024-12-27 10:11:03 +08:00
Googletest export
Fix table formatting in cookbook PiperOrigin-RevId: 355659722
This commit is contained in:
parent
9e975a022e
commit
f3ef7e173f
@ -300,44 +300,86 @@ The macros in the `MOCK_METHODn` family differ from `MOCK_METHOD`:
|
|||||||
|
|
||||||
Old macros and their new equivalents:
|
Old macros and their new equivalents:
|
||||||
|
|
||||||
<a name="table99"></a>
|
<table>
|
||||||
<table border="1" cellspacing="0" cellpadding="1">
|
<tr><th colspan=2>Simple</th></tr>
|
||||||
<tr> <th colspan=2> Simple </th></tr>
|
<tr>
|
||||||
<tr> <td> Old </td> <td> `MOCK_METHOD1(Foo, bool(int))` </td> </tr>
|
<td>Old</td>
|
||||||
<tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, (int))` </td> </tr>
|
<td><code>MOCK_METHOD1(Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>New</td>
|
||||||
|
<td><code>MOCK_METHOD(bool, Foo, (int))</code></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr> <th colspan=2> Const Method </th></tr> <tr> <td> Old </td> <td>
|
<tr><th colspan=2>Const Method</th></tr>
|
||||||
`MOCK_CONST_METHOD1(Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td>
|
<tr>
|
||||||
`MOCK_METHOD(bool, Foo, (int), (const))` </td> </tr>
|
<td>Old</td>
|
||||||
|
<td><code>MOCK_CONST_METHOD1(Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>New</td>
|
||||||
|
<td><code>MOCK_METHOD(bool, Foo, (int), (const))</code></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr> <th colspan=2> Method in a Class Template </th></tr> <tr> <td> Old </td>
|
<tr><th colspan=2>Method in a Class Template</th></tr>
|
||||||
<td> `MOCK_METHOD1_T(Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td>
|
<tr>
|
||||||
`MOCK_METHOD(bool, Foo, (int))` </td> </tr>
|
<td>Old</td>
|
||||||
|
<td><code>MOCK_METHOD1_T(Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>New</td>
|
||||||
|
<td><code>MOCK_METHOD(bool, Foo, (int))</code></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr> <th colspan=2> Const Method in a Class Template </th></tr> <tr> <td> Old
|
<tr><th colspan=2>Const Method in a Class Template</th></tr>
|
||||||
</td> <td> `MOCK_CONST_METHOD1_T(Foo, bool(int))` </td> </tr> <tr> <td> New
|
<tr>
|
||||||
</td> <td> `MOCK_METHOD(bool, Foo, (int), (const))` </td> </tr>
|
<td>Old</td>
|
||||||
|
<td><code>MOCK_CONST_METHOD1_T(Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>New</td>
|
||||||
|
<td><code>MOCK_METHOD(bool, Foo, (int), (const))</code></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr> <th colspan=2> Method with Call Type </th></tr> <tr> <td> Old </td> <td>
|
<tr><th colspan=2>Method with Call Type</th></tr>
|
||||||
`MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))` </td> </tr> <tr>
|
<tr>
|
||||||
<td> New </td> <td> `MOCK_METHOD(bool, Foo, (int),
|
<td>Old</td>
|
||||||
(Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
<td><code>MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>New</td>
|
||||||
|
<td><code>MOCK_METHOD(bool, Foo, (int), (Calltype(STDMETHODCALLTYPE)))</code></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr> <th colspan=2> Const Method with Call Type </th></tr> <tr> <td> Old</td>
|
<tr><th colspan=2>Const Method with Call Type</th></tr>
|
||||||
<td> `MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))` </td>
|
<tr>
|
||||||
</tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, (int), (const,
|
<td>Old</td>
|
||||||
Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
<td><code>MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>New</td>
|
||||||
|
<td><code>MOCK_METHOD(bool, Foo, (int), (const, Calltype(STDMETHODCALLTYPE)))</code></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr> <th colspan=2> Method with Call Type in a Class Template </th></tr> <tr>
|
<tr><th colspan=2>Method with Call Type in a Class Template</th></tr>
|
||||||
<td> Old </td> <td> `MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo,
|
<tr>
|
||||||
bool(int))` </td> </tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, (int),
|
<td>Old</td>
|
||||||
(Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
<td><code>MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
<tr> <th colspan=2> Const Method with Call Type in a Class Template </th></tr>
|
<tr>
|
||||||
<tr> <td> Old </td> <td> `MOCK_CONST_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE,
|
<td>New</td>
|
||||||
Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo,
|
<td><code>MOCK_METHOD(bool, Foo, (int), (Calltype(STDMETHODCALLTYPE)))</code></td>
|
||||||
(int), (const, Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr><th colspan=2>Const Method with Call Type in a Class Template</th></tr>
|
||||||
|
<tr>
|
||||||
|
<td>Old</td>
|
||||||
|
<td><code>MOCK_CONST_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>New</td>
|
||||||
|
<td><code>MOCK_METHOD(bool, Foo, (int), (const, Calltype(STDMETHODCALLTYPE)))</code></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### The Nice, the Strict, and the Naggy {#NiceStrictNaggy}
|
### 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
|
know its type. The type depends on the macro used to define the action and the
|
||||||
parameter types. The rule is relatively simple:
|
parameter types. The rule is relatively simple:
|
||||||
|
|
||||||
|
<!-- mdformat off(GitHub does not support multiline tables) -->
|
||||||
|
|
||||||
| Given Definition | Expression | Has Type |
|
| Given Definition | Expression | Has Type |
|
||||||
| ----------------------------- | ------------------- | --------------------- |
|
| ----------------------------- | ------------------- | --------------------- |
|
||||||
| `ACTION(Foo)` | `Foo()` | `FooAction` |
|
| `ACTION(Foo)` | `Foo()` | `FooAction` |
|
||||||
| `ACTION_TEMPLATE(Foo,` | `Foo<t1, ..., | `FooAction<t1, ..., |
|
| `ACTION_TEMPLATE(Foo, HAS_m_TEMPLATE_PARAMS(...), AND_0_VALUE_PARAMS())` | `Foo<t1, ..., t_m>()` | `FooAction<t1, ..., t_m>` |
|
||||||
: `HAS_m_TEMPLATE_PARAMS(...),` : t_m>()` : t_m>` :
|
|
||||||
: `AND_0_VALUE_PARAMS())` : : :
|
|
||||||
| `ACTION_P(Bar, param)` | `Bar(int_value)` | `BarActionP<int>` |
|
| `ACTION_P(Bar, param)` | `Bar(int_value)` | `BarActionP<int>` |
|
||||||
| `ACTION_TEMPLATE(Bar,` | `Bar<t1, ..., t_m>` | `FooActionP<t1, ..., |
|
| `ACTION_TEMPLATE(Bar, HAS_m_TEMPLATE_PARAMS(...), AND_1_VALUE_PARAMS(p1))` | `Bar<t1, ..., t_m>(int_value)` | `BarActionP<t1, ..., t_m, int>` |
|
||||||
: `HAS_m_TEMPLATE_PARAMS(...),` : `(int_value)` : t_m, int>` :
|
| `ACTION_P2(Baz, p1, p2)` | `Baz(bool_value, int_value)` | `BazActionP2<bool, int>` |
|
||||||
: `AND_1_VALUE_PARAMS(p1))` : : :
|
| `ACTION_TEMPLATE(Baz, HAS_m_TEMPLATE_PARAMS(...), AND_2_VALUE_PARAMS(p1, p2))` | `Baz<t1, ..., t_m>(bool_value, int_value)` | `BazActionP2<t1, ..., t_m, bool, int>` |
|
||||||
| `ACTION_P2(Baz, p1, p2)` | `Baz(bool_value,` | `BazActionP2<bool, |
|
|
||||||
: : `int_value)` : int>` :
|
|
||||||
| `ACTION_TEMPLATE(Baz,` | `Baz<t1, ..., t_m>` | `FooActionP2<t1, ..., |
|
|
||||||
: `HAS_m_TEMPLATE_PARAMS(...),` : `(bool_value,` : t_m,` `bool, int>` :
|
|
||||||
: `AND_2_VALUE_PARAMS(p1, p2))` : `int_value)` : :
|
|
||||||
| ... | ... | ... |
|
| ... | ... | ... |
|
||||||
|
|
||||||
|
<!-- mdformat on -->
|
||||||
|
|
||||||
Note that we have to pick different suffixes (`Action`, `ActionP`, `ActionP2`,
|
Note that we have to pick different suffixes (`Action`, `ActionP`, `ActionP2`,
|
||||||
and etc) for actions with different numbers of value parameters, or the action
|
and etc) for actions with different numbers of value parameters, or the action
|
||||||
definitions cannot be overloaded on the number of them.
|
definitions cannot be overloaded on the number of them.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user