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
15756aa0
Commit
15756aa0
authored
Jul 18, 2019
by
Gennadiy Civil
Browse files
Manual docs tweaks still in preparation for including docs with code pushes
parent
34ddfff9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
66 deletions
+98
-66
googlemock/docs/cheat_sheet.md
googlemock/docs/cheat_sheet.md
+94
-62
googlemock/docs/cook_book.md
googlemock/docs/cook_book.md
+2
-2
googlemock/docs/for_dummies.md
googlemock/docs/for_dummies.md
+1
-1
googletest/docs/faq.md
googletest/docs/faq.md
+1
-1
No files found.
googlemock/docs/cheat_sheet.md
View file @
15756aa0
...
@@ -215,7 +215,7 @@ and the default action will be taken each time.
...
@@ -215,7 +215,7 @@ and the default action will be taken each time.
### Matchers {#MatcherList}
### Matchers {#MatcherList}
<!-- GOOGLETEST_CM00
19
DO NOT DELETE -->
<!-- GOOGLETEST_CM00
20
DO NOT DELETE -->
A
**matcher**
matches a
*single*
argument. You can use it inside
`ON_CALL()`
or
A
**matcher**
matches a
*single*
argument. You can use it inside
`ON_CALL()`
or
`EXPECT_CALL()`
, or use it to validate a value directly:
`EXPECT_CALL()`
, or use it to validate a value directly:
...
@@ -341,65 +341,97 @@ write the elements in-line, match them more flexibly, or get more informative
...
@@ -341,65 +341,97 @@ write the elements in-line, match them more flexibly, or get more informative
messages, you can use:
messages, you can use:
| Matcher | Description |
| Matcher | Description |
| :----------------------------------- | :----------------------------------- |
| :---------------------------------------- | :------------------------------- |
|
`ContainerEq(container)`
| The same as
`Eq(container)`
except |
|
`BeginEndDistanceIs(m)`
|
`argument`
is a container whose |
: : that the failure message also :
: :
`begin()`
and
`end()`
iterators :
: : includes which elements are in one :
: : are separated by a number of :
: : container but not the other. :
: : increments matching
`m`
. E.g. :
|
`Contains(e)`
|
`argument`
contains an element that |
: :
`BeginEndDistanceIs(2)`
or :
: : matches
`e`
, which can be either a :
: :
`BeginEndDistanceIs(Lt(2))`
. For :
: : value or a matcher. :
: : containers that define a :
: :
`size()`
method,
`SizeIs(m)`
may :
: : be more efficient. :
|
`ContainerEq(container)`
| The same as
`Eq(container)`
|
: : except that the failure message :
: : also includes which elements are :
: : in one container but not the :
: : other. :
|
`Contains(e)`
|
`argument`
contains an element |
: : that matches
`e`
, which can be :
: : either a value or a matcher. :
|
`Each(e)`
|
`argument`
is a container where |
|
`Each(e)`
|
`argument`
is a container where |
: : _every_ element matches
`e`
, which :
: :
*every*
element matches
`e`
, :
: : can be either a value or a matcher. :
: : which can be either a value or a :
: : matcher. :
|
`ElementsAre(e0, e1, ..., en)`
|
`argument`
has
`n + 1`
elements, |
|
`ElementsAre(e0, e1, ..., en)`
|
`argument`
has
`n + 1`
elements, |
: : where the i-th element matches
`ei`
, :
: : where the
*i*
-th element matches :
: : which can be a value or a matcher. 0 :
: :
`ei`
, which can be a value or a :
: : to 10 arguments are allowed. :
: : matcher. :
|
`ElementsAreArray({ e0, e1, ..., en | The same as `
ElementsAre()
` except |
|
`ElementsAreArray({e0, e1, ..., en})`
, | The same as
`ElementsAre()`
|
: })`
,
`ElementsAreArray(array)`
, or : that the expected element :
:
`ElementsAreArray(a_container)`
, : except that the expected element :
:
`ElementsAreArray(array, count)`
: values/matchers come from an :
:
`ElementsAreArray(begin, end)`
, : values/matchers come from an :
: : initializer list, STL-style :
:
`ElementsAreArray(array)`
, or : initializer list, STL-style :
: : container, or C-style array. :
:
`ElementsAreArray(array, count)`
: container, iterator range, or :
: : C-style array. :
|
`IsEmpty()`
|
`argument`
is an empty container |
|
`IsEmpty()`
|
`argument`
is an empty container |
: : (
`container.empty()`
). :
: : (
`container.empty()`
). :
|
`Pointwise(m, container)`
|
`argument`
contains the same number |
|
`IsFalse()`
|
`argument`
evaluates to
`false`
|
: : of elements as in
`container`
, and :
: : in a Boolean context. :
: : for all i, (the i-th element in :
|
`IsSubsetOf({e0, e1, ..., en})`
, |
`argument`
matches |
: :
`argument`
, the i-th element in :
:
`IsSubsetOf(a_container)`
, :
`UnorderedElementsAre(x0, x1, :
: :
`container`
) match
`m`
, which is a :
: `
IsSubsetOf(begin, end)
`, : ..., xk)`
for some subset
`{x0, :
: : matcher on 2-tuples. E.g. :
: `
IsSubsetOf(array)
`, or : x1, ..., xk}`
of the expected :
: :
`Pointwise(Le(), upper_bounds)`
:
:
`IsSubsetOf(array, count)`
: matchers. :
: : verifies that each element in :
|
`IsSupersetOf({e0, e1, ..., en})`
, | Some subset of
`argument`
|
: :
`argument`
doesn't exceed the :
:
`IsSupersetOf(a_container)`
, : matches :
: : corresponding element in :
:
`IsSupersetOf(begin, end)`
, :
`UnorderedElementsAre(`
expected :
: :
`upper_bounds`
. See more detail :
:
`IsSupersetOf(array)`
, or : matchers
`)`
. :
: : below. :
:
`IsSupersetOf(array, count)`
: :
|
`SizeIs(m)`
|
`argument`
is a container whose size |
|
`IsTrue()`
|
`argument`
evaluates to
`true`
|
: : matches
`m`
. E.g.
`SizeIs(2)`
or :
: : in a Boolean context. :
: :
`SizeIs(Lt(2))`
. :
|
`Pointwise(m, container)`
,
`Pointwise(m, | `
argument
` contains the same |
|
`UnorderedElementsAre(e0, e1, ..., | `
argument
` has `
n + 1
` elements, and |
: {e0, e1, ..., en})`
: number of elements as in :
: en)`
: under some permutation each element :
: :
`container`
, and for all i, (the :
: : i-th element in
`argument`
, the :
: : i-th element in
`container`
) :
: : match
`m`
, which is a matcher on :
: : 2-tuples. E.g.
`Pointwise(Le(), :
: : upper_bounds)`
verifies that :
: : each element in
`argument`
:
: : doesn't exceed the corresponding :
: : element in
`upper_bounds`
. See :
: : more detail below. :
|
`SizeIs(m)`
|
`argument`
is a container whose |
: : size matches
`m`
. E.g. :
: :
`SizeIs(2)`
or
`SizeIs(Lt(2))`
. :
|
`UnorderedElementsAre(e0, e1, ..., en)`
|
`argument`
has
`n + 1`
elements, |
: : and under
*some*
permutation of :
: : the elements, each element :
: : matches an
`ei`
(for a different :
: : matches an
`ei`
(for a different :
: :
`i`
), which can be a value or a :
: :
`i`
), which can be a value or a :
: : matcher. 0 to 10 arguments are :
: : matcher. :
: : allowed. :
|
`UnorderedElementsAreArray({e0, e1, ..., | The same as |
|
`UnorderedElementsAreArray({ e0, e1, | The same as `
UnorderedElementsAre()
` |
: en})`
, :
`UnorderedElementsAre()`
except :
: ..., en })`
, : except that the expected element :
:
`UnorderedElementsAreArray(a_container)`
, : that the expected element :
:
`UnorderedElementsAreArray(array)`
, : values/matchers come from an :
:
`UnorderedElementsAreArray(begin, end)`
, : values/matchers come from an :
: or
`UnorderedElementsAreArray(array, : initializer list, STL-style :
:
`UnorderedElementsAreArray(array)`
, or : initializer list, STL-style :
: count)`
: container, or C-style array. :
:
`UnorderedElementsAreArray(array, count)`
: container, iterator range, or :
|
`WhenSorted(m)`
| When
`argument`
is sorted using the |
: : C-style array. :
: :
`<`
operator, it matches container :
|
`UnorderedPointwise(m, container)`
, | Like
`Pointwise(m, container)`
, |
: : matcher
`m`
. E.g. :
:
`UnorderedPointwise(m, {e0, e1, ..., : but ignores the order of :
: :
`WhenSorted(ElementsAre(1, 2, 3))`
:
: en})`
: elements. :
: : verifies that
`argument`
contains :
|
`WhenSorted(m)`
| When
`argument`
is sorted using |
: : elements
`1`
,
`2`
, and
`3`
, ignoring :
: : the
`<`
operator, it matches :
: : order. :
: : container matcher
`m`
. E.g. :
|
`WhenSortedBy(comparator, m)`
| The same as
`WhenSorted(m)`
, except |
: :
`WhenSorted(ElementsAre(1, 2, :
: : that the given comparator instead of :
: : 3))`
verifies that
`argument`
:
: :
`<`
is used to sort
`argument`
. E.g. :
: : contains elements 1, 2, and 3, :
: :
`WhenSortedBy(std\:\:greater<int>(), :
: : ignoring order. :
|
`WhenSortedBy(comparator, m)`
| The same as
`WhenSorted(m)`
, |
: : except that the given comparator :
: : instead of
`<`
is used to sort :
: :
`argument`
. E.g. :
: :
`WhenSortedBy(std\:\:greater(), :
: : ElementsAre(3, 2, 1))`
. :
: : ElementsAre(3, 2, 1))`
. :
**Notes:**
**Notes:**
...
...
googlemock/docs/cook_book.md
View file @
15756aa0
...
@@ -154,7 +154,7 @@ class MockStack : public StackInterface<Elem> {
...
@@ -154,7 +154,7 @@ class MockStack : public StackInterface<Elem> {
#### Mocking Non-virtual Methods {#MockingNonVirtualMethods}
#### Mocking Non-virtual Methods {#MockingNonVirtualMethods}
gMock can mock non-virtual functions to be used in Hi-perf dependency
gMock can mock non-virtual functions to be used in Hi-perf dependency
injection.
<!-- GOOGLETEST_CM001
6
DO NOT DELETE -->
.
injection.
<!-- GOOGLETEST_CM001
7
DO NOT DELETE -->
.
In this case, instead of sharing a common base class with the real class, your
In this case, instead of sharing a common base class with the real class, your
mock class will be
*unrelated*
to the real class, but contain methods with the
mock class will be
*unrelated*
to the real class, but contain methods with the
...
@@ -1455,7 +1455,7 @@ mock object and gMock.
...
@@ -1455,7 +1455,7 @@ mock object and gMock.
#### Knowing When to Expect {#UseOnCall}
#### Knowing When to Expect {#UseOnCall}
<!-- GOOGLETEST_CM001
7
DO NOT DELETE -->
<!-- GOOGLETEST_CM001
8
DO NOT DELETE -->
**`ON_CALL`**
is likely the
*single most under-utilized construct*
in gMock.
**`ON_CALL`**
is likely the
*single most under-utilized construct*
in gMock.
...
...
googlemock/docs/for_dummies.md
View file @
15756aa0
...
@@ -499,7 +499,7 @@ always return 100 as `n++` is only evaluated once. Similarly, `Return(new Foo)`
...
@@ -499,7 +499,7 @@ always return 100 as `n++` is only evaluated once. Similarly, `Return(new Foo)`
will create a new
`Foo`
object when the
`EXPECT_CALL()`
is executed, and will
will create a new
`Foo`
object when the
`EXPECT_CALL()`
is executed, and will
return the same pointer every time. If you want the side effect to happen every
return the same pointer every time. If you want the side effect to happen every
time, you need to define a custom action, which we'll teach in the
time, you need to define a custom action, which we'll teach in the
[
cook book
](
http://
<!-- GOOGLETEST_CM001
1
DO NOT DELETE -->
).
[
cook book
](
http://
<!-- GOOGLETEST_CM001
2
DO NOT DELETE -->
).
Time for another quiz! What do you think the following means?
Time for another quiz! What do you think the following means?
...
...
googletest/docs/faq.md
View file @
15756aa0
...
@@ -332,7 +332,7 @@ You may still want to use `SetUp()/TearDown()` in the following cases:
...
@@ -332,7 +332,7 @@ You may still want to use `SetUp()/TearDown()` in the following cases:
*
In the body of a constructor (or destructor), it's not possible to use the
*
In the body of a constructor (or destructor), it's not possible to use the
`ASSERT_xx`
macros. Therefore, if the set-up operation could cause a fatal
`ASSERT_xx`
macros. Therefore, if the set-up operation could cause a fatal
test failure that should prevent the test from running, it's necessary to
test failure that should prevent the test from running, it's necessary to
use
`abort`
<!-- GOOGLETEST_CM001
4
DO NOT DELETE -->
and abort the whole test executable,
use
`abort`
<!-- GOOGLETEST_CM001
5
DO NOT DELETE -->
and abort the whole test executable,
or to use
`SetUp()`
instead of a constructor.
or to use
`SetUp()`
instead of a constructor.
*
If the tear-down operation could throw an exception, you must use
*
If the tear-down operation could throw an exception, you must use
`TearDown()`
as opposed to the destructor, as throwing in a destructor leads
`TearDown()`
as opposed to the destructor, as throwing in a destructor leads
...
...
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