Commit f3ef7e17 by Abseil Team Committed by Dino Radaković

Googletest export

Fix table formatting in cookbook PiperOrigin-RevId: 355659722
parent 9e975a02
...@@ -300,44 +300,86 @@ The macros in the `MOCK_METHODn` family differ from `MOCK_METHOD`: ...@@ -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> <th colspan=2> Const Method </th></tr> <tr> <td> Old </td> <td> <tr>
`MOCK_CONST_METHOD1(Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td> <td>New</td>
`MOCK_METHOD(bool, Foo, (int), (const))` </td> </tr> <td><code>MOCK_METHOD(bool, Foo, (int))</code></td>
</tr>
<tr> <th colspan=2> Method in a Class Template </th></tr> <tr> <td> Old </td>
<td> `MOCK_METHOD1_T(Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td> <tr><th colspan=2>Const Method</th></tr>
`MOCK_METHOD(bool, Foo, (int))` </td> </tr> <tr>
<td>Old</td>
<tr> <th colspan=2> Const Method in a Class Template </th></tr> <tr> <td> Old <td><code>MOCK_CONST_METHOD1(Foo, bool(int))</code></td>
</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> <tr>
<td>New</td>
<tr> <th colspan=2> Method with Call Type </th></tr> <tr> <td> Old </td> <td> <td><code>MOCK_METHOD(bool, Foo, (int), (const))</code></td>
`MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))` </td> </tr> <tr> </tr>
<td> New </td> <td> `MOCK_METHOD(bool, Foo, (int),
(Calltype(STDMETHODCALLTYPE)))` </td> </tr> <tr><th colspan=2>Method in a Class Template</th></tr>
<tr>
<tr> <th colspan=2> Const Method with Call Type </th></tr> <tr> <td> Old</td> <td>Old</td>
<td> `MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))` </td> <td><code>MOCK_METHOD1_T(Foo, bool(int))</code></td>
</tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, (int), (const, </tr>
Calltype(STDMETHODCALLTYPE)))` </td> </tr> <tr>
<td>New</td>
<tr> <th colspan=2> Method with Call Type in a Class Template </th></tr> <tr> <td><code>MOCK_METHOD(bool, Foo, (int))</code></td>
<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),
(Calltype(STDMETHODCALLTYPE)))` </td> </tr> <tr><th colspan=2>Const Method in a Class Template</th></tr>
<tr>
<tr> <th colspan=2> Const Method with Call Type in a Class Template </th></tr> <td>Old</td>
<tr> <td> Old </td> <td> `MOCK_CONST_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, <td><code>MOCK_CONST_METHOD1_T(Foo, bool(int))</code></td>
Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, </tr>
(int), (const, Calltype(STDMETHODCALLTYPE)))` </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><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>
<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>
<td>Old</td>
<td><code>MOCK_METHOD1_T_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 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 ...@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment