Skip to content

Commit

Permalink
Googletest export
Browse files Browse the repository at this point in the history
Move all docs into top-level docs/ directory

PiperOrigin-RevId: 350211277
  • Loading branch information
Abseil Team authored and derekmauro committed Jan 14, 2021
1 parent 996b65e commit 4892835
Show file tree
Hide file tree
Showing 35 changed files with 48 additions and 2,905 deletions.
14 changes: 7 additions & 7 deletions googletest/docs/advanced.md → docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ Verifies that `val1` is less than, or almost equal to, `val2`. You can replace
### Asserting Using gMock Matchers
[gMock](../../googlemock) comes with
[a library of matchers](../../googlemock/docs/cheat_sheet.md#MatcherList) for
[gMock](gmock_index.md) comes with
[a library of matchers](gmock_cheat_sheet.md#MatcherList) for
validating arguments passed to mock objects. A gMock *matcher* is basically a
predicate that knows how to describe itself. It can be used in these assertion
macros:
Expand All @@ -396,13 +396,13 @@ using ::testing::StartsWith;
```

Read this
[recipe](../../googlemock/docs/cook_book.md#using-matchers-in-googletest-assertions)
[recipe](gmock_cook_book.md#using-matchers-in-googletest-assertions)
in the gMock Cookbook for more details.

gMock has a rich set of matchers. You can do many things googletest cannot do
alone with them. For a list of matchers gMock provides, read
[this](../../googlemock/docs/cook_book.md##using-matchers). It's easy to write
your [own matchers](../../googlemock/docs/cook_book.md#NewMatchers) too.
[this](gmock_cook_book.md##using-matchers). It's easy to write
your [own matchers](gmock_cook_book.md#NewMatchers) too.

gMock is bundled with googletest, so you don't need to add any build dependency
in order to take advantage of this. Just include `"gmock/gmock.h"`
Expand All @@ -414,7 +414,7 @@ and you're ready to go.
you haven't.)

You can use the gMock
[string matchers](../../googlemock/docs/cheat_sheet.md#string-matchers) with
[string matchers](gmock_cheat_sheet.md#string-matchers) with
`EXPECT_THAT()` or `ASSERT_THAT()` to do more string comparison tricks
(sub-string, prefix, suffix, regular expression, and etc). For example,

Expand Down Expand Up @@ -915,7 +915,7 @@ handlers registered with `pthread_atfork(3)`.
Note: If you want to put a series of test assertions in a subroutine to check
for a complex condition, consider using
[a custom GMock matcher](../../googlemock/docs/cook_book.md#NewMatchers)
[a custom GMock matcher](gmock_cook_book.md#NewMatchers)
instead. This lets you provide a more readable error message in case of failure
and avoid all of the issues described below.
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions googlemock/docs/cheat_sheet.md → docs/gmock_cheat_sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Example usage:
To customize the default action for a particular method of a specific mock
object, use `ON_CALL()`. `ON_CALL()` has a similar syntax to `EXPECT_CALL()`,
but it is used for setting default behaviors (when you do not require that the
mock method is called). See [here](cook_book.md#UseOnCall) for a more detailed
mock method is called). See [here](gmock_cook_book.md#UseOnCall) for a more detailed
discussion.
```cpp
Expand Down Expand Up @@ -477,7 +477,7 @@ You can make a matcher from one or more other matchers:
| Matcher | Description |
| :---------------------- | :------------------------------------ |
| `MatcherCast<T>(m)` | casts matcher `m` to type `Matcher<T>`. |
| `SafeMatcherCast<T>(m)` | [safely casts](cook_book.md#casting-matchers) matcher `m` to type `Matcher<T>`. |
| `SafeMatcherCast<T>(m)` | [safely casts](gmock_cook_book.md#casting-matchers) matcher `m` to type `Matcher<T>`. |
| `Truly(predicate)` | `predicate(argument)` returns something considered by C++ to be true, where `predicate` is a function or functor. |
<!-- mdformat on -->
Expand Down Expand Up @@ -774,7 +774,7 @@ class MockFunction<R(A1, ..., An)> {
};
```
See this [recipe](cook_book.md#using-check-points) for one application of it.
See this [recipe](gmock_cook_book.md#using-check-points) for one application of it.
## Flags
Expand Down
19 changes: 10 additions & 9 deletions googlemock/docs/cook_book.md → docs/gmock_cook_book.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<!-- GOOGLETEST_CM0012 DO NOT DELETE -->

You can find recipes for using gMock here. If you haven't yet, please read
[the dummy guide](for_dummies.md) first to make sure you understand the basics.
[the dummy guide](gmock_for_dummies.md) first to make sure you understand the
basics.

**Note:** gMock lives in the `testing` name space. For readability, it is
recommended to write `using ::testing::Foo;` once in your file before using the
Expand Down Expand Up @@ -1141,11 +1142,11 @@ Hamcrest project, which adds `assertThat()` to JUnit.

### Using Predicates as Matchers

gMock provides a [built-in set](cheat_sheet.md#MatcherList) of matchers. In case
you find them lacking, you can use an arbitrary unary predicate function or
functor as a matcher - as long as the predicate accepts a value of the type you
want. You do this by wrapping the predicate inside the `Truly()` function, for
example:
gMock provides a [built-in set](gmock_cheat_sheet.md#MatcherList) of matchers.
In case you find them lacking, you can use an arbitrary unary predicate function
or functor as a matcher - as long as the predicate accepts a value of the type
you want. You do this by wrapping the predicate inside the `Truly()` function,
for example:

```cpp
using ::testing::Truly;
Expand Down Expand Up @@ -1710,7 +1711,7 @@ the test should reflect our real intent, instead of being overly constraining.

gMock allows you to impose an arbitrary DAG (directed acyclic graph) on the
calls. One way to express the DAG is to use the
[After](cheat_sheet.md#AfterClause) clause of `EXPECT_CALL`.
[After](gmock_cheat_sheet.md#AfterClause) clause of `EXPECT_CALL`.

Another way is via the `InSequence()` clause (not the same as the `InSequence`
class), which we borrowed from jMock 2. It's less flexible than `After()`, but
Expand Down Expand Up @@ -3714,8 +3715,8 @@ A cardinality is used in `Times()` to tell gMock how many times you expect a
call to occur. It doesn't have to be exact. For example, you can say
`AtLeast(5)` or `Between(2, 4)`.

If the [built-in set](cheat_sheet.md#CardinalityList) of cardinalities doesn't
suit you, you are free to define your own by implementing the following
If the [built-in set](gmock_cheat_sheet.md#CardinalityList) of cardinalities
doesn't suit you, you are free to define your own by implementing the following
interface (in namespace `testing`):

```cpp
Expand Down
12 changes: 6 additions & 6 deletions googlemock/docs/gmock_faq.md → docs/gmock_faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
### When I call a method on my mock object, the method for the real object is invoked instead. What's the problem?

In order for a method to be mocked, it must be *virtual*, unless you use the
[high-perf dependency injection technique](cook_book.md#MockingNonVirtualMethods).
[high-perf dependency injection technique](gmock_cook_book.md#MockingNonVirtualMethods).

### Can I mock a variadic function?

Expand Down Expand Up @@ -93,9 +93,9 @@ trace, you'll gain insights on why the expectations you set are not met.

If you see the message "The mock function has no default action set, and its
return type has no default value set.", then try
[adding a default action](for_dummies.md#DefaultValue). Due to a known issue,
unexpected calls on mocks without default actions don't print out a detailed
comparison between the actual arguments and the expected arguments.
[adding a default action](gmock_for_dummies.md#DefaultValue). Due to a known
issue, unexpected calls on mocks without default actions don't print out a
detailed comparison between the actual arguments and the expected arguments.

### My program crashed and `ScopedMockLog` spit out tons of messages. Is it a gMock bug?

Expand Down Expand Up @@ -388,8 +388,8 @@ doesn't say what the return value should be. You need `DoAll()` to chain a
`SetArgPointee()` with a `Return()` that provides a value appropriate to the API
being mocked.

See this [recipe](cook_book.md#mocking-side-effects) for more details and an
example.
See this [recipe](gmock_cook_book.md#mocking-side-effects) for more details and
an example.

### I have a huge mock class, and Microsoft Visual C++ runs out of memory when compiling it. What can I do?

Expand Down
18 changes: 9 additions & 9 deletions googlemock/docs/for_dummies.md → docs/gmock_for_dummies.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ follow:
* Derive a class `MockTurtle` from `Turtle`.
* Take a *virtual* function of `Turtle` (while it's possible to
[mock non-virtual methods using templates](cook_book.md#MockingNonVirtualMethods),
[mock non-virtual methods using templates](gmock_cook_book.md#MockingNonVirtualMethods),
it's much more involved).
* In the `public:` section of the child class, write `MOCK_METHOD();`
* Now comes the fun part: you take the function signature, cut-and-paste it
Expand Down Expand Up @@ -376,8 +376,8 @@ convenient way of saying "any value".
In the above examples, `100` and `50` are also matchers; implicitly, they are
the same as `Eq(100)` and `Eq(50)`, which specify that the argument must be
equal (using `operator==`) to the matcher argument. There are many
[built-in matchers](cheat_sheet.md#MatcherList) for common types (as well as
[custom matchers](cook_book.md#NewMatchers)); for example:
[built-in matchers](gmock_cheat_sheet.md#MatcherList) for common types (as well
as [custom matchers](gmock_cook_book.md#NewMatchers)); for example:
```cpp
using ::testing::Ge;
Expand All @@ -399,7 +399,7 @@ EXPECT_CALL(turtle, GoTo);
This works for all non-overloaded methods; if a method is overloaded, you need
to help gMock resolve which overload is expected by specifying the number of
arguments and possibly also the
[types of the arguments](cook_book.md#SelectOverload).
[types of the arguments](gmock_cook_book.md#SelectOverload).
### Cardinalities: How Many Times Will It Be Called?
Expand All @@ -416,7 +416,7 @@ called.
We've seen `AtLeast(n)` as an example of fuzzy cardinalities earlier. For the
list of built-in cardinalities you can use, see
[here](cheat_sheet.md#CardinalityList).
[here](gmock_cheat_sheet.md#CardinalityList).
The `Times()` clause can be omitted. **If you omit `Times()`, gMock will infer
the cardinality for you.** The rules are easy to remember:
Expand Down Expand Up @@ -485,7 +485,7 @@ the *default* action for the function every time (unless, of course, you have a
What can we do inside `WillOnce()` besides `Return()`? You can return a
reference using `ReturnRef(*variable*)`, or invoke a pre-defined function, among
[others](cook_book.md#using-actions).
[others](gmock_cook_book.md#using-actions).
**Important note:** The `EXPECT_CALL()` statement evaluates the action clause
only once, even though the action may be performed many times. Therefore you
Expand Down Expand Up @@ -563,7 +563,7 @@ overloaded). This makes any calls to the method expected. This is not necessary
for methods that are not mentioned at all (these are "uninteresting"), but is
useful for methods that have some expectations, but for which other calls are
ok. See
[Understanding Uninteresting vs Unexpected Calls](cook_book.md#uninteresting-vs-unexpected).
[Understanding Uninteresting vs Unexpected Calls](gmock_cook_book.md#uninteresting-vs-unexpected).

### Ordered vs Unordered Calls {#OrderedCalls}

Expand Down Expand Up @@ -600,7 +600,7 @@ order as written. If a call is made out-of-order, it will be an error.
(What if you care about the relative order of some of the calls, but not all of
them? Can you specify an arbitrary partial order? The answer is ... yes! The
details can be found [here](cook_book.md#OrderedCalls).)
details can be found [here](gmock_cook_book.md#OrderedCalls).)
### All Expectations Are Sticky (Unless Said Otherwise) {#StickyExpectations}
Expand Down Expand Up @@ -699,4 +699,4 @@ For example, in some tests we may not care about how many times `GetX()` and
In gMock, if you are not interested in a method, just don't say anything about
it. If a call to this method occurs, you'll see a warning in the test output,
but it won't be a failure. This is called "naggy" behavior; to change, see
[The Nice, the Strict, and the Naggy](cook_book.md#NiceStrictNaggy).
[The Nice, the Strict, and the Naggy](gmock_cook_book.md#NiceStrictNaggy).
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions googlemock/docs/pump_manual.md → docs/pump_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ exp ::= simple_expression_in_Python_syntax
## Code
You can find the source code of Pump in [scripts/pump.py](../scripts/pump.py).
It is still very unpolished and lacks automated tests, although it has been
successfully used many times. If you find a chance to use it in your project,
please let us know what you think! We also welcome help on improving Pump.
You can find the source code of Pump in
[googlemock/scripts/pump.py](../googlemock/scripts/pump.py). It is still very
unpolished and lacks automated tests, although it has been successfully used
many times. If you find a chance to use it in your project, please let us know
what you think! We also welcome help on improving Pump.
## Real Examples
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions googlemock/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Content Moved

We are working on updates to the GoogleTest documentation, which has moved to
the top-level [docs](../../docs) directory.
5 changes: 0 additions & 5 deletions googlemock/docs/contribute.md

This file was deleted.

Loading

0 comments on commit 4892835

Please sign in to comment.