mirror of
https://github.com/google/googletest.git
synced 2026-06-15 08:26:11 +08:00
Compare commits
8 Commits
e0e57997e8
...
ad19a0dbc3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad19a0dbc3 | ||
|
|
7140cd416c | ||
|
|
a721f1b20c | ||
|
|
8736d2cd5c | ||
|
|
09f45f51fb | ||
|
|
f482391f3d | ||
|
|
b1e7595753 | ||
|
|
b2788e9227 |
@ -3386,30 +3386,6 @@ With this definition, the above assertion will give a better message:
|
||||
Actual: 27 (the remainder is 6)
|
||||
```
|
||||
|
||||
#### Using EXPECT_ Statements in Matchers
|
||||
|
||||
You can also use `EXPECT_...` statements inside custom matcher definitions. In
|
||||
many cases, this allows you to write your matcher more concisely while still
|
||||
providing an informative error message. For example:
|
||||
|
||||
```cpp
|
||||
MATCHER(IsDivisibleBy7, "") {
|
||||
const auto remainder = arg % 7;
|
||||
EXPECT_EQ(remainder, 0);
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
If you write a test that includes the line `EXPECT_THAT(27, IsDivisibleBy7());`,
|
||||
you will get an error something like the following:
|
||||
|
||||
```shell
|
||||
Expected equality of these values:
|
||||
remainder
|
||||
Which is: 6
|
||||
0
|
||||
```
|
||||
|
||||
#### `MatchAndExplain`
|
||||
|
||||
You should let `MatchAndExplain()` print *any additional information* that can
|
||||
@ -3429,6 +3405,66 @@ the value of `(arg % 7) == 0` can be implicitly converted to a `bool`. In the
|
||||
`arg_type` will be `int`; if it takes an `unsigned long`, `arg_type` will be
|
||||
`unsigned long`; and so on.
|
||||
|
||||
#### Anti-pattern: Using EXPECT_ Statements in Matchers
|
||||
|
||||
Using `EXPECT_...` statements inside custom matcher definitions is an
|
||||
**anti-pattern** and should be avoided.
|
||||
|
||||
While it might appear to write matchers more concisely and generate informative
|
||||
messages, this pattern has critical issues:
|
||||
|
||||
1. **Negation Breakage (`Not`):** If wrapped in `Not(IsDivisibleBy7())`,
|
||||
evaluating it still triggers the internal `EXPECT_EQ`, registering a test
|
||||
failure on the runner even when the overall assertion is expected to
|
||||
succeed.
|
||||
2. **Composition / Container Breakage (`AnyOf`, `AllOf`, `Contains`):** When
|
||||
composed or used inside container matchers, elements that are expected
|
||||
mismatches will trigger the internal `EXPECT_` and register spurious
|
||||
failures.
|
||||
3. **ASSERT_* compilation errors:** `ASSERT_*` macros use `return;` to abort
|
||||
from a void function. Since matchers return `bool`, using `ASSERT_` inside
|
||||
them triggers a compilation error.
|
||||
4. **Purity Violations:** Matchers must be functionally pure (side-effect
|
||||
free), whereas registering global failures is a major side effect.
|
||||
5. **Line Number Confusion:** Failure reports point to the matcher's definition
|
||||
line rather than the calling `EXPECT_THAT`
|
||||
line.
|
||||
|
||||
##### The Anti-Pattern
|
||||
|
||||
```cpp
|
||||
// Anti-pattern: Do not do this!
|
||||
MATCHER(IsDivisibleBy7, "") {
|
||||
const auto remainder = arg % 7;
|
||||
EXPECT_EQ(remainder, 0); // Spurious failures if negated/composed!
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
##### The Correct Solution
|
||||
|
||||
To write concise matchers that delegate to other matchers and safely propagate
|
||||
the mismatch explanation, use **`::testing::ExplainMatchResult`** instead,
|
||||
passing it the sub-matcher, the value to check, and the `result_listener`:
|
||||
|
||||
```cpp
|
||||
MATCHER(IsDivisibleBy7, "") {
|
||||
const auto remainder = arg % 7;
|
||||
return ::testing::ExplainMatchResult(::testing::Eq(0), remainder,
|
||||
result_listener);
|
||||
}
|
||||
```
|
||||
|
||||
If you write a test that includes the line:
|
||||
|
||||
```cpp
|
||||
EXPECT_THAT(28, Not(IsDivisibleBy7()));
|
||||
```
|
||||
|
||||
it will correctly report the mismatch, properly point to the `EXPECT_THAT` line
|
||||
number, and support negation (`Not`) and composition (`AllOf`, `AnyOf`, etc.)
|
||||
without registering spurious failures.
|
||||
|
||||
### Writing New Parameterized Matchers Quickly
|
||||
|
||||
Sometimes you'll want to define a matcher that has parameters. For that you can
|
||||
|
||||
29
docs/platforms-zh.md
Normal file
29
docs/platforms-zh.md
Normal file
@ -0,0 +1,29 @@
|
||||
# 支持的平台
|
||||
|
||||
GoogleTest 需要符合 C++11 标准或者更新标准的代码库和编译器
|
||||
|
||||
GoogleTest 代码在以下平台上获得了正式支持。下面未列出的操作系统或工具是社区支持的。对于社区支持的平台,可以考虑使用不使代码复杂化的补丁。
|
||||
|
||||
如果在你的平台上发现任何问题,请将问题提交到 [GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues). 欢迎提交 Pull requests 进行修复!
|
||||
|
||||
### 操作系统
|
||||
|
||||
* Linux
|
||||
* macOS
|
||||
* Windows
|
||||
|
||||
### 编译器
|
||||
|
||||
* gcc 5.0+
|
||||
* clang 5.0+
|
||||
* MSVC 2015+
|
||||
|
||||
**macOS 用户:** Xcode 9.3+ 提供了 clang 5.0+.
|
||||
|
||||
### 构建系统
|
||||
|
||||
* [Bazel](https://bazel.build/)
|
||||
* [CMake](https://cmake.org/)
|
||||
|
||||
Bazel 是 google 团队内部和测试中使用的构建系统。CMake 是由开源社区支持的构建系统。
|
||||
|
||||
113
docs/quickstart-bazel-zh.md
Normal file
113
docs/quickstart-bazel-zh.md
Normal file
@ -0,0 +1,113 @@
|
||||
# 快速入门:使用 Bazel 构建
|
||||
|
||||
这个教程旨在让你使用 Bazel 构建和运行 GoogleTest。如果你是第一次使用 GoogleTest,或者需要复习一下,我们建议将本教程作为起点。
|
||||
|
||||
## 前提条件
|
||||
|
||||
为了完成这个教程,你需要的工具有:
|
||||
|
||||
+ 一个兼容的操作系统(例如 Linux,macOS,Windows)。
|
||||
+ 一个兼容的 C++ 编译器,至少支持 C++11。
|
||||
+ [Bazel](https://bazel.build/),GoogleTest 团队使用的首选构建系统。
|
||||
|
||||
更多关于 GoogleTest 兼容平台的信息,请参见 [支持的平台](platforms-zh.md)。
|
||||
|
||||
如果你没有安装 Bazel,参考 [Bazel installation guide](https://docs.bazel.build/versions/master/install.html)。
|
||||
|
||||
{: .callout .note}
|
||||
注意: 本教程中的终端命令显示的是 Unix shell,但这些命令在 Windows 命令行是哪个也可以使用。
|
||||
|
||||
## 建立一个 Bazel 工作区
|
||||
|
||||
[Bazel 工作区](https://docs.bazel.build/versions/master/build-ref.html#workspace) 是你文件系统上的一个目录,用于管理你想要构建的系统的源文件。每个工作区有个文本文件叫做 `WORKSPACE`,它可能是空的,也可能包含构建需要的外部依赖的引用。
|
||||
|
||||
首先,为你的工作区创建一个目录:
|
||||
|
||||
```
|
||||
$ mkdir my_workspace && cd my_workspace
|
||||
```
|
||||
|
||||
接着,创建 `WORKSPACE` 文件来指定依赖关系。为了依赖 GoogleTest,一种常见且推荐方式是通过 [`http_archive` 规则](https://docs.bazel.build/versions/master/repo/http.html#http_archive) 使用 [Bazel 外部依赖](https://docs.bazel.build/versions/master/external.html)。为此,在你的工作空间根目录下(`my_workspace/`)创建一个名为`WORKSPACE`的文件,内容为:
|
||||
|
||||
```
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "com_google_googletest",
|
||||
urls = ["https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip"],
|
||||
strip_prefix = "googletest-609281088cfefc76f9d0ce82e1ff6c30cc3591e5",
|
||||
)
|
||||
```
|
||||
|
||||
上述配置声明了对 GoogleTest 的依赖,GoogleTest 将以 ZIP 文件的形式从 Gihub 中下载。上述例子中,`609281088cfefc76f9d0ce82e1ff6c30cc3591e5`即 GoogleTest 版本的 Git commit ID。建议经常更新该值,以指向最新的版本。
|
||||
|
||||
现在你已经准备好构建使用 GoogleTest 的 C++ 代码了。
|
||||
|
||||
## 创建并运行
|
||||
|
||||
随着 Bazel 工作区的建立,现在可以在你的项目中使用 GoogleTest 代码了。
|
||||
|
||||
举个例子,在 `my_workspace` 目录下创建 `hello_test.cc` 文件,内容为:
|
||||
|
||||
```cpp
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// Demonstrate some basic assertions.
|
||||
TEST(HelloTest, BasicAssertions) {
|
||||
// Expect two strings not to be equal.
|
||||
EXPECT_STRNE("hello", "world");
|
||||
// Expect equality.
|
||||
EXPECT_EQ(7 * 6, 42);
|
||||
}
|
||||
```
|
||||
|
||||
GoogleTest 提供了许多 [断言](primer.md#assertions),可以用它们来测试代码的行为。上述示例中引入了 GoogleTest 的头文件并演示了一些基本的断言。
|
||||
|
||||
为了编译代码,请在相同目录下创建一个叫 `BUILD` 的文件,内容为:
|
||||
|
||||
```
|
||||
cc_test(
|
||||
name = "hello_test",
|
||||
size = "small",
|
||||
srcs = ["hello_test.cc"],
|
||||
deps = ["@com_google_googletest//:gtest_main"],
|
||||
)
|
||||
```
|
||||
|
||||
`cc_test` 规则声明了你要建立的测试可执行文件,并通过在 `WORKSPACE` 文件中指定的前缀(`@com_google_googletest`)去链接 GoogleTest。更多关于 Bazel `BUILD`文件的内容,请参考 [Bazel C++ Tutorial](https://docs.bazel.build/versions/master/tutorial/cpp.html)。
|
||||
|
||||
现在你可以投建并运行你的测试了:
|
||||
|
||||
<pre>
|
||||
<strong>my_workspace$ bazel test --test_output=all //:hello_test</strong>
|
||||
INFO: Analyzed target //:hello_test (26 packages loaded, 362 targets configured).
|
||||
INFO: Found 1 test target...
|
||||
INFO: From Testing //:hello_test:
|
||||
==================== Test output for //:hello_test:
|
||||
Running main() from gmock_main.cc
|
||||
[==========] Running 1 test from 1 test suite.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 1 test from HelloTest
|
||||
[ RUN ] HelloTest.BasicAssertions
|
||||
[ OK ] HelloTest.BasicAssertions (0 ms)
|
||||
[----------] 1 test from HelloTest (0 ms total)
|
||||
[----------] Global test environment tear-down
|
||||
[==========] 1 test from 1 test suite ran. (0 ms total)
|
||||
|
||||
[ PASSED ] 1 test.
|
||||
================================================================================
|
||||
Target //:hello_test up-to-date:
|
||||
bazel-bin/hello_test
|
||||
INFO: Elapsed time: 4.190s, Critical Path: 3.05s
|
||||
INFO: 27 processes: 8 internal, 19 linux-sandbox.
|
||||
INFO: Build completed successfully, 27 total actions
|
||||
//:hello_test PASSED in 0.1s
|
||||
|
||||
INFO: Build completed successfully, 27 total actions
|
||||
</pre>
|
||||
恭喜!你已经成功地使用 GoogleTest 构建并运行了一个测试。
|
||||
|
||||
## 下一步行动
|
||||
|
||||
* [查看 Primer](primer.md) 开始学习如何编写简单的测试。
|
||||
* [看看更多例子](samples.md)学习如何使用 GoogleTest 的各种功能。
|
||||
123
docs/quickstart-cmake-zh.md
Normal file
123
docs/quickstart-cmake-zh.md
Normal file
@ -0,0 +1,123 @@
|
||||
# 快速入门:使用 CMake 构建
|
||||
|
||||
这个教程旨在让你使用 CMake 构建和运行 GoogleTest。如果你是第一次使用 GoogleTest,或者需要复习一下,我们建议将本教程作为起点。如果你的项目使用 Bazel,请参阅 [快速入门:使用 Bazel 构建](quickstart-bazel-zh.md)
|
||||
|
||||
## 前提条件
|
||||
|
||||
为了完成这个教程,你需要的工具有:
|
||||
|
||||
+ 一个兼容的操作系统(例如 Linux,macOS,Windows)。
|
||||
+ 一个兼容的 C++ 编译器,至少支持 C++11。
|
||||
+ [CMake](https://cmake.org/) 以及一系列用于构建的工具。
|
||||
+ 构建工具包括 [Make](https://www.gnu.org/software/make/),[Ninja](https://ninja-build.org/),和其他,更多信息请参考[CMake Generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html。
|
||||
|
||||
更多关于 GoogleTest 兼容平台的信息,请参见 [支持的平台](platforms-zh.md) 。
|
||||
|
||||
如果你没有安装 CMake,参考 [CMake installation guide。](https://cmake.org/install)
|
||||
|
||||
{: .callout .note}
|
||||
注意: 本教程中的终端命令显示的是 Unix shell,但这些命令在 Windows 命令行是哪个也可以使用。
|
||||
|
||||
## 建立一个项目
|
||||
|
||||
CMake 使用一个叫 `CMakeLists.txt` 的文件来配置项目的构建系统。使用此文件来设置项目并声明对 GoogleTest 的依赖。
|
||||
|
||||
首先,为你的项目创建一个目录:
|
||||
|
||||
```
|
||||
$ mkdir my_project && cd my_project
|
||||
```
|
||||
|
||||
接着,创建 `CMakeLists.txt` 文件并声明对 GoogleTest 的依赖。在 CMake 系统中,有很多方法来表达依赖关系;在本教程中,你将使用 [`FetchContent` CMake 模块](https://cmake.org/cmake/help/latest/module/FetchContent.html)。为此,在工程目录下(`my_project`)创建一个名为 `CMakeLists.txt` 的文件,其内容为:
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(my_project)
|
||||
|
||||
# GoogleTest requires at least C++11
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
```
|
||||
|
||||
上述配置声明了对 GoogleTest 的依赖,其中 GoogleTest 将从 Github 上下载。上述例子中,`609281088cfefc76f9d0ce82e1ff6c30cc3591e5` 即 GoogleTest 版本的 Git commit ID。建议经常更新该值,以指向最新的版本。
|
||||
|
||||
关于如何创建 `CMakeLists.txt` 文件的更多信息,请参与 [CMake Tutorial](https://cmake.org/cmake/help/latest/guide/tutorial/index.html)。
|
||||
|
||||
## 创建并运行
|
||||
|
||||
有了 GoogleTest 的依赖后,你就可以在项目中使用 GoogleTest 了。
|
||||
|
||||
举个例子,在 `my_project` 目录下创建 `hello_test.cc` 文件,内容为:
|
||||
|
||||
```cpp
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// Demonstrate some basic assertions.
|
||||
TEST(HelloTest, BasicAssertions) {
|
||||
// Expect two strings not to be equal.
|
||||
EXPECT_STRNE("hello", "world");
|
||||
// Expect equality.
|
||||
EXPECT_EQ(7 * 6, 42);
|
||||
}
|
||||
```
|
||||
|
||||
GoogleTest 提供了许多 [断言](primer.md#assertions),可以用它们来测试代码的行为。上述示例中引入了 GoogleTest 的头文件并演示了一些基本的断言。
|
||||
|
||||
为了编译代码,在 `CMakeLists.txt` 末尾添加以下内容:
|
||||
|
||||
```cmake
|
||||
enable_testing()
|
||||
|
||||
add_executable(
|
||||
hello_test
|
||||
hello_test.cc
|
||||
)
|
||||
target_link_libraries(
|
||||
hello_test
|
||||
gtest_main
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(hello_test)
|
||||
```
|
||||
|
||||
上述配置在 CMake 中启动了测试,声明了你想要建立的测试可执行文件(`hello_test`)并链接了 GoogleTest(`gtest_main`)。最后两行使用 [`GoogleTest` CMake 模块](https://cmake.org/cmake/help/git-stage/module/GoogleTest.html) 让 CMake 的测试运行器能找到并执行测试。
|
||||
|
||||
现在你可以投建并运行你的测试了:
|
||||
|
||||
<pre>
|
||||
<strong>my_project$ cmake -S . -B build</strong>
|
||||
-- The C compiler identification is GNU 10.2.1
|
||||
-- The CXX compiler identification is GNU 10.2.1
|
||||
...
|
||||
-- Build files have been written to: .../my_project/build
|
||||
|
||||
<strong>my_project$ cmake --build build</strong>
|
||||
Scanning dependencies of target gtest
|
||||
...
|
||||
[100%] Built target gmock_main
|
||||
|
||||
<strong>my_project$ cd build && ctest</strong>
|
||||
Test project .../my_project/build
|
||||
Start 1: HelloTest.BasicAssertions
|
||||
1/1 Test #1: HelloTest.BasicAssertions ........ Passed 0.00 sec
|
||||
|
||||
100% tests passed, 0 tests failed out of 1
|
||||
|
||||
Total Test time (real) = 0.01 sec
|
||||
</pre>
|
||||
|
||||
恭喜!你已经成功地使用 GoogleTest 构建并运行了一个测试。
|
||||
|
||||
## 下一步行动
|
||||
|
||||
* [查看 Primer](primer.md) 开始学习如何编写简单的测试。
|
||||
* [看看更多例子](samples.md)学习如何使用 GoogleTest 的各种功能。
|
||||
@ -1957,6 +1957,11 @@ struct SignatureOf<R(Args...)> {
|
||||
using type = R(Args...);
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct SignatureOf<R(Args...) const> {
|
||||
using type = R(Args...);
|
||||
};
|
||||
|
||||
template <template <typename> class C, typename F>
|
||||
struct SignatureOf<C<F>,
|
||||
typename std::enable_if<std::is_function<F>::value>::type>
|
||||
|
||||
@ -942,6 +942,15 @@ static constexpr bool IsMockFunctionTemplateArgumentDeducedTo(
|
||||
|
||||
} // namespace
|
||||
|
||||
// Like std::add_const, but for function types.
|
||||
template <typename F>
|
||||
struct AddConstToFunction;
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct AddConstToFunction<R(Args...)> {
|
||||
using type = R(Args...) const;
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
class MockMethodMockFunctionSignatureTest : public Test {};
|
||||
|
||||
@ -953,25 +962,69 @@ TYPED_TEST_SUITE(MockMethodMockFunctionSignatureTest,
|
||||
|
||||
TYPED_TEST(MockMethodMockFunctionSignatureTest,
|
||||
IsMockFunctionTemplateArgumentDeducedForRawSignature) {
|
||||
using Argument = TypeParam;
|
||||
MockFunction<Argument> foo;
|
||||
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
|
||||
// Non-const
|
||||
{
|
||||
using Argument = TypeParam;
|
||||
MockFunction<Argument> foo;
|
||||
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
|
||||
}
|
||||
|
||||
// Const
|
||||
{
|
||||
using Argument = typename AddConstToFunction<TypeParam>::type;
|
||||
MockFunction<Argument> foo;
|
||||
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
|
||||
}
|
||||
}
|
||||
|
||||
TYPED_TEST(MockMethodMockFunctionSignatureTest,
|
||||
IsMockFunctionTemplateArgumentDeducedForStdFunction) {
|
||||
using Argument = std::function<TypeParam>;
|
||||
MockFunction<Argument> foo;
|
||||
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
|
||||
// Non-const
|
||||
{
|
||||
using Argument = std::function<TypeParam>;
|
||||
MockFunction<Argument> foo;
|
||||
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
|
||||
}
|
||||
|
||||
// As of 2026-05 MSVC doesn't know how to deal with this, providing pages of
|
||||
// inscrutable errors about std::_Get_function_impl. But this is fine, since
|
||||
// std::function<R(Args...) const> doesn't apply the const qualifier correctly
|
||||
// anyway.
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
// Const
|
||||
{
|
||||
using Argument =
|
||||
std::function<typename AddConstToFunction<TypeParam>::type>;
|
||||
|
||||
MockFunction<Argument> foo;
|
||||
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
TYPED_TEST(
|
||||
MockMethodMockFunctionSignatureTest,
|
||||
IsMockFunctionCallMethodSignatureTheSameForRawSignatureAndStdFunction) {
|
||||
using ForRawSignature = decltype(&MockFunction<TypeParam>::Call);
|
||||
using ForStdFunction =
|
||||
decltype(&MockFunction<std::function<TypeParam>>::Call);
|
||||
EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value));
|
||||
// Non-const
|
||||
{
|
||||
using ForRawSignature = decltype(&MockFunction<TypeParam>::Call);
|
||||
using ForStdFunction =
|
||||
decltype(&MockFunction<std::function<TypeParam>>::Call);
|
||||
EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value));
|
||||
}
|
||||
|
||||
// Const
|
||||
{
|
||||
using ConstTypeParam = typename AddConstToFunction<TypeParam>::type;
|
||||
using ForRawSignature = decltype(&MockFunction<ConstTypeParam>::Call);
|
||||
|
||||
using ForStdFunction =
|
||||
decltype(&MockFunction<std::function<ConstTypeParam>>::Call);
|
||||
|
||||
EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
|
||||
@ -129,7 +129,7 @@ class GTEST_API_ Message {
|
||||
int>::type = 0
|
||||
#endif // GTEST_HAS_ABSL
|
||||
>
|
||||
inline Message& operator<<(const T& val) {
|
||||
Message& operator<<(const T& val) {
|
||||
// Some libraries overload << for STL containers. These
|
||||
// overloads are defined in the global namespace instead of ::std.
|
||||
//
|
||||
@ -155,7 +155,7 @@ class GTEST_API_ Message {
|
||||
template <typename T,
|
||||
typename std::enable_if<absl::HasAbslStringify<T>::value, // NOLINT
|
||||
int>::type = 0>
|
||||
inline Message& operator<<(const T& val) {
|
||||
Message& operator<<(const T& val) {
|
||||
// ::operator<< is needed here for a similar reason as with the non-Abseil
|
||||
// version above
|
||||
using ::operator<<;
|
||||
|
||||
@ -229,7 +229,8 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
|
||||
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
|
||||
} \
|
||||
if (gtest_dt != nullptr) { \
|
||||
std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \
|
||||
const std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr( \
|
||||
gtest_dt); \
|
||||
switch (gtest_dt->AssumeRole()) { \
|
||||
case ::testing::internal::DeathTest::OVERSEE_TEST: \
|
||||
if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user