Skip to content

Commit

Permalink
Googletest export
Browse files Browse the repository at this point in the history
Add files for GitHub Pages

PiperOrigin-RevId: 357096486
  • Loading branch information
Abseil Team authored and derekmauro committed Feb 18, 2021
1 parent 9e2c7ab commit 1a5a78b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
11 changes: 5 additions & 6 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,6 @@ TEST(MyDeathTest, CompoundStatement) {
}
```
gtest-death-test_test.cc contains more examples if you are interested.
## I have a fixture class `FooTest`, but `TEST_F(FooTest, Bar)` gives me error ``"no matching function for call to `FooTest::FooTest()'"``. Why?
Googletest needs to be able to create objects of your test fixture class, so it
Expand Down Expand Up @@ -663,14 +661,15 @@ break the death test (e.g. by changing the regex pattern it is expected to
match). Admittedly, this is a hack. We'll consider a more permanent solution
after the fork-and-exec-style death tests are implemented.
## The compiler complains about "no match for 'operator<<'" when I use an assertion. What gives?
## The compiler complains about `no match for 'operator<<'` when I use an assertion. What gives?
If you use a user-defined type `FooType` in an assertion, you must make sure
there is an `std::ostream& operator<<(std::ostream&, const FooType&)` function
defined such that we can print a value of `FooType`.
In addition, if `FooType` is declared in a name space, the `<<` operator also
needs to be defined in the *same* name space. See abseil.io/tips/49 for details.
needs to be defined in the *same* name space. See
[Tip of the Week #49](http://abseil.io/tips/49) for details.
## How do I suppress the memory leak messages on Windows?
Expand All @@ -691,10 +690,10 @@ mistake in production. Such cleverness also leads to
advise against the practice, and googletest doesn't provide a way to do it.
In general, the recommended way to cause the code to behave differently under
test is [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection). You can inject
test is [Dependency Injection](http://en.wikipedia.org/wiki/Dependency_injection). You can inject
different functionality from the test and from the production code. Since your
production code doesn't link in the for-test logic at all (the
[`testonly`](https://docs.bazel.build/versions/master/be/common-definitions.html#common.testonly) attribute for BUILD targets helps to ensure
[`testonly`](http://docs.bazel.build/versions/master/be/common-definitions.html#common.testonly) attribute for BUILD targets helps to ensure
that), there is no danger in accidentally running it.
However, if you *really*, *really*, *really* have no choice, and if you follow
Expand Down
12 changes: 8 additions & 4 deletions docs/gmock_cook_book.md
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,8 @@ using ::testing::ElementsAreArray;

Use `Pair` when comparing maps or other associative containers.

{% raw %}

```cpp
using testing::ElementsAre;
using testing::Pair;
Expand All @@ -1460,6 +1462,8 @@ using testing::Pair;
EXPECT_THAT(m, ElementsAre(Pair("a", 1), Pair("b", 2), Pair("c", 3)));
```

{% endraw %}

**Tips:**

* `ElementsAre*()` can be used to match *any* container that implements the
Expand Down Expand Up @@ -2244,7 +2248,7 @@ former, and the former's return type can be implicitly converted to that of the
latter. So, you can invoke something whose type is *not* exactly the same as the
mock function, as long as it's safe to do so - nice, huh?

**`Note:`{.escaped}**
Note that:

* The action takes ownership of the callback and will delete it when the
action itself is destructed.
Expand Down Expand Up @@ -2330,7 +2334,7 @@ bool Job2(int n, char c) { ... }
foo.ComplexJob(20); // Invokes Job2(5, 'a').
```

**`Note:`{.escaped}**
Note that:

* The action takes ownership of the callback and will delete it when the
action itself is destructed.
Expand Down Expand Up @@ -2875,8 +2879,8 @@ work with non-copyable objects; you'll have to use functors instead.
#### Legacy workarounds for move-only types {#LegacyMoveOnly}

Support for move-only function arguments was only introduced to gMock in April
2017. In older code, you may encounter the following workaround for the lack of
this feature (it is no longer necessary - we're including it just for
of 2017. In older code, you may encounter the following workaround for the lack
of this feature (it is no longer necessary - we're including it just for
reference):

```cpp
Expand Down
2 changes: 1 addition & 1 deletion docs/pkgconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ $ pkg-config --libs gtest

which contains the correct sysroot now. For a more comprehensive guide to also
including `${CHOST}` in build system calls, see the excellent tutorial by Diego
Elio Pettenò: https://autotools.io/pkgconfig/cross-compiling.html
Elio Pettenò: <https://autotools.io/pkgconfig/cross-compiling.html>

0 comments on commit 1a5a78b

Please sign in to comment.