Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
f3ef7e17
Commit
f3ef7e17
authored
Feb 04, 2021
by
Abseil Team
Committed by
Dino Radaković
Feb 05, 2021
Browse files
Googletest export
Fix table formatting in cookbook PiperOrigin-RevId: 355659722
parent
9e975a02
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
49 deletions
+88
-49
docs/gmock_cook_book.md
docs/gmock_cook_book.md
+88
-49
No files found.
docs/gmock_cook_book.md
View file @
f3ef7e17
...
...
@@ -300,44 +300,86 @@ The macros in the `MOCK_METHODn` family differ from `MOCK_METHOD`:
Old macros and their new equivalents:
<a
name=
"table99"
></a>
<table
border=
"1"
cellspacing=
"0"
cellpadding=
"1"
>
<tr>
<th
colspan=
2
>
Simple
</th></tr>
<tr>
<td>
Old
</td>
<td>
`MOCK_METHOD1(Foo, bool(int))`
</td>
</tr>
<tr>
<td>
New
</td>
<td>
`MOCK_METHOD(bool, Foo, (int))`
</td>
</tr>
<tr>
<th
colspan=
2
>
Const Method
</th></tr>
<tr>
<td>
Old
</td>
<td>
`MOCK_CONST_METHOD1(Foo, bool(int))`
</td>
</tr>
<tr>
<td>
New
</td>
<td>
`MOCK_METHOD(bool, Foo, (int), (const))`
</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>
`MOCK_METHOD(bool, Foo, (int))`
</td>
</tr>
<tr>
<th
colspan=
2
>
Const Method in a Class Template
</th></tr>
<tr>
<td>
Old
</td>
<td>
`MOCK_CONST_METHOD1_T(Foo, bool(int))`
</td>
</tr>
<tr>
<td>
New
</td>
<td>
`MOCK_METHOD(bool, Foo, (int), (const))`
</td>
</tr>
<tr>
<th
colspan=
2
>
Method with Call Type
</th></tr>
<tr>
<td>
Old
</td>
<td>
`MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))`
</td>
</tr>
<tr>
<td>
New
</td>
<td>
`MOCK_METHOD(bool, Foo, (int),
(Calltype(STDMETHODCALLTYPE)))`
</td>
</tr>
<tr>
<th
colspan=
2
>
Const Method with Call Type
</th></tr>
<tr>
<td>
Old
</td>
<td>
`MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))`
</td>
</tr>
<tr>
<td>
New
</td>
<td>
`MOCK_METHOD(bool, Foo, (int), (const,
Calltype(STDMETHODCALLTYPE)))`
</td>
</tr>
<tr>
<th
colspan=
2
>
Method with Call Type in a Class Template
</th></tr>
<tr>
<td>
Old
</td>
<td>
`MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo,
bool(int))`
</td>
</tr>
<tr>
<td>
New
</td>
<td>
`MOCK_METHOD(bool, Foo, (int),
(Calltype(STDMETHODCALLTYPE)))`
</td>
</tr>
<tr>
<th
colspan=
2
>
Const Method with Call Type in a Class Template
</th></tr>
<tr>
<td>
Old
</td>
<td>
`MOCK_CONST_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE,
Foo, bool(int))`
</td>
</tr>
<tr>
<td>
New
</td>
<td>
`MOCK_METHOD(bool, Foo,
(int), (const, Calltype(STDMETHODCALLTYPE)))`
</td>
</tr>
<table>
<tr><th
colspan=
2
>
Simple
</th></tr>
<tr>
<td>
Old
</td>
<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><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>
<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
</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><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>
### 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:
<!-- mdformat off(GitHub does not support multiline tables) -->
| Given Definition | Expression | Has Type |
| ----------------------------- | ------------------- | --------------------- |
| `
ACTION(Foo)
` | `
Foo()
` | `
FooAction
` |
| `
ACTION_TEMPLATE(Foo,
` | `
Foo<t1, ..., |
`FooAction<t1, ..., |
: `
HAS_m_TEMPLATE_PARAMS(...),
` : t_m>()`
: t_m>
` :
: `
AND_0_VALUE_PARAMS())
` : : :
| `
ACTION_TEMPLATE(Foo, HAS_m_TEMPLATE_PARAMS(...), AND_0_VALUE_PARAMS())
` | `
Foo
<t1
,
...,
t_m
>
()
` | `
FooAction
<t1
,
...,
t_m
>
` |
| `
ACTION_P(Bar, param)
` | `
Bar(int_value)
` | `
BarActionP
<int>
` |
| `
ACTION_TEMPLATE(Bar,
` | `
Bar
<t1
,
...,
t_m
>
` | `
FooActionP<t1, ..., |
:
`HAS_m_TEMPLATE_PARAMS(...),`
:
`(int_value)`
: t_m, int>
` :
: `
AND_1_VALUE_PARAMS(p1))
` : : :
| `
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)
` : :
| `
ACTION_TEMPLATE(Bar, HAS_m_TEMPLATE_PARAMS(...), AND_1_VALUE_PARAMS(p1))
` | `
Bar
<t1
,
...,
t_m
>
(int_value)
` | `
BarActionP
<t1
,
...,
t_m
,
int
>
` |
| `
ACTION_P2(Baz, p1, p2)
` | `
Baz(bool_value, int_value)
` | `
BazActionP2
<bool
,
int
>
` |
| `
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
>
` |
| ... | ... | ... |
<!-- mdformat on -->
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment