summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BUILD.bazel1
-rw-r--r--README.md43
-rw-r--r--WORKSPACE19
-rw-r--r--ci/windows-presubmit.bat24
-rw-r--r--docs/advanced.md207
-rw-r--r--docs/gmock_cook_book.md31
-rw-r--r--docs/platforms.md39
-rw-r--r--docs/primer.md70
-rw-r--r--docs/quickstart-bazel.md9
-rw-r--r--docs/quickstart-cmake.md1
-rw-r--r--googlemock/include/gmock/gmock-actions.h8
-rw-r--r--googlemock/include/gmock/gmock-cardinalities.h4
-rw-r--r--googlemock/include/gmock/gmock-matchers.h14
-rw-r--r--googlemock/include/gmock/gmock-spec-builders.h77
-rw-r--r--googlemock/include/gmock/internal/gmock-internal-utils.h4
-rw-r--r--googlemock/src/gmock-internal-utils.cc1
-rw-r--r--googlemock/src/gmock-spec-builders.cc9
-rw-r--r--googlemock/src/gmock.cc2
-rw-r--r--googlemock/test/gmock-actions_test.cc23
-rw-r--r--googlemock/test/gmock-cardinalities_test.cc4
-rw-r--r--googlemock/test/gmock-function-mocker_test.cc24
-rw-r--r--googlemock/test/gmock-internal-utils_test.cc1
-rw-r--r--googlemock/test/gmock-matchers-arithmetic_test.cc7
-rw-r--r--googlemock/test/gmock-matchers-comparisons_test.cc10
-rw-r--r--googlemock/test/gmock-matchers-containers_test.cc18
-rw-r--r--googlemock/test/gmock-matchers-misc_test.cc8
-rw-r--r--googlemock/test/gmock-more-actions_test.cc6
-rw-r--r--googlemock/test/gmock-nice-strict_test.cc8
-rw-r--r--googlemock/test/gmock-spec-builders_test.cc43
-rw-r--r--googlemock/test/gmock_ex_test.cc2
-rw-r--r--googlemock/test/gmock_leak_test_.cc4
-rw-r--r--googlemock/test/gmock_link_test.h4
-rw-r--r--googlemock/test/gmock_output_test_.cc11
-rw-r--r--googlemock/test/gmock_output_test_golden.txt22
-rw-r--r--googlemock/test/gmock_test.cc2
-rw-r--r--googletest/README.md8
-rw-r--r--googletest/cmake/internal_utils.cmake18
-rw-r--r--googletest/include/gtest/gtest-assertion-result.h4
-rw-r--r--googletest/include/gtest/gtest-matchers.h12
-rw-r--r--googletest/include/gtest/gtest-printers.h15
-rw-r--r--googletest/include/gtest/gtest-test-part.h4
-rw-r--r--googletest/include/gtest/gtest.h12
-rw-r--r--googletest/include/gtest/internal/gtest-death-test-internal.h4
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h2
-rw-r--r--googletest/include/gtest/internal/gtest-param-util.h26
-rw-r--r--googletest/include/gtest/internal/gtest-port.h35
-rw-r--r--googletest/include/gtest/internal/gtest-type-util.h30
-rw-r--r--googletest/samples/prime_tables.h2
-rw-r--r--googletest/samples/sample10_unittest.cc1
-rw-r--r--googletest/samples/sample8_unittest.cc2
-rw-r--r--googletest/samples/sample9_unittest.cc1
-rw-r--r--googletest/src/gtest-assertion-result.cc4
-rw-r--r--googletest/src/gtest-death-test.cc14
-rw-r--r--googletest/src/gtest-filepath.cc3
-rw-r--r--googletest/src/gtest-internal-inl.h14
-rw-r--r--googletest/src/gtest-port.cc8
-rw-r--r--googletest/src/gtest-printers.cc4
-rw-r--r--googletest/src/gtest-test-part.cc5
-rw-r--r--googletest/src/gtest-typed-test.cc6
-rw-r--r--googletest/src/gtest.cc133
-rw-r--r--googletest/test/googletest-death-test-test.cc3
-rw-r--r--googletest/test/googletest-filepath-test.cc2
-rw-r--r--googletest/test/googletest-json-outfiles-test.py2
-rw-r--r--googletest/test/googletest-json-output-unittest.py56
-rw-r--r--googletest/test/googletest-list-tests-unittest_.cc3
-rw-r--r--googletest/test/googletest-listener-test.cc1
-rwxr-xr-xgoogletest/test/googletest-output-test.py2
-rw-r--r--googletest/test/googletest-output-test_.cc3
-rw-r--r--googletest/test/googletest-param-test-invalid-name2-test_.cc2
-rw-r--r--googletest/test/googletest-port-test.cc10
-rw-r--r--googletest/test/googletest-printers-test.cc18
-rwxr-xr-xgoogletest/test/gtest_help_test.py14
-rw-r--r--googletest/test/gtest_repeat_test.cc2
-rw-r--r--googletest/test/gtest_stress_test.cc2
-rw-r--r--googletest/test/gtest_unittest.cc20
-rw-r--r--googletest/test/gtest_xml_outfile2_test_.cc2
-rwxr-xr-xgoogletest/test/gtest_xml_outfiles_test.py2
-rwxr-xr-xgoogletest/test/gtest_xml_output_unittest.py90
-rw-r--r--googletest/test/gtest_xml_output_unittest_.cc2
-rwxr-xr-xgoogletest/test/gtest_xml_test_utils.py2
-rw-r--r--googletest_deps.bzl22
81 files changed, 832 insertions, 555 deletions
diff --git a/BUILD.bazel b/BUILD.bazel
index ac62251..b1e3b7f 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -132,6 +132,7 @@ cc_library(
}),
deps = select({
":has_absl": [
+ "@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/debugging:failure_signal_handler",
"@com_google_absl//absl/debugging:stacktrace",
"@com_google_absl//absl/debugging:symbolize",
diff --git a/README.md b/README.md
index 23eb502..ef0c288 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,8 @@ GoogleTest now follows the
[Abseil Live at Head philosophy](https://abseil.io/about/philosophy#upgrade-support).
We recommend
[updating to the latest commit in the `main` branch as often as possible](https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-live-at-head-and-how-do-i-do-it).
+We do publish occasional semantic versions, tagged with
+`v${major}.${minor}.${patch}` (e.g. `v1.13.0`).
#### Documentation Updates
@@ -52,16 +54,37 @@ More information about building GoogleTest can be found at
## Features
-* An [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework.
-* Test discovery.
-* A rich set of assertions.
-* User-defined assertions.
-* Death tests.
-* Fatal and non-fatal failures.
-* Value-parameterized tests.
-* Type-parameterized tests.
-* Various options for running the tests.
-* XML test report generation.
+* xUnit test framework: \
+ Googletest is based on the [xUnit](https://en.wikipedia.org/wiki/XUnit)
+ testing framework, a popular architecture for unit testing
+* Test discovery: \
+ Googletest automatically discovers and runs your tests, eliminating the need
+ to manually register your tests
+* Rich set of assertions: \
+ Googletest provides a variety of assertions, such as equality, inequality,
+ exceptions, and more, making it easy to test your code
+* User-defined assertions: \
+ You can define your own assertions with Googletest, making it simple to
+ write tests that are specific to your code
+* Death tests: \
+ Googletest supports death tests, which verify that your code exits in a
+ certain way, making it useful for testing error-handling code
+* Fatal and non-fatal failures: \
+ You can specify whether a test failure should be treated as fatal or
+ non-fatal with Googletest, allowing tests to continue running even if a
+ failure occurs
+* Value-parameterized tests: \
+ Googletest supports value-parameterized tests, which run multiple times with
+ different input values, making it useful for testing functions that take
+ different inputs
+* Type-parameterized tests: \
+ Googletest also supports type-parameterized tests, which run with different
+ data types, making it useful for testing functions that work with different
+ data types
+* Various options for running tests: \
+ Googletest provides many options for running tests including running
+ individual tests, running tests in a specific order, and running tests in
+ parallel
## Supported Platforms
diff --git a/WORKSPACE b/WORKSPACE
index cb5f83f..1c8ea24 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,22 +1,9 @@
workspace(name = "com_google_googletest")
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-http_archive(
- name = "com_google_absl", # 2023-02-27T15:50:25Z
- sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76",
- strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc",
- urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"],
-)
+load("//:googletest_deps.bzl", "googletest_deps")
+googletest_deps()
-# Note this must use a commit from the `abseil` branch of the RE2 project.
-# https://github.com/google/re2/tree/abseil
-http_archive(
- name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z
- sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5",
- strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e",
- urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"],
-)
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python", # 2023-01-10T22:00:51Z
diff --git a/ci/windows-presubmit.bat b/ci/windows-presubmit.bat
index 8668ff3..48962eb 100644
--- a/ci/windows-presubmit.bat
+++ b/ci/windows-presubmit.bat
@@ -2,12 +2,14 @@ SETLOCAL ENABLEDELAYEDEXPANSION
SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-windows-x86_64.exe
-SET PATH=C:\Python37;%PATH%
-SET BAZEL_PYTHON=C:\python37\python.exe
+SET PATH=C:\Python34;%PATH%
+SET BAZEL_PYTHON=C:\python34\python.exe
SET BAZEL_SH=C:\tools\msys64\usr\bin\bash.exe
-SET CMAKE_BIN="C:\Program Files\CMake\bin\cmake.exe"
-SET CTEST_BIN="C:\Program Files\CMake\bin\ctest.exe"
+SET CMAKE_BIN="cmake.exe"
+SET CTEST_BIN="ctest.exe"
SET CTEST_OUTPUT_ON_FAILURE=1
+SET CMAKE_BUILD_PARALLEL_LEVEL=16
+SET CTEST_PARALLEL_LEVEL=16
IF EXIST git\googletest (
CD git\googletest
@@ -18,12 +20,12 @@ IF EXIST git\googletest (
IF %errorlevel% neq 0 EXIT /B 1
:: ----------------------------------------------------------------------------
-:: CMake Visual Studio 15 2017 Win64
-MKDIR cmake_msvc2017
-CD cmake_msvc2017
+:: CMake
+MKDIR cmake_msvc2022
+CD cmake_msvc2022
%CMAKE_BIN% .. ^
- -G "Visual Studio 15 2017 Win64" ^
+ -G "Visual Studio 17 2022" ^
-DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^
-DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^
-DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^
@@ -39,12 +41,12 @@ IF %errorlevel% neq 0 EXIT /B 1
IF %errorlevel% neq 0 EXIT /B 1
CD ..
-RMDIR /S /Q cmake_msvc2017
+RMDIR /S /Q cmake_msvc2022
:: ----------------------------------------------------------------------------
-:: Bazel Visual Studio 15 2017 Win64
+:: Bazel
-SET BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC
+SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
%BAZEL_EXE% test ... ^
--compilation_mode=dbg ^
--copt=/std:c++14 ^
diff --git a/docs/advanced.md b/docs/advanced.md
index 6b4c3f0..3871db1 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1,9 +1,9 @@
-# Advanced googletest Topics
+# Advanced GoogleTest Topics
## Introduction
-Now that you have read the [googletest Primer](primer.md) and learned how to
-write tests using googletest, it's time to learn some new tricks. This document
+Now that you have read the [GoogleTest Primer](primer.md) and learned how to
+write tests using GoogleTest, it's time to learn some new tricks. This document
will show you more assertions as well as how to construct complex failure
messages, propagate fatal failures, reuse and speed up your test fixtures, and
use various flags with your tests.
@@ -25,7 +25,7 @@ Reference.
### Predicate Assertions for Better Error Messages
-Even though googletest has a rich set of assertions, they can never be complete,
+Even though GoogleTest has a rich set of assertions, they can never be complete,
as it's impossible (nor a good idea) to anticipate all scenarios a user might
run into. Therefore, sometimes a user has to use `EXPECT_TRUE()` to check a
complex expression, for lack of a better macro. This has the problem of not
@@ -35,7 +35,7 @@ failure message by themselves, streaming it into `EXPECT_TRUE()`. However, this
is awkward especially when the expression has side-effects or is expensive to
evaluate.
-googletest gives you three different options to solve this problem:
+GoogleTest gives you three different options to solve this problem:
#### Using an Existing Boolean Function
@@ -304,9 +304,9 @@ TEST_F(SkipFixture, SkipsOneTest) {
As with assertion macros, you can stream a custom message into `GTEST_SKIP()`.
-## Teaching googletest How to Print Your Values
+## Teaching GoogleTest How to Print Your Values
-When a test assertion such as `EXPECT_EQ` fails, googletest prints the argument
+When a test assertion such as `EXPECT_EQ` fails, GoogleTest prints the argument
values to help you debug. It does this using a user-extensible value printer.
This printer knows how to print built-in C++ types, native arrays, STL
@@ -315,73 +315,96 @@ prints the raw bytes in the value and hopes that you the user can figure it out.
As mentioned earlier, the printer is *extensible*. That means you can teach it
to do a better job at printing your particular type than to dump the bytes. To
-do that, define `<<` for your type:
-
-```c++
-#include <ostream>
+do that, define an `AbslStringify()` overload as a `friend` function template
+for your type:
+```cpp
namespace foo {
-class Bar { // We want googletest to be able to print instances of this.
-...
- // Create a free inline friend function.
- friend std::ostream& operator<<(std::ostream& os, const Bar& bar) {
- return os << bar.DebugString(); // whatever needed to print bar to os
+class Point { // We want GoogleTest to be able to print instances of this.
+ ...
+ // Provide a friend overload.
+ template <typename Sink>
+ friend void AbslStringify(Sink& sink, const Point& point) {
+ absl::Format(&sink, "(%d, %d)", point.x, point.y);
}
+
+ int x;
+ int y;
};
// If you can't declare the function in the class it's important that the
-// << operator is defined in the SAME namespace that defines Bar. C++'s look-up
-// rules rely on that.
-std::ostream& operator<<(std::ostream& os, const Bar& bar) {
- return os << bar.DebugString(); // whatever needed to print bar to os
+// AbslStringify overload is defined in the SAME namespace that defines Point.
+// C++'s look-up rules rely on that.
+enum class EnumWithStringify { kMany = 0, kChoices = 1 };
+
+template <typename Sink>
+void AbslStringify(Sink& sink, EnumWithStringify e) {
+ absl::Format(&sink, "%s", e == EnumWithStringify::kMany ? "Many" : "Choices");
}
} // namespace foo
```
-Sometimes, this might not be an option: your team may consider it bad style to
-have a `<<` operator for `Bar`, or `Bar` may already have a `<<` operator that
-doesn't do what you want (and you cannot change it). If so, you can instead
-define a `PrintTo()` function like this:
+{: .callout .note}
+Note: `AbslStringify()` utilizes a generic "sink" buffer to construct its
+string. For more information about supported operations on `AbslStringify()`'s
+sink, see go/abslstringify.
+
+`AbslStringify()` can also use `absl::StrFormat`'s catch-all `%v` type specifier
+within its own format strings to perform type deduction. `Point` above could be
+formatted as `"(%v, %v)"` for example, and deduce the `int` values as `%d`.
+
+Sometimes, `AbslStringify()` might not be an option: your team may wish to print
+types with extra debugging information for testing purposes only. If so, you can
+instead define a `PrintTo()` function like this:
```c++
#include <ostream>
namespace foo {
-class Bar {
+class Point {
...
- friend void PrintTo(const Bar& bar, std::ostream* os) {
- *os << bar.DebugString(); // whatever needed to print bar to os
+ friend void PrintTo(const Point& point, std::ostream* os) {
+ *os << "(" << point.x << "," << point.y << ")";
}
+
+ int x;
+ int y;
};
// If you can't declare the function in the class it's important that PrintTo()
-// is defined in the SAME namespace that defines Bar. C++'s look-up rules rely
-// on that.
-void PrintTo(const Bar& bar, std::ostream* os) {
- *os << bar.DebugString(); // whatever needed to print bar to os
+// is defined in the SAME namespace that defines Point. C++'s look-up rules
+// rely on that.
+void PrintTo(const Point& point, std::ostream* os) {
+ *os << "(" << point.x << "," << point.y << ")";
}
} // namespace foo
```
-If you have defined both `<<` and `PrintTo()`, the latter will be used when
-googletest is concerned. This allows you to customize how the value appears in
-googletest's output without affecting code that relies on the behavior of its
-`<<` operator.
+If you have defined both `AbslStringify()` and `PrintTo()`, the latter will be
+used by GoogleTest. This allows you to customize how the value appears in
+GoogleTest's output without affecting code that relies on the behavior of
+`AbslStringify()`.
+
+If you have an existing `<<` operator and would like to define an
+`AbslStringify()`, the latter will be used for GoogleTest printing.
-If you want to print a value `x` using googletest's value printer yourself, just
+If you want to print a value `x` using GoogleTest's value printer yourself, just
call `::testing::PrintToString(x)`, which returns an `std::string`:
```c++
-vector<pair<Bar, int> > bar_ints = GetBarIntVector();
+vector<pair<Point, int> > point_ints = GetPointIntVector();
-EXPECT_TRUE(IsCorrectBarIntVector(bar_ints))
- << "bar_ints = " << testing::PrintToString(bar_ints);
+EXPECT_TRUE(IsCorrectPointIntVector(point_ints))
+ << "point_ints = " << testing::PrintToString(point_ints);
```
+For more details regarding `AbslStringify()` and its integration with other
+libraries, see go/abslstringify.
+
## Death Tests
In many applications, there are assertions that can cause application failure if
@@ -451,7 +474,7 @@ Note that a death test only cares about three things:
3. does the stderr output match `matcher`?
In particular, if `statement` generates an `ASSERT_*` or `EXPECT_*` failure, it
-will **not** cause the death test to fail, as googletest assertions don't abort
+will **not** cause the death test to fail, as GoogleTest assertions don't abort
the process.
### Death Test Naming
@@ -482,14 +505,14 @@ TEST_F(FooDeathTest, DoesThat) {
### Regular Expression Syntax
-When built with Bazel and using Abseil, googletest uses the
+When built with Bazel and using Abseil, GoogleTest uses the
[RE2](https://github.com/google/re2/wiki/Syntax) syntax. Otherwise, for POSIX
-systems (Linux, Cygwin, Mac), googletest uses the
+systems (Linux, Cygwin, Mac), GoogleTest uses the
[POSIX extended regular expression](http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)
syntax. To learn about POSIX syntax, you may want to read this
[Wikipedia entry](http://en.wikipedia.org/wiki/Regular_expression#POSIX_extended).
-On Windows, googletest uses its own simple regular expression implementation. It
+On Windows, GoogleTest uses its own simple regular expression implementation. It
lacks many features. For example, we don't support union (`"x|y"`), grouping
(`"(xy)"`), brackets (`"[xy]"`), and repetition count (`"x{5,7}"`), among
others. Below is what we do support (`A` denotes a literal character, period
@@ -519,7 +542,7 @@ Expression | Meaning
`$` | matches the end of a string (not that of each line)
`xy` | matches `x` followed by `y`
-To help you determine which capability is available on your system, googletest
+To help you determine which capability is available on your system, GoogleTest
defines macros to govern which regular expression it is using. The macros are:
`GTEST_USES_SIMPLE_RE=1` or `GTEST_USES_POSIX_RE=1`. If you want your death
tests to work in all cases, you can either `#if` on these macros or use the more
@@ -539,7 +562,7 @@ arrange that kind of environment. For example, statically-initialized modules
may start threads before main is ever reached. Once threads have been created,
it may be difficult or impossible to clean them up.
-googletest has three features intended to raise awareness of threading issues.
+GoogleTest has three features intended to raise awareness of threading issues.
1. A warning is emitted if multiple threads are running when a death test is
encountered.
@@ -592,7 +615,7 @@ TEST(MyDeathTest, TestTwo) {
The `statement` argument of `ASSERT_EXIT()` can be any valid C++ statement. If
it leaves the current function via a `return` statement or by throwing an
-exception, the death test is considered to have failed. Some googletest macros
+exception, the death test is considered to have failed. Some GoogleTest macros
may return from the current function (e.g. `ASSERT_TRUE()`), so be sure to avoid
them in `statement`.
@@ -726,7 +749,7 @@ TEST(FooTest, Bar) {
}
```
-To alleviate this, googletest provides three different solutions. You could use
+To alleviate this, GoogleTest provides three different solutions. You could use
either exceptions, the `(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the
`HasFatalFailure()` function. They are described in the following two
subsections.
@@ -760,7 +783,7 @@ in it, the test will continue after the subroutine returns. This may not be what
you want.
Often people want fatal failures to propagate like exceptions. For that
-googletest offers the following macros:
+GoogleTest offers the following macros:
Fatal assertion | Nonfatal assertion | Verifies
------------------------------------- | ------------------------------------- | --------
@@ -852,7 +875,7 @@ will output XML like this:
> needs to be prefixed with `::testing::Test::` if used outside of the
> `TEST` body and the test fixture class.
> * *`key`* must be a valid XML attribute name, and cannot conflict with the
-> ones already used by googletest (`name`, `status`, `time`, `classname`,
+> ones already used by GoogleTest (`name`, `status`, `time`, `classname`,
> `type_param`, and `value_param`).
> * Calling `RecordProperty()` outside of the lifespan of a test is allowed.
> If it's called outside of a test but between a test suite's
@@ -863,13 +886,13 @@ will output XML like this:
## Sharing Resources Between Tests in the Same Test Suite
-googletest creates a new test fixture object for each test in order to make
+GoogleTest creates a new test fixture object for each test in order to make
tests independent and easier to debug. However, sometimes tests use resources
that are expensive to set up, making the one-copy-per-test model prohibitively
expensive.
If the tests don't change the resource, there's no harm in their sharing a
-single resource copy. So, in addition to per-test set-up/tear-down, googletest
+single resource copy. So, in addition to per-test set-up/tear-down, GoogleTest
also supports per-test-suite set-up/tear-down. To use it:
1. In your test fixture class (say `FooTest` ), declare as `static` some member
@@ -881,7 +904,7 @@ also supports per-test-suite set-up/tear-down. To use it:
`u`!) to set up the shared resources and a `static void TearDownTestSuite()`
function to tear them down.
-That's it! googletest automatically calls `SetUpTestSuite()` before running the
+That's it! GoogleTest automatically calls `SetUpTestSuite()` before running the
*first test* in the `FooTest` test suite (i.e. before creating the first
`FooTest` object), and calls `TearDownTestSuite()` after running the *last test*
in it (i.e. after deleting the last `FooTest` object). In between, the tests can
@@ -974,7 +997,7 @@ class Environment : public ::testing::Environment {
};
```
-Then, you register an instance of your environment class with googletest by
+Then, you register an instance of your environment class with GoogleTest by
calling the `::testing::AddGlobalTestEnvironment()` function:
```c++
@@ -991,7 +1014,7 @@ It's OK to register multiple environment objects. In this suite, their `SetUp()`
will be called in the order they are registered, and their `TearDown()` will be
called in the reverse order.
-Note that googletest takes ownership of the registered environment objects.
+Note that GoogleTest takes ownership of the registered environment objects.
Therefore **do not delete them** by yourself.
You should call `AddGlobalTestEnvironment()` before `RUN_ALL_TESTS()` is called,
@@ -1043,7 +1066,7 @@ they must be declared **public** rather than **protected** in order to use
```c++
class FooTest :
- public testing::TestWithParam<const char*> {
+ public testing::TestWithParam<absl::string_view> {
// You can implement all the usual fixture class members here.
// To access the test parameter, call GetParam() from class
// TestWithParam<T>.
@@ -1054,7 +1077,7 @@ class BaseTest : public testing::Test {
...
};
class BarTest : public BaseTest,
- public testing::WithParamInterface<const char*> {
+ public testing::WithParamInterface<absl::string_view> {
...
};
```
@@ -1125,8 +1148,8 @@ with parameter values `"cat"` and `"dog"` using the
[`ValuesIn`](reference/testing.md#param-generators) parameter generator:
```c++
-const char* pets[] = {"cat", "dog"};
-INSTANTIATE_TEST_SUITE_P(Pets, FooTest, testing::ValuesIn(pets));
+constexpr absl::string_view kPets[] = {"cat", "dog"};
+INSTANTIATE_TEST_SUITE_P(Pets, FooTest, testing::ValuesIn(kPets));
```
The tests from the instantiation above will have these names:
@@ -1501,12 +1524,12 @@ To test them, we use the following special techniques:
## "Catching" Failures
-If you are building a testing utility on top of googletest, you'll want to test
-your utility. What framework would you use to test it? googletest, of course.
+If you are building a testing utility on top of GoogleTest, you'll want to test
+your utility. What framework would you use to test it? GoogleTest, of course.
The challenge is to verify that your testing utility reports failures correctly.
In frameworks that report a failure by throwing an exception, you could catch
-the exception and assert on it. But googletest doesn't use exceptions, so how do
+the exception and assert on it. But GoogleTest doesn't use exceptions, so how do
we test that a piece of code generates an expected failure?
`"gtest/gtest-spi.h"` contains some constructs to do this.
@@ -1649,9 +1672,9 @@ particular, you cannot find the test suite name in `SetUpTestSuite()`,
`TearDownTestSuite()` (where you know the test suite name implicitly), or
functions called from them.
-## Extending googletest by Handling Test Events
+## Extending GoogleTest by Handling Test Events
-googletest provides an **event listener API** to let you receive notifications
+GoogleTest provides an **event listener API** to let you receive notifications
about the progress of a test program and test failures. The events you can
listen to include the start and end of the test program, a test suite, or a test
method, among others. You may use this API to augment or replace the standard
@@ -1712,7 +1735,7 @@ Here's an example:
### Using Event Listeners
To use the event listener you have defined, add an instance of it to the
-googletest event listener list (represented by class
+GoogleTest event listener list (represented by class
[`TestEventListeners`](reference/testing.md#TestEventListeners) - note the "s"
at the end of the name) in your `main()` function, before calling
`RUN_ALL_TESTS()`:
@@ -1723,7 +1746,7 @@ int main(int argc, char** argv) {
// Gets hold of the event listener list.
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
- // Adds a listener to the end. googletest takes the ownership.
+ // Adds a listener to the end. GoogleTest takes the ownership.
listeners.Append(new MinimalistPrinter);
return RUN_ALL_TESTS();
}
@@ -1775,7 +1798,7 @@ See [sample10_unittest.cc] for an example of a failure-raising listener.
## Running Test Programs: Advanced Options
-googletest test programs are ordinary executables. Once built, you can run them
+GoogleTest test programs are ordinary executables. Once built, you can run them
directly and affect their behavior via the following environment variables
and/or command line flags. For the flags to work, your programs must call
`::testing::InitGoogleTest()` before calling `RUN_ALL_TESTS()`.
@@ -1808,10 +1831,10 @@ corresponding environment variable for this flag.
#### Running a Subset of the Tests
-By default, a googletest program runs all tests the user has defined. Sometimes,
+By default, a GoogleTest program runs all tests the user has defined. Sometimes,
you want to run only a subset of the tests (e.g. for debugging or quickly
verifying a change). If you set the `GTEST_FILTER` environment variable or the
-`--gtest_filter` flag to a filter string, googletest will only run the tests
+`--gtest_filter` flag to a filter string, GoogleTest will only run the tests
whose full names (in the form of `TestSuiteName.TestName`) match the filter.
The format of a filter is a '`:`'-separated list of wildcard patterns (called
@@ -1842,7 +1865,7 @@ For example:
#### Stop test execution upon first failure
-By default, a googletest program runs all tests the user has defined. In some
+By default, a GoogleTest program runs all tests the user has defined. In some
cases (e.g. iterative test development & execution) it may be desirable stop
test execution upon first failure (trading improved latency for completeness).
If `GTEST_FAIL_FAST` environment variable or `--gtest_fail_fast` flag is set,
@@ -1859,7 +1882,7 @@ If you need to disable all tests in a test suite, you can either add `DISABLED_`
to the front of the name of each test, or alternatively add it to the front of
the test suite name.
-For example, the following tests won't be run by googletest, even though they
+For example, the following tests won't be run by GoogleTest, even though they
will still be compiled:
```c++
@@ -1874,7 +1897,7 @@ TEST_F(DISABLED_BarTest, DoesXyz) { ... }
{: .callout .note}
NOTE: This feature should only be used for temporary pain-relief. You still have
-to fix the disabled tests at a later date. As a reminder, googletest will print
+to fix the disabled tests at a later date. As a reminder, GoogleTest will print
a banner warning you if a test program contains any disabled tests.
{: .callout .tip}
@@ -1932,16 +1955,16 @@ You can specify the `--gtest_shuffle` flag (or set the `GTEST_SHUFFLE`
environment variable to `1`) to run the tests in a program in a random order.
This helps to reveal bad dependencies between tests.
-By default, googletest uses a random seed calculated from the current time.
+By default, GoogleTest uses a random seed calculated from the current time.
Therefore you'll get a different order every time. The console output includes
the random seed value, such that you can reproduce an order-related test failure
later. To specify the random seed explicitly, use the `--gtest_random_seed=SEED`
flag (or set the `GTEST_RANDOM_SEED` environment variable), where `SEED` is an
integer in the range [0, 99999]. The seed value 0 is special: it tells
-googletest to do the default behavior of calculating the seed from the current
+GoogleTest to do the default behavior of calculating the seed from the current
time.
-If you combine this with `--gtest_repeat=N`, googletest will pick a different
+If you combine this with `--gtest_repeat=N`, GoogleTest will pick a different
random seed and re-shuffle the tests in each iteration.
### Distributing Test Functions to Multiple Machines
@@ -2000,7 +2023,7 @@ shards, but here's one possible scenario:
#### Colored Terminal Output
-googletest can use colors in its terminal output to make it easier to spot the
+GoogleTest can use colors in its terminal output to make it easier to spot the
important information:
<pre>...
@@ -2025,25 +2048,25 @@ important information:
You can set the `GTEST_COLOR` environment variable or the `--gtest_color`
command line flag to `yes`, `no`, or `auto` (the default) to enable colors,
-disable colors, or let googletest decide. When the value is `auto`, googletest
+disable colors, or let GoogleTest decide. When the value is `auto`, GoogleTest
will use colors if and only if the output goes to a terminal and (on non-Windows
platforms) the `TERM` environment variable is set to `xterm` or `xterm-color`.
#### Suppressing test passes
-By default, googletest prints 1 line of output for each test, indicating if it
+By default, GoogleTest prints 1 line of output for each test, indicating if it
passed or failed. To show only test failures, run the test program with
`--gtest_brief=1`, or set the GTEST_BRIEF environment variable to `1`.
#### Suppressing the Elapsed Time
-By default, googletest prints the time it takes to run each test. To disable
+By default, GoogleTest prints the time it takes to run each test. To disable
that, run the test program with the `--gtest_print_time=0` command line flag, or
set the GTEST_PRINT_TIME environment variable to `0`.
#### Suppressing UTF-8 Text Output
-In case of assertion failures, googletest prints expected and actual values of
+In case of assertion failures, GoogleTest prints expected and actual values of
type `string` both as hex-encoded strings as well as in readable UTF-8 text if
they contain valid non-ASCII UTF-8 characters. If you want to suppress the UTF-8
text because, for example, you don't have an UTF-8 compatible output medium, run
@@ -2052,7 +2075,7 @@ environment variable to `0`.
#### Generating an XML Report
-googletest can emit a detailed XML report to a file in addition to its normal
+GoogleTest can emit a detailed XML report to a file in addition to its normal
textual output. The report contains the duration of each test, and thus can help
you identify slow tests.
@@ -2063,15 +2086,15 @@ in which case the output can be found in the `test_detail.xml` file in the
current directory.
If you specify a directory (for example, `"xml:output/directory/"` on Linux or
-`"xml:output\directory\"` on Windows), googletest will create the XML file in
+`"xml:output\directory\"` on Windows), GoogleTest will create the XML file in
that directory, named after the test executable (e.g. `foo_test.xml` for test
program `foo_test` or `foo_test.exe`). If the file already exists (perhaps left
-over from a previous run), googletest will pick a different name (e.g.
+over from a previous run), GoogleTest will pick a different name (e.g.
`foo_test_1.xml`) to avoid overwriting it.
The report is based on the `junitreport` Ant task. Since that format was
originally intended for Java, a little interpretation is required to make it
-apply to googletest tests, as shown here:
+apply to GoogleTest tests, as shown here:
```xml
<testsuites name="AllTests" ...>
@@ -2086,8 +2109,8 @@ apply to googletest tests, as shown here:
```
* The root `<testsuites>` element corresponds to the entire test program.
-* `<testsuite>` elements correspond to googletest test suites.
-* `<testcase>` elements correspond to googletest test functions.
+* `<testsuite>` elements correspond to GoogleTest test suites.
+* `<testcase>` elements correspond to GoogleTest test functions.
For instance, the following program
@@ -2120,7 +2143,7 @@ could generate this report:
Things to note:
* The `tests` attribute of a `<testsuites>` or `<testsuite>` element tells how
- many test functions the googletest program or test suite contains, while the
+ many test functions the GoogleTest program or test suite contains, while the
`failures` attribute tells how many of them failed.
* The `time` attribute expresses the duration of the test, test suite, or
@@ -2132,12 +2155,12 @@ Things to note:
* The `file` and `line` attributes record the source file location, where the
test was defined.
-* Each `<failure>` element corresponds to a single failed googletest
+* Each `<failure>` element corresponds to a single failed GoogleTest
assertion.
#### Generating a JSON Report
-googletest can also emit a JSON report as an alternative format to XML. To
+GoogleTest can also emit a JSON report as an alternative format to XML. To
generate the JSON report, set the `GTEST_OUTPUT` environment variable or the
`--gtest_output` flag to the string `"json:path_to_output_file"`, which will
create the file at the given location. You can also just use the string
@@ -2362,7 +2385,7 @@ variable has been set.
When running test programs under a debugger, it's very convenient if the
debugger can catch an assertion failure and automatically drop into interactive
-mode. googletest's *break-on-failure* mode supports this behavior.
+mode. GoogleTest's *break-on-failure* mode supports this behavior.
To enable it, set the `GTEST_BREAK_ON_FAILURE` environment variable to a value
other than `0`. Alternatively, you can use the `--gtest_break_on_failure`
@@ -2370,9 +2393,9 @@ command line flag.
#### Disabling Catching Test-Thrown Exceptions
-googletest can be used either with or without exceptions enabled. If a test
+GoogleTest can be used either with or without exceptions enabled. If a test
throws a C++ exception or (on Windows) a structured exception (SEH), by default
-googletest catches it, reports it as a test failure, and continues with the next
+GoogleTest catches it, reports it as a test failure, and continues with the next
test method. This maximizes the coverage of a test run. Also, on Windows an
uncaught exception will cause a pop-up window, so catching the exceptions allows
you to run the tests automatically.
@@ -2410,4 +2433,4 @@ void __tsan_on_report() {
```
After compiling your project with one of the sanitizers enabled, if a particular
-test triggers a sanitizer error, googletest will report that it failed.
+test triggers a sanitizer error, GoogleTest will report that it failed.
diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index d11282f..d57be58 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -2781,26 +2781,21 @@ action:
If you are not happy with the default action, you can tweak it as usual; see
[Setting Default Actions](#OnCall).
-If you just need to return a pre-defined move-only value, you can use the
-`Return(ByMove(...))` action:
+If you just need to return a move-only value, you can use it in combination with
+`WillOnce`. For example:
```cpp
- // When this fires, the unique_ptr<> specified by ByMove(...) will
- // be returned.
- EXPECT_CALL(mock_buzzer_, MakeBuzz("world"))
- .WillOnce(Return(ByMove(std::make_unique<Buzz>(AccessLevel::kInternal))));
-
- EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("world"));
+ EXPECT_CALL(mock_buzzer_, MakeBuzz("hello"))
+ .WillOnce(Return(std::make_unique<Buzz>(AccessLevel::kInternal)));
+ EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("hello"));
```
-Note that `ByMove()` is essential here - if you drop it, the code won’t compile.
-
-Quiz time! What do you think will happen if a `Return(ByMove(...))` action is
-performed more than once (e.g. you write `...
-.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first time
-the action runs, the source value will be consumed (since it’s a move-only
-value), so the next time around, there’s no value to move from -- you’ll get a
-run-time error that `Return(ByMove(...))` can only be run once.
+Quiz time! What do you think will happen if a `Return` action is performed more
+than once (e.g. you write `... .WillRepeatedly(Return(std::move(...)));`)? Come
+think of it, after the first time the action runs, the source value will be
+consumed (since it’s a move-only value), so the next time around, there’s no
+value to move from -- you’ll get a run-time error that `Return(std::move(...))`
+can only be run once.
If you need your mock method to do more than just moving a pre-defined value,
remember that you can always use a lambda or a callable object, which can do
@@ -2817,7 +2812,7 @@ pretty much anything you want:
```
Every time this `EXPECT_CALL` fires, a new `unique_ptr<Buzz>` will be created
-and returned. You cannot do this with `Return(ByMove(...))`.
+and returned. You cannot do this with `Return(std::make_unique<...>(...))`.
That covers returning move-only values; but how do we work with methods
accepting move-only arguments? The answer is that they work normally, although
@@ -4298,7 +4293,7 @@ particular type than to dump the bytes.
### Mock std::function {#MockFunction}
`std::function` is a general function type introduced in C++11. It is a
-preferred way of passing callbacks to new interfaces. Functions are copiable,
+preferred way of passing callbacks to new interfaces. Functions are copyable,
and are not usually passed around by pointer, which makes them tricky to mock.
But fear not - `MockFunction` can help you with that.
diff --git a/docs/platforms.md b/docs/platforms.md
index eba6ef8..d35a7be 100644
--- a/docs/platforms.md
+++ b/docs/platforms.md
@@ -1,35 +1,8 @@
# Supported Platforms
-GoogleTest requires a codebase and compiler compliant with the C++11 standard or
-newer.
-
-The GoogleTest code is officially supported on the following platforms.
-Operating systems or tools not listed below are community-supported. For
-community-supported platforms, patches that do not complicate the code may be
-considered.
-
-If you notice any problems on your platform, please file an issue on the
-[GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues).
-Pull requests containing fixes are welcome!
-
-### Operating systems
-
-* Linux
-* macOS
-* Windows
-
-### Compilers
-
-* gcc 5.0+
-* clang 5.0+
-* MSVC 2015+
-
-**macOS users:** Xcode 9.3+ provides clang 5.0+.
-
-### Build systems
-
-* [Bazel](https://bazel.build/)
-* [CMake](https://cmake.org/)
-
-Bazel is the build system used by the team internally and in tests. CMake is
-supported on a best-effort basis and by the community.
+GoogleTest follows Google's
+[Foundational C++ Support Policy](https://opensource.google/documentation/policies/cplusplus-support).
+See
+[this table](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md)
+for a list of currently supported versions compilers, platforms, and build
+tools.
diff --git a/docs/primer.md b/docs/primer.md
index d559fe8..c3aee3c 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -1,74 +1,74 @@
-# Googletest Primer
+# GoogleTest Primer
-## Introduction: Why googletest?
+## Introduction: Why GoogleTest?
-*googletest* helps you write better C++ tests.
+*GoogleTest* helps you write better C++ tests.
-googletest is a testing framework developed by the Testing Technology team with
+GoogleTest is a testing framework developed by the Testing Technology team with
Google's specific requirements and constraints in mind. Whether you work on
-Linux, Windows, or a Mac, if you write C++ code, googletest can help you. And it
+Linux, Windows, or a Mac, if you write C++ code, GoogleTest can help you. And it
supports *any* kind of tests, not just unit tests.
-So what makes a good test, and how does googletest fit in? We believe:
+So what makes a good test, and how does GoogleTest fit in? We believe:
1. Tests should be *independent* and *repeatable*. It's a pain to debug a test
- that succeeds or fails as a result of other tests. googletest isolates the
+ that succeeds or fails as a result of other tests. GoogleTest isolates the
tests by running each of them on a different object. When a test fails,
- googletest allows you to run it in isolation for quick debugging.
+ GoogleTest allows you to run it in isolation for quick debugging.
2. Tests should be well *organized* and reflect the structure of the tested
- code. googletest groups related tests into test suites that can share data
+ code. GoogleTest groups related tests into test suites that can share data
and subroutines. This common pattern is easy to recognize and makes tests
easy to maintain. Such consistency is especially helpful when people switch
projects and start to work on a new code base.
3. Tests should be *portable* and *reusable*. Google has a lot of code that is
- platform-neutral; its tests should also be platform-neutral. googletest
+ platform-neutral; its tests should also be platform-neutral. GoogleTest
works on different OSes, with different compilers, with or without
- exceptions, so googletest tests can work with a variety of configurations.
+ exceptions, so GoogleTest tests can work with a variety of configurations.
4. When tests fail, they should provide as much *information* about the problem
- as possible. googletest doesn't stop at the first test failure. Instead, it
+ as possible. GoogleTest doesn't stop at the first test failure. Instead, it
only stops the current test and continues with the next. You can also set up
tests that report non-fatal failures after which the current test continues.
Thus, you can detect and fix multiple bugs in a single run-edit-compile
cycle.
5. The testing framework should liberate test writers from housekeeping chores
- and let them focus on the test *content*. googletest automatically keeps
+ and let them focus on the test *content*. GoogleTest automatically keeps
track of all tests defined, and doesn't require the user to enumerate them
in order to run them.
-6. Tests should be *fast*. With googletest, you can reuse shared resources
+6. Tests should be *fast*. With GoogleTest, you can reuse shared resources
across tests and pay for the set-up/tear-down only once, without making
tests depend on each other.
-Since googletest is based on the popular xUnit architecture, you'll feel right
+Since GoogleTest is based on the popular xUnit architecture, you'll feel right
at home if you've used JUnit or PyUnit before. If not, it will take you about 10
minutes to learn the basics and get started. So let's go!
-## Beware of the nomenclature
+## Beware of the Nomenclature
{: .callout .note}
*Note:* There might be some confusion arising from different definitions of the
terms *Test*, *Test Case* and *Test Suite*, so beware of misunderstanding these.
-Historically, googletest started to use the term *Test Case* for grouping
+Historically, GoogleTest started to use the term *Test Case* for grouping
related tests, whereas current publications, including International Software
Testing Qualifications Board ([ISTQB](http://www.istqb.org/)) materials and
various textbooks on software quality, use the term
*[Test Suite][istqb test suite]* for this.
-The related term *Test*, as it is used in googletest, corresponds to the term
+The related term *Test*, as it is used in GoogleTest, corresponds to the term
*[Test Case][istqb test case]* of ISTQB and others.
The term *Test* is commonly of broad enough sense, including ISTQB's definition
of *Test Case*, so it's not much of a problem here. But the term *Test Case* as
was used in Google Test is of contradictory sense and thus confusing.
-googletest recently started replacing the term *Test Case* with *Test Suite*.
+GoogleTest recently started replacing the term *Test Case* with *Test Suite*.
The preferred API is *TestSuite*. The older TestCase API is being slowly
deprecated and refactored away.
So please be aware of the different definitions of the terms:
-Meaning | googletest Term | [ISTQB](http://www.istqb.org/) Term
+Meaning | GoogleTest Term | [ISTQB](http://www.istqb.org/) Term
:----------------------------------------------------------------------------------- | :---------------------- | :----------------------------------
Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case][istqb test case]
@@ -78,7 +78,7 @@ Exercise a particular program path with specific input values and verify the res
## Basic Concepts
-When using googletest, you start by writing *assertions*, which are statements
+When using GoogleTest, you start by writing *assertions*, which are statements
that check whether a condition is true. An assertion's result can be *success*,
*nonfatal failure*, or *fatal failure*. If a fatal failure occurs, it aborts the
current function; otherwise the program continues normally.
@@ -98,11 +98,11 @@ assertion level and building up to tests and test suites.
## Assertions
-googletest assertions are macros that resemble function calls. You test a class
+GoogleTest assertions are macros that resemble function calls. You test a class
or function by making assertions about its behavior. When an assertion fails,
-googletest prints the assertion's source file and line number location, along
+GoogleTest prints the assertion's source file and line number location, along
with a failure message. You may also supply a custom failure message which will
-be appended to googletest's message.
+be appended to GoogleTest's message.
The assertions come in pairs that test the same thing but have different effects
on the current function. `ASSERT_*` versions generate fatal failures when they
@@ -149,7 +149,7 @@ To create a test:
1. Use the `TEST()` macro to define and name a test function. These are
ordinary C++ functions that don't return a value.
2. In this function, along with any valid C++ statements you want to include,
- use the various googletest assertions to check values.
+ use the various GoogleTest assertions to check values.
3. The test's result is determined by the assertions; if any assertion in the
test fails (either fatally or non-fatally), or if the test crashes, the
entire test fails. Otherwise, it succeeds.
@@ -190,7 +190,7 @@ TEST(FactorialTest, HandlesPositiveInput) {
}
```
-googletest groups the test results by test suites, so logically related tests
+GoogleTest groups the test results by test suites, so logically related tests
should be in the same test suite; in other words, the first argument to their
`TEST()` should be the same. In the above example, we have two tests,
`HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test
@@ -244,12 +244,12 @@ Also, you must first define a test fixture class before using it in a
`TEST_F()`, or you'll get the compiler error "`virtual outside class
declaration`".
-For each test defined with `TEST_F()`, googletest will create a *fresh* test
+For each test defined with `TEST_F()`, GoogleTest will create a *fresh* test
fixture at runtime, immediately initialize it via `SetUp()`, run the test, clean
up by calling `TearDown()`, and then delete the test fixture. Note that
different tests in the same test suite have different test fixture objects, and
-googletest always deletes a test fixture before it creates the next one.
-googletest does **not** reuse the same test fixture for multiple tests. Any
+GoogleTest always deletes a test fixture before it creates the next one.
+GoogleTest does **not** reuse the same test fixture for multiple tests. Any
changes one test makes to the fixture do not affect other tests.
As an example, let's write tests for a FIFO queue class named `Queue`, which has
@@ -325,7 +325,7 @@ would lead to a segfault when `n` is `NULL`.
When these tests run, the following happens:
-1. googletest constructs a `QueueTest` object (let's call it `t1`).
+1. GoogleTest constructs a `QueueTest` object (let's call it `t1`).
2. `t1.SetUp()` initializes `t1`.
3. The first test (`IsEmptyInitially`) runs on `t1`.
4. `t1.TearDown()` cleans up after the test finishes.
@@ -337,7 +337,7 @@ When these tests run, the following happens:
## Invoking the Tests
-`TEST()` and `TEST_F()` implicitly register their tests with googletest. So,
+`TEST()` and `TEST_F()` implicitly register their tests with GoogleTest. So,
unlike with many other C++ testing frameworks, you don't have to re-list all
your defined tests in order to run them.
@@ -348,7 +348,7 @@ test suites, or even different source files.
When invoked, the `RUN_ALL_TESTS()` macro:
-* Saves the state of all googletest flags.
+* Saves the state of all GoogleTest flags.
* Creates a test fixture object for the first test.
@@ -360,7 +360,7 @@ When invoked, the `RUN_ALL_TESTS()` macro:
* Deletes the fixture.
-* Restores the state of all googletest flags.
+* Restores the state of all GoogleTest flags.
* Repeats the above steps for the next test, until all tests have run.
@@ -374,7 +374,7 @@ If a fatal failure happens the subsequent steps will be skipped.
> return the value of `RUN_ALL_TESTS()`.
>
> Also, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than
-> once conflicts with some advanced googletest features (e.g., thread-safe
+> once conflicts with some advanced GoogleTest features (e.g., thread-safe
> [death tests](advanced.md#death-tests)) and thus is not supported.
**Availability**: Linux, Windows, Mac.
@@ -456,7 +456,7 @@ int main(int argc, char **argv) {
```
The `::testing::InitGoogleTest()` function parses the command line for
-googletest flags, and removes all recognized flags. This allows the user to
+GoogleTest flags, and removes all recognized flags. This allows the user to
control a test program's behavior via various flags, which we'll cover in the
[AdvancedGuide](advanced.md). You **must** call this function before calling
`RUN_ALL_TESTS()`, or the flags won't be properly initialized.
diff --git a/docs/quickstart-bazel.md b/docs/quickstart-bazel.md
index 15c27a2..4f693db 100644
--- a/docs/quickstart-bazel.md
+++ b/docs/quickstart-bazel.md
@@ -105,10 +105,17 @@ file (`@com_google_googletest`). For more information about Bazel `BUILD` files,
see the
[Bazel C++ Tutorial](https://docs.bazel.build/versions/main/tutorial/cpp.html).
+{: .callout .note}
+NOTE: In the example below, we assume Clang or GCC and set `--cxxopt=-std=c++14`
+to ensure that GoogleTest is compiled as C++14 instead of the compiler's default
+setting (which could be C++11). For MSVC, the equivalent would be
+`--cxxopt=/std:c++14`. See [Supported Platforms](platforms.md) for more details
+on supported language versions.
+
Now you can build and run your test:
<pre>
-<strong>my_workspace$ bazel test --test_output=all //:hello_test</strong>
+<strong>my_workspace$ bazel test --cxxopt=-std=c++14 --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:
diff --git a/docs/quickstart-cmake.md b/docs/quickstart-cmake.md
index 5abe504..4e422b7 100644
--- a/docs/quickstart-cmake.md
+++ b/docs/quickstart-cmake.md
@@ -54,6 +54,7 @@ project(my_project)
# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)
FetchContent_Declare(
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index c0bb8a9..bd9ba73 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -611,7 +611,7 @@ class DefaultValue {
private:
class ValueProducer {
public:
- virtual ~ValueProducer() {}
+ virtual ~ValueProducer() = default;
virtual T Produce() = 0;
};
@@ -699,8 +699,8 @@ class ActionInterface {
typedef typename internal::Function<F>::Result Result;
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
- ActionInterface() {}
- virtual ~ActionInterface() {}
+ ActionInterface() = default;
+ virtual ~ActionInterface() = default;
// Performs the action. This method is not const, as in general an
// action can have side effects and be stateful. For example, a
@@ -749,7 +749,7 @@ class Action<R(Args...)> {
// Constructs a null Action. Needed for storing Action objects in
// STL containers.
- Action() {}
+ Action() = default;
// Construct an Action from a specified callable.
// This cannot take std::function directly, because then Action would not be
diff --git a/googlemock/include/gmock/gmock-cardinalities.h b/googlemock/include/gmock/gmock-cardinalities.h
index b6ab648..533e604 100644
--- a/googlemock/include/gmock/gmock-cardinalities.h
+++ b/googlemock/include/gmock/gmock-cardinalities.h
@@ -65,7 +65,7 @@ namespace testing {
// The implementation of a cardinality.
class CardinalityInterface {
public:
- virtual ~CardinalityInterface() {}
+ virtual ~CardinalityInterface() = default;
// Conservative estimate on the lower/upper bound of the number of
// calls allowed.
@@ -92,7 +92,7 @@ class GTEST_API_ Cardinality {
public:
// Constructs a null cardinality. Needed for storing Cardinality
// objects in STL containers.
- Cardinality() {}
+ Cardinality() = default;
// Constructs a Cardinality from its implementation.
explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index a480576..0f67713 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -257,6 +257,7 @@
#include <algorithm>
#include <cmath>
+#include <exception>
#include <functional>
#include <initializer_list>
#include <ios>
@@ -563,7 +564,7 @@ namespace internal {
// If the explanation is not empty, prints it to the ostream.
inline void PrintIfNotEmpty(const std::string& explanation,
::std::ostream* os) {
- if (explanation != "" && os != nullptr) {
+ if (!explanation.empty() && os != nullptr) {
*os << ", " << explanation;
}
}
@@ -2966,7 +2967,7 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
const bool match = inner_matcher_.MatchAndExplain(
pair_getters::First(key_value, Rank0()), &inner_listener);
const std::string explanation = inner_listener.str();
- if (explanation != "") {
+ if (!explanation.empty()) {
*listener << "whose first field is a value " << explanation;
}
return match;
@@ -3113,12 +3114,12 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
const std::string& second_explanation,
MatchResultListener* listener) const {
*listener << "whose both fields match";
- if (first_explanation != "") {
+ if (!first_explanation.empty()) {
*listener << ", where the first field is a value " << first_explanation;
}
- if (second_explanation != "") {
+ if (!second_explanation.empty()) {
*listener << ", ";
- if (first_explanation != "") {
+ if (!first_explanation.empty()) {
*listener << "and ";
} else {
*listener << "where ";
@@ -5544,7 +5545,8 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
\
private: \
::std::string FormatDescription(bool negation) const { \
- ::std::string gmock_description = (description); \
+ ::std::string gmock_description; \
+ gmock_description = (description); \
if (!gmock_description.empty()) { \
return gmock_description; \
} \
diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h
index 4e498d8..78ca15d 100644
--- a/googlemock/include/gmock/gmock-spec-builders.h
+++ b/googlemock/include/gmock/gmock-spec-builders.h
@@ -204,6 +204,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
using UntypedExpectations = std::vector<std::shared_ptr<ExpectationBase>>;
+ struct UninterestingCallCleanupHandler;
+ struct FailureCleanupHandler;
+
// Returns an Expectation object that references and co-owns exp,
// which must be an expectation on this mock function.
Expectation GetHandleOf(ExpectationBase* exp);
@@ -563,7 +566,7 @@ class ExpectationSet {
typedef Expectation::Set::value_type value_type;
// Constructs an empty set.
- ExpectationSet() {}
+ ExpectationSet() = default;
// This single-argument ctor must not be explicit, in order to support the
// ExpectationSet es = EXPECT_CALL(...);
@@ -1396,6 +1399,41 @@ class Cleanup final {
std::function<void()> f_;
};
+struct UntypedFunctionMockerBase::UninterestingCallCleanupHandler {
+ CallReaction reaction;
+ std::stringstream& ss;
+
+ ~UninterestingCallCleanupHandler() {
+ ReportUninterestingCall(reaction, ss.str());
+ }
+};
+
+struct UntypedFunctionMockerBase::FailureCleanupHandler {
+ std::stringstream& ss;
+ std::stringstream& why;
+ std::stringstream& loc;
+ const ExpectationBase* untyped_expectation;
+ bool found;
+ bool is_excessive;
+
+ ~FailureCleanupHandler() {
+ ss << "\n" << why.str();
+
+ if (!found) {
+ // No expectation matches this call - reports a failure.
+ Expect(false, nullptr, -1, ss.str());
+ } else if (is_excessive) {
+ // We had an upper-bound violation and the failure message is in ss.
+ Expect(false, untyped_expectation->file(), untyped_expectation->line(),
+ ss.str());
+ } else {
+ // We had an expected call and the matching expectation is
+ // described in ss.
+ Log(kInfo, loc.str() + ss.str(), 2);
+ }
+ }
+};
+
template <typename F>
class FunctionMocker;
@@ -1408,7 +1446,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
using ArgumentTuple = std::tuple<Args...>;
using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;
- FunctionMocker() {}
+ FunctionMocker() = default;
// There is no generally useful and implementable semantics of
// copying a mock object, so copying a mock is usually a user error.
@@ -1794,8 +1832,15 @@ R FunctionMocker<R(Args...)>::InvokeWith(ArgumentTuple&& args)
//
// We use RAII to do the latter in case R is void or a non-moveable type. In
// either case we can't assign it to a local variable.
- const Cleanup report_uninteresting_call(
- [&] { ReportUninterestingCall(reaction, ss.str()); });
+ //
+ // Note that std::bind() is essential here.
+ // We *don't* use any local callback types (like lambdas).
+ // Doing so slows down compilation dramatically because the *constructor* of
+ // std::function<T> is re-instantiated with different template
+ // parameters each time.
+ const UninterestingCallCleanupHandler report_uninteresting_call = {
+ reaction, ss
+ };
return PerformActionAndPrintResult(nullptr, std::move(args), ss.str(), ss);
}
@@ -1839,22 +1884,14 @@ R FunctionMocker<R(Args...)>::InvokeWith(ArgumentTuple&& args)
//
// We use RAII to do the latter in case R is void or a non-moveable type. In
// either case we can't assign it to a local variable.
- const Cleanup handle_failures([&] {
- ss << "\n" << why.str();
-
- if (!found) {
- // No expectation matches this call - reports a failure.
- Expect(false, nullptr, -1, ss.str());
- } else if (is_excessive) {
- // We had an upper-bound violation and the failure message is in ss.
- Expect(false, untyped_expectation->file(), untyped_expectation->line(),
- ss.str());
- } else {
- // We had an expected call and the matching expectation is
- // described in ss.
- Log(kInfo, loc.str() + ss.str(), 2);
- }
- });
+ //
+ // Note that we *don't* use any local callback types (like lambdas) here.
+ // Doing so slows down compilation dramatically because the *constructor* of
+ // std::function<T> is re-instantiated with different template
+ // parameters each time.
+ const FailureCleanupHandler handle_failures = {
+ ss, why, loc, untyped_expectation, found, is_excessive
+ };
return PerformActionAndPrintResult(untyped_action, std::move(args), ss.str(),
ss);
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index b5283ed..ead6d7c 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -224,7 +224,7 @@ class FailureReporterInterface {
// The type of a failure (either non-fatal or fatal).
enum FailureType { kNonfatal, kFatal };
- virtual ~FailureReporterInterface() {}
+ virtual ~FailureReporterInterface() = default;
// Reports a failure that occurred at the given source file location.
virtual void ReportFailure(FailureType type, const char* file, int line,
@@ -465,8 +465,10 @@ struct Function<R(Args...)> {
using MakeResultIgnoredValue = IgnoredValue(Args...);
};
+#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
template <typename R, typename... Args>
constexpr size_t Function<R(Args...)>::ArgumentCount;
+#endif
// Workaround for MSVC error C2039: 'type': is not a member of 'std'
// when std::tuple_element is used.
diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc
index 774cce3..5c2ce0d 100644
--- a/googlemock/src/gmock-internal-utils.cc
+++ b/googlemock/src/gmock-internal-utils.cc
@@ -41,6 +41,7 @@
#include <cctype>
#include <cstdint>
#include <cstring>
+#include <iostream>
#include <ostream> // NOLINT
#include <string>
#include <vector>
diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index 5a98faf..de89471 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -40,6 +40,7 @@
#include <map>
#include <memory>
#include <set>
+#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
@@ -95,7 +96,7 @@ ExpectationBase::ExpectationBase(const char* a_file, int a_line,
action_count_checked_(false) {}
// Destructs an ExpectationBase object.
-ExpectationBase::~ExpectationBase() {}
+ExpectationBase::~ExpectationBase() = default;
// Explicitly specifies the cardinality of this expectation. Used by
// the subclasses to implement the .Times() clause.
@@ -308,7 +309,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) {
UntypedFunctionMockerBase::UntypedFunctionMockerBase()
: mock_obj_(nullptr), name_("") {}
-UntypedFunctionMockerBase::~UntypedFunctionMockerBase() {}
+UntypedFunctionMockerBase::~UntypedFunctionMockerBase() = default;
// Sets the mock object this mock method belongs to, and registers
// this information in the global mock registry. Will be called
@@ -745,13 +746,13 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj)
// needed by VerifyAndClearExpectationsLocked().
}
-Expectation::Expectation() {}
+Expectation::Expectation() = default;
Expectation::Expectation(
const std::shared_ptr<internal::ExpectationBase>& an_expectation_base)
: expectation_base_(an_expectation_base) {}
-Expectation::~Expectation() {}
+Expectation::~Expectation() = default;
// Adds an expectation to a sequence.
void Sequence::AddExpectation(const Expectation& expectation) const {
diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc
index 5025656..b5e714d 100644
--- a/googlemock/src/gmock.cc
+++ b/googlemock/src/gmock.cc
@@ -29,6 +29,8 @@
#include "gmock/gmock.h"
+#include <string>
+
#include "gmock/internal/gmock-port.h"
GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index 7734830..da1675c 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -37,14 +37,18 @@
#include <functional>
#include <iterator>
#include <memory>
+#include <sstream>
#include <string>
+#include <tuple>
#include <type_traits>
+#include <utility>
#include <vector>
#include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
+#include "gtest/internal/gtest-port.h"
// Silence C4100 (unreferenced formal parameter) and C4503 (decorated name
// length exceeded) for MSVC.
@@ -218,7 +222,8 @@ TEST(TypeTraits, IsInvocableRV) {
// In C++17 and above, where it's guaranteed that functions can return
// non-moveable objects, everything should work fine for non-moveable rsult
// types too.
-#if defined(__cplusplus) && __cplusplus >= 201703L
+#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
+ GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
{
struct NonMoveable {
NonMoveable() = default;
@@ -444,7 +449,7 @@ TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) {
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Get() == nullptr);
DefaultValue<std::unique_ptr<int>>::SetFactory(
- [] { return std::unique_ptr<int>(new int(42)); });
+ [] { return std::make_unique<int>(42); });
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
std::unique_ptr<int> i = DefaultValue<std::unique_ptr<int>>::Get();
EXPECT_EQ(42, *i);
@@ -982,7 +987,7 @@ TEST(ReturnRoundRobinTest, WorksForVector) {
class MockClass {
public:
- MockClass() {}
+ MockClass() = default;
MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT
MOCK_METHOD0(Foo, MyNonDefaultConstructible());
@@ -1751,9 +1756,7 @@ TEST(ReturnNewTest, ConstructorThatTakes10Arguments) {
delete c;
}
-std::unique_ptr<int> UniquePtrSource() {
- return std::unique_ptr<int>(new int(19));
-}
+std::unique_ptr<int> UniquePtrSource() { return std::make_unique<int>(19); }
std::vector<std::unique_ptr<int>> VectorUniquePtrSource() {
std::vector<std::unique_ptr<int>> out;
@@ -1802,7 +1805,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
// Check default value
DefaultValue<std::unique_ptr<int>>::SetFactory(
- [] { return std::unique_ptr<int>(new int(42)); });
+ [] { return std::make_unique<int>(42); });
EXPECT_EQ(42, *mock.MakeUnique());
EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource));
@@ -1822,7 +1825,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
TEST(MockMethodTest, CanTakeMoveOnlyValue) {
MockClass mock;
- auto make = [](int i) { return std::unique_ptr<int>(new int(i)); };
+ auto make = [](int i) { return std::make_unique<int>(i); };
EXPECT_CALL(mock, TakeUnique(_)).WillRepeatedly([](std::unique_ptr<int> i) {
return *i;
@@ -2053,9 +2056,7 @@ struct Double {
}
};
-std::unique_ptr<int> UniqueInt(int i) {
- return std::unique_ptr<int>(new int(i));
-}
+std::unique_ptr<int> UniqueInt(int i) { return std::make_unique<int>(i); }
TEST(FunctorActionTest, ActionFromFunction) {
Action<int(int, int&, int*)> a = &Add;
diff --git a/googlemock/test/gmock-cardinalities_test.cc b/googlemock/test/gmock-cardinalities_test.cc
index cdd9956..ad49752 100644
--- a/googlemock/test/gmock-cardinalities_test.cc
+++ b/googlemock/test/gmock-cardinalities_test.cc
@@ -31,6 +31,8 @@
//
// This file tests the built-in cardinalities.
+#include <ostream>
+
#include "gmock/gmock.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
@@ -50,7 +52,7 @@ using testing::MakeCardinality;
class MockFoo {
public:
- MockFoo() {}
+ MockFoo() = default;
MOCK_METHOD0(Bar, int()); // NOLINT
private:
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc
index 4db498d..f7b31ae 100644
--- a/googlemock/test/gmock-function-mocker_test.cc
+++ b/googlemock/test/gmock-function-mocker_test.cc
@@ -70,7 +70,7 @@ using testing::TypedEq;
template <typename T>
class TemplatedCopyable {
public:
- TemplatedCopyable() {}
+ TemplatedCopyable() = default;
template <typename U>
TemplatedCopyable(const U& other) {} // NOLINT
@@ -78,7 +78,7 @@ class TemplatedCopyable {
class FooInterface {
public:
- virtual ~FooInterface() {}
+ virtual ~FooInterface() = default;
virtual void VoidReturning(int x) = 0;
@@ -137,7 +137,7 @@ class FooInterface {
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4373)
class MockFoo : public FooInterface {
public:
- MockFoo() {}
+ MockFoo() = default;
// Makes sure that a mock function parameter can be named.
MOCK_METHOD(void, VoidReturning, (int n)); // NOLINT
@@ -208,7 +208,7 @@ class MockFoo : public FooInterface {
class LegacyMockFoo : public FooInterface {
public:
- LegacyMockFoo() {}
+ LegacyMockFoo() = default;
// Makes sure that a mock function parameter can be named.
MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT
@@ -487,7 +487,7 @@ TEST(FunctionMockerTest, RefQualified) {
class MockB {
public:
- MockB() {}
+ MockB() = default;
MOCK_METHOD(void, DoB, ());
@@ -498,7 +498,7 @@ class MockB {
class LegacyMockB {
public:
- LegacyMockB() {}
+ LegacyMockB() = default;
MOCK_METHOD0(DoB, void());
@@ -534,7 +534,7 @@ TYPED_TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
template <typename T>
class StackInterface {
public:
- virtual ~StackInterface() {}
+ virtual ~StackInterface() = default;
// Template parameter appears in function parameter.
virtual void Push(const T& value) = 0;
@@ -547,7 +547,7 @@ class StackInterface {
template <typename T>
class MockStack : public StackInterface<T> {
public:
- MockStack() {}
+ MockStack() = default;
MOCK_METHOD(void, Push, (const T& elem), ());
MOCK_METHOD(void, Pop, (), (final));
@@ -566,7 +566,7 @@ class MockStack : public StackInterface<T> {
template <typename T>
class LegacyMockStack : public StackInterface<T> {
public:
- LegacyMockStack() {}
+ LegacyMockStack() = default;
MOCK_METHOD1_T(Push, void(const T& elem));
MOCK_METHOD0_T(Pop, void());
@@ -711,7 +711,7 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {
class MockOverloadedOnArgNumber {
public:
- MockOverloadedOnArgNumber() {}
+ MockOverloadedOnArgNumber() = default;
MY_MOCK_METHODS1_;
@@ -723,7 +723,7 @@ class MockOverloadedOnArgNumber {
class LegacyMockOverloadedOnArgNumber {
public:
- LegacyMockOverloadedOnArgNumber() {}
+ LegacyMockOverloadedOnArgNumber() = default;
LEGACY_MY_MOCK_METHODS1_;
@@ -758,7 +758,7 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
class MockOverloadedOnConstness {
public:
- MockOverloadedOnConstness() {}
+ MockOverloadedOnConstness() = default;
MY_MOCK_METHODS2_;
diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc
index 360d02a..6c769a8 100644
--- a/googlemock/test/gmock-internal-utils_test.cc
+++ b/googlemock/test/gmock-internal-utils_test.cc
@@ -40,6 +40,7 @@
#include <memory>
#include <sstream>
#include <string>
+#include <tuple>
#include <vector>
#include "gmock/gmock.h"
diff --git a/googlemock/test/gmock-matchers-arithmetic_test.cc b/googlemock/test/gmock-matchers-arithmetic_test.cc
index 2c5f4d0..f176962 100644
--- a/googlemock/test/gmock-matchers-arithmetic_test.cc
+++ b/googlemock/test/gmock-matchers-arithmetic_test.cc
@@ -31,7 +31,10 @@
//
// This file tests some commonly used argument matchers.
+#include <cmath>
#include <limits>
+#include <memory>
+#include <string>
#include "test/gmock-matchers_test.h"
@@ -952,7 +955,7 @@ TEST(AllArgsTest, WorksForNonTuple) {
class AllArgsHelper {
public:
- AllArgsHelper() {}
+ AllArgsHelper() = default;
MOCK_METHOD2(Helper, int(char x, int y));
@@ -973,7 +976,7 @@ TEST(AllArgsTest, WorksInWithClause) {
class OptionalMatchersHelper {
public:
- OptionalMatchersHelper() {}
+ OptionalMatchersHelper() = default;
MOCK_METHOD0(NoArgs, int());
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc
index 0738aaf..b2ce99e 100644
--- a/googlemock/test/gmock-matchers-comparisons_test.cc
+++ b/googlemock/test/gmock-matchers-comparisons_test.cc
@@ -31,6 +31,10 @@
//
// This file tests some commonly used argument matchers.
+#include <functional>
+#include <memory>
+#include <string>
+#include <tuple>
#include <vector>
#include "test/gmock-matchers_test.h"
@@ -585,8 +589,8 @@ TEST(MatcherCastTest, ValueIsNotCopied) {
class Base {
public:
- virtual ~Base() {}
- Base() {}
+ virtual ~Base() = default;
+ Base() = default;
private:
Base(const Base&) = delete;
@@ -1542,7 +1546,7 @@ TEST(PairTest, MatchesCorrectly) {
TEST(PairTest, WorksWithMoveOnly) {
pair<std::unique_ptr<int>, std::unique_ptr<int>> p;
- p.second.reset(new int(7));
+ p.second = std::make_unique<int>(7);
EXPECT_THAT(p, Pair(Eq(nullptr), Ne(nullptr)));
}
diff --git a/googlemock/test/gmock-matchers-containers_test.cc b/googlemock/test/gmock-matchers-containers_test.cc
index b40a26a..38fd9a5 100644
--- a/googlemock/test/gmock-matchers-containers_test.cc
+++ b/googlemock/test/gmock-matchers-containers_test.cc
@@ -31,6 +31,18 @@
//
// This file tests some commonly used argument matchers.
+#include <algorithm>
+#include <array>
+#include <deque>
+#include <forward_list>
+#include <iterator>
+#include <list>
+#include <memory>
+#include <ostream>
+#include <string>
+#include <tuple>
+#include <vector>
+
#include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short',
@@ -1824,8 +1836,8 @@ TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) {
}
TEST(UnorderedElementsAreArrayTest, VectorBool) {
- const bool a[] = {0, 1, 0, 1, 1};
- const bool b[] = {1, 0, 1, 1, 0};
+ const bool a[] = {false, true, false, true, true};
+ const bool b[] = {true, false, true, true, false};
std::vector<bool> expected(std::begin(a), std::end(a));
std::vector<bool> actual(std::begin(b), std::end(b));
StringMatchResultListener listener;
@@ -2776,7 +2788,7 @@ TEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) {
class NativeArrayPassedAsPointerAndSize {
public:
- NativeArrayPassedAsPointerAndSize() {}
+ NativeArrayPassedAsPointerAndSize() = default;
MOCK_METHOD(void, Helper, (int* array, int size));
diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc
index 0c7aa49..b8f6458 100644
--- a/googlemock/test/gmock-matchers-misc_test.cc
+++ b/googlemock/test/gmock-matchers-misc_test.cc
@@ -31,6 +31,14 @@
//
// This file tests some commonly used argument matchers.
+#include <array>
+#include <memory>
+#include <ostream>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
+
#include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short',
diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index 866e1ab..9980f3b 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -33,10 +33,14 @@
#include "gmock/gmock-more-actions.h"
+#include <algorithm>
#include <functional>
+#include <iterator>
#include <memory>
#include <sstream>
#include <string>
+#include <tuple>
+#include <vector>
#include "gmock/gmock.h"
#include "gtest/gtest-spi.h"
@@ -673,7 +677,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithIteratorArgument) {
Action<MyFunction> a = SetArrayArgument<1>(letters.begin(), letters.end());
std::string s;
- a.Perform(std::make_tuple(true, back_inserter(s)));
+ a.Perform(std::make_tuple(true, std::back_inserter(s)));
EXPECT_EQ(letters, s);
}
diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc
index 08254e1..95f0969 100644
--- a/googlemock/test/gmock-nice-strict_test.cc
+++ b/googlemock/test/gmock-nice-strict_test.cc
@@ -40,7 +40,7 @@
// clash with ::testing::Mock.
class Mock {
public:
- Mock() {}
+ Mock() = default;
MOCK_METHOD0(DoThis, void());
@@ -78,7 +78,7 @@ class CallsMockMethodInDestructor {
class Foo {
public:
- virtual ~Foo() {}
+ virtual ~Foo() = default;
virtual void DoThis() = 0;
virtual int DoThat(bool flag) = 0;
@@ -86,7 +86,7 @@ class Foo {
class MockFoo : public Foo {
public:
- MockFoo() {}
+ MockFoo() = default;
void Delete() { delete this; }
MOCK_METHOD0(DoThis, void());
@@ -109,7 +109,7 @@ class MockBar {
(a10 ? 'T' : 'F');
}
- virtual ~MockBar() {}
+ virtual ~MockBar() = default;
const std::string& str() const { return str_; }
diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc
index d53196b..221de2d 100644
--- a/googlemock/test/gmock-spec-builders_test.cc
+++ b/googlemock/test/gmock-spec-builders_test.cc
@@ -98,7 +98,7 @@ class NonDefaultConstructible {
class MockA {
public:
- MockA() {}
+ MockA() = default;
MOCK_METHOD1(DoA, void(int n));
MOCK_METHOD1(ReturnResult, Result(int n));
@@ -113,7 +113,7 @@ class MockA {
class MockB {
public:
- MockB() {}
+ MockB() = default;
MOCK_CONST_METHOD0(DoB, int()); // NOLINT
MOCK_METHOD1(DoB, int(int n)); // NOLINT
@@ -125,7 +125,7 @@ class MockB {
class ReferenceHoldingMock {
public:
- ReferenceHoldingMock() {}
+ ReferenceHoldingMock() = default;
MOCK_METHOD1(AcceptReference, void(std::shared_ptr<MockA>*));
@@ -143,12 +143,12 @@ class ReferenceHoldingMock {
class CC {
public:
- virtual ~CC() {}
+ virtual ~CC() = default;
virtual int Method() = 0;
};
class MockCC : public CC {
public:
- MockCC() {}
+ MockCC() = default;
MOCK_METHOD0(Method, int());
@@ -804,39 +804,40 @@ TEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) {
"to be called at least once");
}
-#if defined(__cplusplus) && __cplusplus >= 201703L
+#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
+ GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
// It should be possible to return a non-moveable type from a mock action in
// C++17 and above, where it's guaranteed that such a type can be initialized
// from a prvalue returned from a function.
TEST(ExpectCallTest, NonMoveableType) {
// Define a non-moveable result type.
- struct Result {
- explicit Result(int x_in) : x(x_in) {}
- Result(Result&&) = delete;
+ struct NonMoveableStruct {
+ explicit NonMoveableStruct(int x_in) : x(x_in) {}
+ NonMoveableStruct(NonMoveableStruct&&) = delete;
int x;
};
- static_assert(!std::is_move_constructible_v<Result>);
- static_assert(!std::is_copy_constructible_v<Result>);
+ static_assert(!std::is_move_constructible_v<NonMoveableStruct>);
+ static_assert(!std::is_copy_constructible_v<NonMoveableStruct>);
- static_assert(!std::is_move_assignable_v<Result>);
- static_assert(!std::is_copy_assignable_v<Result>);
+ static_assert(!std::is_move_assignable_v<NonMoveableStruct>);
+ static_assert(!std::is_copy_assignable_v<NonMoveableStruct>);
// We should be able to use a callable that returns that result as both a
// OnceAction and an Action, whether the callable ignores arguments or not.
- const auto return_17 = [] { return Result(17); };
+ const auto return_17 = [] { return NonMoveableStruct(17); };
- static_cast<void>(OnceAction<Result()>{return_17});
- static_cast<void>(Action<Result()>{return_17});
+ static_cast<void>(OnceAction<NonMoveableStruct()>{return_17});
+ static_cast<void>(Action<NonMoveableStruct()>{return_17});
- static_cast<void>(OnceAction<Result(int)>{return_17});
- static_cast<void>(Action<Result(int)>{return_17});
+ static_cast<void>(OnceAction<NonMoveableStruct(int)>{return_17});
+ static_cast<void>(Action<NonMoveableStruct(int)>{return_17});
// It should be possible to return the result end to end through an
// EXPECT_CALL statement, with both WillOnce and WillRepeatedly.
- MockFunction<Result()> mock;
+ MockFunction<NonMoveableStruct()> mock;
EXPECT_CALL(mock, Call) //
.WillOnce(return_17) //
.WillRepeatedly(return_17);
@@ -1881,7 +1882,7 @@ struct Unprintable {
class MockC {
public:
- MockC() {}
+ MockC() = default;
MOCK_METHOD6(VoidMethod, void(bool cond, int n, std::string s, void* p,
const Printable& x, Unprintable y));
@@ -2121,7 +2122,7 @@ void PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) {
class LogTestHelper {
public:
- LogTestHelper() {}
+ LogTestHelper() = default;
MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));
diff --git a/googlemock/test/gmock_ex_test.cc b/googlemock/test/gmock_ex_test.cc
index 44e5e35..e174122 100644
--- a/googlemock/test/gmock_ex_test.cc
+++ b/googlemock/test/gmock_ex_test.cc
@@ -29,6 +29,8 @@
// Tests Google Mock's functionality that depends on exceptions.
+#include <exception>
+
#include "gmock/gmock.h"
#include "gtest/gtest.h"
diff --git a/googlemock/test/gmock_leak_test_.cc b/googlemock/test/gmock_leak_test_.cc
index fa64591..a6bb339 100644
--- a/googlemock/test/gmock_leak_test_.cc
+++ b/googlemock/test/gmock_leak_test_.cc
@@ -40,13 +40,13 @@ using ::testing::Return;
class FooInterface {
public:
- virtual ~FooInterface() {}
+ virtual ~FooInterface() = default;
virtual void DoThis() = 0;
};
class MockFoo : public FooInterface {
public:
- MockFoo() {}
+ MockFoo() = default;
MOCK_METHOD0(DoThis, void());
diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h
index 8d2abb1..db11c2d 100644
--- a/googlemock/test/gmock_link_test.h
+++ b/googlemock/test/gmock_link_test.h
@@ -194,7 +194,7 @@ using testing::MatchesRegex;
class Interface {
public:
- virtual ~Interface() {}
+ virtual ~Interface() = default;
virtual void VoidFromString(char* str) = 0;
virtual char* StringFromString(char* str) = 0;
virtual int IntFromString(char* str) = 0;
@@ -208,7 +208,7 @@ class Interface {
class Mock : public Interface {
public:
- Mock() {}
+ Mock() = default;
MOCK_METHOD1(VoidFromString, void(char* str));
MOCK_METHOD1(StringFromString, char*(char* str));
diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc
index ca5a646..03d8421 100644
--- a/googlemock/test/gmock_output_test_.cc
+++ b/googlemock/test/gmock_output_test_.cc
@@ -33,7 +33,6 @@
#include <stdio.h>
#include <string>
-#include <tuple>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -53,7 +52,7 @@ using testing::Value;
class MockFoo {
public:
- MockFoo() {}
+ MockFoo() = default;
MOCK_METHOD3(Bar, char(const std::string& s, int i, double x));
MOCK_METHOD2(Bar2, bool(int x, int y));
@@ -255,16 +254,12 @@ TEST_F(GMockOutputTest, CatchesLeakedMocks) {
}
MATCHER_P2(IsPair, first, second, "") {
- return Value(std::get<0>(arg), first) && Value(std::get<1>(arg), second);
+ return Value(arg.first, first) && Value(arg.second, second);
}
TEST_F(GMockOutputTest, PrintsMatcher) {
const testing::Matcher<int> m1 = Ge(48);
- // Explicitly using std::tuple instead of std::pair due to differences between
- // MSVC and other compilers. std::pair is printed as
- // "struct std::pair<int,bool>" when using MSVC vs "std::pair<int,bool>" with
- // other compilers.
- EXPECT_THAT((std::tuple<int, bool>(42, true)), IsPair(m1, true));
+ EXPECT_THAT((std::pair<int, bool>(42, true)), IsPair(m1, true));
}
void TestCatchesLeakedMocksInAdHocTests() {
diff --git a/googlemock/test/gmock_output_test_golden.txt b/googlemock/test/gmock_output_test_golden.txt
index d6c0333..ca88af0 100644
--- a/googlemock/test/gmock_output_test_golden.txt
+++ b/googlemock/test/gmock_output_test_golden.txt
@@ -40,6 +40,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(0, _))...
Actual: 1
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.UnexpectedCall
[ RUN ] GMockOutputTest.UnexpectedCallToVoidFunction
unknown file: Failure
@@ -53,6 +54,7 @@ FILE:#: EXPECT_CALL(foo_, Bar3(0, _))...
Actual: 1
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction
[ RUN ] GMockOutputTest.ExcessiveCall
FILE:#: Failure
@@ -61,6 +63,7 @@ Mock function called more times than expected - returning default value.
Returns: false
Expected: to be called once
Actual: called twice - over-saturated and active
+
[ FAILED ] GMockOutputTest.ExcessiveCall
[ RUN ] GMockOutputTest.ExcessiveCallToVoidFunction
FILE:#: Failure
@@ -68,6 +71,7 @@ Mock function called more times than expected - returning directly.
Function call: Bar3(0, 1)
Expected: to be called once
Actual: called twice - over-saturated and active
+
[ FAILED ] GMockOutputTest.ExcessiveCallToVoidFunction
[ RUN ] GMockOutputTest.UninterestingCall
@@ -104,6 +108,7 @@ FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))...
Actual: 1
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.RetiredExpectation
[ RUN ] GMockOutputTest.UnsatisfiedPrerequisite
unknown file: Failure
@@ -125,6 +130,7 @@ FILE:#: pre-requisite #0
(end of pre-requisites)
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite
[ RUN ] GMockOutputTest.UnsatisfiedPrerequisites
unknown file: Failure
@@ -147,6 +153,7 @@ FILE:#: pre-requisite #1
(end of pre-requisites)
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
[ RUN ] GMockOutputTest.UnsatisfiedWith
FILE:#: Failure
@@ -154,16 +161,19 @@ Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))...
Expected args: are a pair where the first >= the second
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.UnsatisfiedWith
[ RUN ] GMockOutputTest.UnsatisfiedExpectation
FILE:#: Failure
Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))...
Expected: to be called twice
Actual: called once - unsatisfied and active
+
FILE:#: Failure
Actual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))...
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
[ RUN ] GMockOutputTest.MismatchArguments
unknown file: Failure
@@ -180,6 +190,7 @@ FILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))...
Actual: -0.1
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.MismatchArguments
[ RUN ] GMockOutputTest.MismatchWith
unknown file: Failure
@@ -194,6 +205,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
Actual: don't match
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.MismatchWith
[ RUN ] GMockOutputTest.MismatchArgumentsAndWith
unknown file: Failure
@@ -210,6 +222,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
Actual: don't match
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.MismatchArgumentsAndWith
[ RUN ] GMockOutputTest.UnexpectedCallWithDefaultAction
unknown file: Failure
@@ -227,6 +240,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
Actual: 0
Expected: to be called once
Actual: never called - unsatisfied and active
+
unknown file: Failure
Unexpected mock function call - taking default action specified at:
@@ -242,6 +256,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
Actual: 0
Expected: to be called once
Actual: never called - unsatisfied and active
+
[ FAILED ] GMockOutputTest.UnexpectedCallWithDefaultAction
[ RUN ] GMockOutputTest.ExcessiveCallWithDefaultAction
FILE:#: Failure
@@ -251,6 +266,7 @@ FILE:#:
Returns: true
Expected: to be called once
Actual: called twice - over-saturated and active
+
FILE:#: Failure
Mock function called more times than expected - taking default action specified at:
FILE:#:
@@ -258,6 +274,7 @@ FILE:#:
Returns: false
Expected: to be called once
Actual: called twice - over-saturated and active
+
[ FAILED ] GMockOutputTest.ExcessiveCallWithDefaultAction
[ RUN ] GMockOutputTest.UninterestingCallWithDefaultAction
@@ -290,9 +307,10 @@ Stack trace:
[ OK ] GMockOutputTest.CatchesLeakedMocks
[ RUN ] GMockOutputTest.PrintsMatcher
FILE:#: Failure
-Value of: (std::tuple<int, bool>(42, true))
+Value of: (std::pair<int, bool>(42, true))
Expected: is pair (first: is >= 48, second: true)
- Actual: (42, true)
+ Actual: (42, true) (of type std::pair<int,bool>)
+
[ FAILED ] GMockOutputTest.PrintsMatcher
[ FAILED ] GMockOutputTest.UnexpectedCall
[ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction
diff --git a/googlemock/test/gmock_test.cc b/googlemock/test/gmock_test.cc
index 8f1bd5d..8cfff30 100644
--- a/googlemock/test/gmock_test.cc
+++ b/googlemock/test/gmock_test.cc
@@ -174,6 +174,6 @@ TEST(WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) {
// Makes sure Google Mock flags can be accessed in code.
TEST(FlagTest, IsAccessibleInCode) {
bool dummy =
- GMOCK_FLAG_GET(catch_leaked_mocks) && GMOCK_FLAG_GET(verbose) == "";
+ GMOCK_FLAG_GET(catch_leaked_mocks) && GMOCK_FLAG_GET(verbose).empty();
(void)dummy; // Avoids the "unused local variable" warning.
}
diff --git a/googletest/README.md b/googletest/README.md
index 995834e..4cad12f 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -126,10 +126,10 @@ match the project in which it is included.
An environment that supports C++11 is required in order to successfully build
GoogleTest. One way to ensure this is to specify the standard in the top-level
-project, for example by using the `set(CMAKE_CXX_STANDARD 11)` command. If this
-is not feasible, for example in a C project using GoogleTest for validation,
-then it can be specified by adding it to the options for cmake via the
-`DCMAKE_CXX_FLAGS` option.
+project, for example by using the `set(CMAKE_CXX_STANDARD 11)` command along
+with `set(CMAKE_CXX_STANDARD_REQUIRED ON). If this is not feasible, for example
+in a C project using GoogleTest for validation, then it can be specified by
+adding it to the options for cmake via the`-DCMAKE_CXX_FLAGS` option.
### Tweaking GoogleTest
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index edf637e..6573d30 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -16,6 +16,10 @@ if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif (POLICY CMP0054)
+if (POLICY CMP0069)
+ cmake_policy(SET CMP0069 NEW)
+endif (POLICY CMP0069)
+
# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
#
# This must be a macro(), as inside a function string() can only
@@ -90,12 +94,22 @@ macro(config_compiler_and_linker)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(cxx_base_flags "${cxx_base_flags} -utf-8")
endif()
- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
+ set(cxx_base_flags "${cxx_base_flags} /fp:precise -Wno-inconsistent-missing-override -Wno-microsoft-exception-spec -Wno-unused-function -Wno-unused-but-set-variable")
+ endif()
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
+ CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef")
set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions")
- set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls")
+ set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Winline -Wredundant-decls")
set(cxx_no_rtti_flags "-fno-rtti")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ set(cxx_strict_flags "${cxx_strict_flags} -Wchar-subscripts")
+ endif()
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
+ set(cxx_base_flags "${cxx_base_flags} -Wno-implicit-float-size-conversion -ffp-model=precise")
+ endif()
elseif (CMAKE_COMPILER_IS_GNUCXX)
set(cxx_base_flags "-Wall -Wshadow -Wundef")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
diff --git a/googletest/include/gtest/gtest-assertion-result.h b/googletest/include/gtest/gtest-assertion-result.h
index addbb59..56fe128 100644
--- a/googletest/include/gtest/gtest-assertion-result.h
+++ b/googletest/include/gtest/gtest-assertion-result.h
@@ -181,7 +181,7 @@ class GTEST_API_ AssertionResult {
// assertion's expectation). When nothing has been streamed into the
// object, returns an empty string.
const char* message() const {
- return message_.get() != nullptr ? message_->c_str() : "";
+ return message_ != nullptr ? message_->c_str() : "";
}
// Deprecated; please use message() instead.
const char* failure_message() const { return message(); }
@@ -204,7 +204,7 @@ class GTEST_API_ AssertionResult {
private:
// Appends the contents of message to message_.
void AppendMessage(const Message& a_message) {
- if (message_.get() == nullptr) message_.reset(new ::std::string);
+ if (message_ == nullptr) message_ = ::std::make_unique<::std::string>();
message_->append(a_message.GetString().c_str());
}
diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h
index d73d834..eae210e 100644
--- a/googletest/include/gtest/gtest-matchers.h
+++ b/googletest/include/gtest/gtest-matchers.h
@@ -107,13 +107,13 @@ class MatchResultListener {
MatchResultListener& operator=(const MatchResultListener&) = delete;
};
-inline MatchResultListener::~MatchResultListener() {}
+inline MatchResultListener::~MatchResultListener() = default;
// An instance of a subclass of this knows how to describe itself as a
// matcher.
class GTEST_API_ MatcherDescriberInterface {
public:
- virtual ~MatcherDescriberInterface() {}
+ virtual ~MatcherDescriberInterface() = default;
// Describes this matcher to an ostream. The function should print
// a verb phrase that describes the property a value matching this
@@ -494,7 +494,7 @@ template <>
class GTEST_API_ Matcher<const std::string&>
: public internal::MatcherBase<const std::string&> {
public:
- Matcher() {}
+ Matcher() = default;
explicit Matcher(const MatcherInterface<const std::string&>* impl)
: internal::MatcherBase<const std::string&>(impl) {}
@@ -516,7 +516,7 @@ template <>
class GTEST_API_ Matcher<std::string>
: public internal::MatcherBase<std::string> {
public:
- Matcher() {}
+ Matcher() = default;
explicit Matcher(const MatcherInterface<const std::string&>* impl)
: internal::MatcherBase<std::string>(impl) {}
@@ -544,7 +544,7 @@ template <>
class GTEST_API_ Matcher<const internal::StringView&>
: public internal::MatcherBase<const internal::StringView&> {
public:
- Matcher() {}
+ Matcher() = default;
explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)
: internal::MatcherBase<const internal::StringView&>(impl) {}
@@ -570,7 +570,7 @@ template <>
class GTEST_API_ Matcher<internal::StringView>
: public internal::MatcherBase<internal::StringView> {
public:
- Matcher() {}
+ Matcher() = default;
explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)
: internal::MatcherBase<internal::StringView>(impl) {}
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index b2d7b0a..539d99c 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -206,12 +206,13 @@ struct StreamPrinter {
// Don't accept member pointers here. We'd print them via implicit
// conversion to bool, which isn't useful.
typename = typename std::enable_if<
- !std::is_member_pointer<T>::value>::type,
- // Only accept types for which we can find a streaming operator via
- // ADL (possibly involving implicit conversions).
- typename = decltype(std::declval<std::ostream&>()
- << std::declval<const T&>())>
- static void PrintValue(const T& value, ::std::ostream* os) {
+ !std::is_member_pointer<T>::value>::type>
+ // Only accept types for which we can find a streaming operator via
+ // ADL (possibly involving implicit conversions).
+ // (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name
+ // lookup properly when we do it in the template parameter list.)
+ static auto PrintValue(const T& value, ::std::ostream* os)
+ -> decltype((void)(*os << value)) {
// Call streaming operator found by ADL, possibly with implicit conversions
// of the arguments.
*os << value;
@@ -1003,7 +1004,7 @@ template <>
class UniversalTersePrinter<char*> : public UniversalTersePrinter<const char*> {
};
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
template <>
class UniversalTersePrinter<const char8_t*> {
public:
diff --git a/googletest/include/gtest/gtest-test-part.h b/googletest/include/gtest/gtest-test-part.h
index 8290b4d..41c8a9a 100644
--- a/googletest/include/gtest/gtest-test-part.h
+++ b/googletest/include/gtest/gtest-test-part.h
@@ -133,7 +133,7 @@ std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
// virtual.
class GTEST_API_ TestPartResultArray {
public:
- TestPartResultArray() {}
+ TestPartResultArray() = default;
// Appends the given TestPartResult to the array.
void Append(const TestPartResult& result);
@@ -154,7 +154,7 @@ class GTEST_API_ TestPartResultArray {
// This interface knows how to report a test part result.
class GTEST_API_ TestPartResultReporterInterface {
public:
- virtual ~TestPartResultReporterInterface() {}
+ virtual ~TestPartResultReporterInterface() = default;
virtual void ReportTestPartResult(const TestPartResult& result) = 0;
};
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 04a84f3..8412503 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -551,14 +551,14 @@ class GTEST_API_ TestInfo {
// Returns the name of the parameter type, or NULL if this is not a typed
// or a type-parameterized test.
const char* type_param() const {
- if (type_param_.get() != nullptr) return type_param_->c_str();
+ if (type_param_ != nullptr) return type_param_->c_str();
return nullptr;
}
// Returns the text representation of the value parameter, or NULL if this
// is not a value-parameterized test.
const char* value_param() const {
- if (value_param_.get() != nullptr) return value_param_->c_str();
+ if (value_param_ != nullptr) return value_param_->c_str();
return nullptr;
}
@@ -697,7 +697,7 @@ class GTEST_API_ TestSuite {
// Returns the name of the parameter type, or NULL if this is not a
// type-parameterized test suite.
const char* type_param() const {
- if (type_param_.get() != nullptr) return type_param_->c_str();
+ if (type_param_ != nullptr) return type_param_->c_str();
return nullptr;
}
@@ -894,7 +894,7 @@ class GTEST_API_ TestSuite {
class Environment {
public:
// The d'tor is virtual as we need to subclass Environment.
- virtual ~Environment() {}
+ virtual ~Environment() = default;
// Override this to define how to set up the environment.
virtual void SetUp() {}
@@ -925,7 +925,7 @@ class GTEST_API_ AssertionException
// the order the corresponding events are fired.
class TestEventListener {
public:
- virtual ~TestEventListener() {}
+ virtual ~TestEventListener() = default;
// Fired before any test activity starts.
virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
@@ -1671,7 +1671,7 @@ template <typename T>
class WithParamInterface {
public:
typedef T ParamType;
- virtual ~WithParamInterface() {}
+ virtual ~WithParamInterface() = default;
// The current parameter value. Is also available in the test fixture's
// constructor.
diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h
index 522eed8..8e9c988 100644
--- a/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -88,7 +88,7 @@ class GTEST_API_ DeathTest {
static bool Create(const char* statement, Matcher<const std::string&> matcher,
const char* file, int line, DeathTest** test);
DeathTest();
- virtual ~DeathTest() {}
+ virtual ~DeathTest() = default;
// A helper class that aborts a death test when it's deleted.
class ReturnSentinel {
@@ -153,7 +153,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
// Factory interface for death tests. May be mocked out for testing.
class DeathTestFactory {
public:
- virtual ~DeathTestFactory() {}
+ virtual ~DeathTestFactory() = default;
virtual bool Create(const char* statement,
Matcher<const std::string&> matcher, const char* file,
int line, DeathTest** test) = 0;
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index ae2ca95..317894e 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -435,7 +435,7 @@ GTEST_API_ TypeId GetTestTypeId();
// of a Test object.
class TestFactoryBase {
public:
- virtual ~TestFactoryBase() {}
+ virtual ~TestFactoryBase() = default;
// Creates a test instance to run. The instance is both created and destroyed
// within TestInfoImpl::Run()
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index 50435f5..6a81c37 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -97,7 +97,7 @@ class ParamGenerator;
template <typename T>
class ParamIteratorInterface {
public:
- virtual ~ParamIteratorInterface() {}
+ virtual ~ParamIteratorInterface() = default;
// A pointer to the base generator instance.
// Used only for the purposes of iterator comparison
// to make sure that two iterators belong to the same generator.
@@ -171,7 +171,7 @@ class ParamGeneratorInterface {
public:
typedef T ParamType;
- virtual ~ParamGeneratorInterface() {}
+ virtual ~ParamGeneratorInterface() = default;
// Generator interface definition
virtual ParamIteratorInterface<T>* Begin() const = 0;
@@ -215,7 +215,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
end_(end),
step_(step),
end_index_(CalculateEndIndex(begin, end, step)) {}
- ~RangeGenerator() override {}
+ ~RangeGenerator() override = default;
ParamIteratorInterface<T>* Begin() const override {
return new Iterator(this, begin_, 0, step_);
@@ -230,7 +230,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
IncrementT step)
: base_(base), value_(value), index_(index), step_(step) {}
- ~Iterator() override {}
+ ~Iterator() override = default;
const ParamGeneratorInterface<T>* BaseGenerator() const override {
return base_;
@@ -299,7 +299,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
template <typename ForwardIterator>
ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
: container_(begin, end) {}
- ~ValuesInIteratorRangeGenerator() override {}
+ ~ValuesInIteratorRangeGenerator() override = default;
ParamIteratorInterface<T>* Begin() const override {
return new Iterator(this, container_.begin());
@@ -316,7 +316,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
Iterator(const ParamGeneratorInterface<T>* base,
typename ContainerType::const_iterator iterator)
: base_(base), iterator_(iterator) {}
- ~Iterator() override {}
+ ~Iterator() override = default;
const ParamGeneratorInterface<T>* BaseGenerator() const override {
return base_;
@@ -420,7 +420,7 @@ class ParameterizedTestFactory : public TestFactoryBase {
template <class ParamType>
class TestMetaFactoryBase {
public:
- virtual ~TestMetaFactoryBase() {}
+ virtual ~TestMetaFactoryBase() = default;
virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
};
@@ -439,7 +439,7 @@ class TestMetaFactory
public:
using ParamType = typename TestSuite::ParamType;
- TestMetaFactory() {}
+ TestMetaFactory() = default;
TestFactoryBase* CreateTestFactory(ParamType parameter) override {
return new ParameterizedTestFactory<TestSuite>(parameter);
@@ -462,7 +462,7 @@ class TestMetaFactory
// and calls RegisterTests() on each of them when asked.
class ParameterizedTestSuiteInfoBase {
public:
- virtual ~ParameterizedTestSuiteInfoBase() {}
+ virtual ~ParameterizedTestSuiteInfoBase() = default;
// Base part of test suite name for display purposes.
virtual const std::string& GetTestSuiteName() const = 0;
@@ -691,7 +691,7 @@ using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;
// ParameterizedTestSuiteInfo descriptors.
class ParameterizedTestSuiteRegistry {
public:
- ParameterizedTestSuiteRegistry() {}
+ ParameterizedTestSuiteRegistry() = default;
~ParameterizedTestSuiteRegistry() {
for (auto& test_suite_info : test_suite_infos_) {
delete test_suite_info;
@@ -825,7 +825,7 @@ class CartesianProductGenerator
CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g)
: generators_(g) {}
- ~CartesianProductGenerator() override {}
+ ~CartesianProductGenerator() override = default;
ParamIteratorInterface<ParamType>* Begin() const override {
return new Iterator(this, generators_, false);
@@ -850,7 +850,7 @@ class CartesianProductGenerator
current_(is_end ? end_ : begin_) {
ComputeCurrentValue();
}
- ~IteratorImpl() override {}
+ ~IteratorImpl() override = default;
const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
return base_;
@@ -969,7 +969,7 @@ class ParamGeneratorConverter : public ParamGeneratorInterface<To> {
: base_(base), it_(it), end_(end) {
if (it_ != end_) value_ = std::make_shared<To>(static_cast<To>(*it_));
}
- ~Iterator() override {}
+ ~Iterator() override = default;
const ParamGeneratorInterface<To>* BaseGenerator() const override {
return base_;
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 0160fad..d71110c 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -693,7 +693,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_GNU_KFREEBSD) || \
defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
defined(GTEST_OS_NETBSD) || defined(GTEST_OS_OPENBSD) || \
- defined(GTEST_OS_GNU_HURD)
+ defined(GTEST_OS_GNU_HURD) || defined(GTEST_OS_MAC)
#define GTEST_CAN_STREAM_RESULTS_ 1
#else
#define GTEST_CAN_STREAM_RESULTS_ 0
@@ -861,7 +861,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// Ask the compiler not to perform tail call optimization inside
// the marked function.
#define GTEST_NO_TAIL_CALL_ __attribute__((disable_tail_calls))
-#elif __GNUC__
+#elif defined(__GNUC__) && !defined(__NVCOMPILER)
#define GTEST_NO_TAIL_CALL_ \
__attribute__((optimize("no-optimize-sibling-calls")))
#else
@@ -1328,7 +1328,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
// problem.
class ThreadWithParamBase {
public:
- virtual ~ThreadWithParamBase() {}
+ virtual ~ThreadWithParamBase() = default;
virtual void Run() = 0;
};
@@ -1790,7 +1790,7 @@ typedef GTestMutexLock MutexLock;
// ThreadLocalValueHolderBase.
class GTEST_API_ ThreadLocalValueHolderBase {
public:
- virtual ~ThreadLocalValueHolderBase() {}
+ virtual ~ThreadLocalValueHolderBase() = default;
};
// Called by pthread to delete thread-local data stored by
@@ -1862,8 +1862,8 @@ class GTEST_API_ ThreadLocal {
class ValueHolderFactory {
public:
- ValueHolderFactory() {}
- virtual ~ValueHolderFactory() {}
+ ValueHolderFactory() = default;
+ virtual ~ValueHolderFactory() = default;
virtual ValueHolder* MakeNewHolder() const = 0;
private:
@@ -1873,7 +1873,7 @@ class GTEST_API_ ThreadLocal {
class DefaultValueHolderFactory : public ValueHolderFactory {
public:
- DefaultValueHolderFactory() {}
+ DefaultValueHolderFactory() = default;
ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
private:
@@ -2169,8 +2169,8 @@ inline const char* StrError(int errnum) { return strerror(errnum); }
inline const char* GetEnv(const char* name) {
#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
- defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \
- defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT)
+ defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
+ defined(GTEST_OS_QURT)
// We are on an embedded platform, which has no environment variables.
static_cast<void>(name); // To prevent 'unused argument' warning.
return nullptr;
@@ -2398,7 +2398,7 @@ using Any = ::absl::any;
} // namespace testing
#else
#ifdef __has_include
-#if __has_include(<any>) && __cplusplus >= 201703L && \
+#if __has_include(<any>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
(!defined(_MSC_VER) || GTEST_HAS_RTTI)
// Otherwise for C++17 and higher use std::any for UniversalPrinter<>
// specializations.
@@ -2411,7 +2411,7 @@ using Any = ::std::any;
} // namespace testing
// The case where absl is configured NOT to alias std::any is not
// supported.
-#endif // __has_include(<any>) && __cplusplus >= 201703L
+#endif // __has_include(<any>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
#endif // __has_include
#endif // GTEST_HAS_ABSL
@@ -2433,7 +2433,7 @@ inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; }
} // namespace testing
#else
#ifdef __has_include
-#if __has_include(<optional>) && __cplusplus >= 201703L
+#if __has_include(<optional>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
// Otherwise for C++17 and higher use std::optional for UniversalPrinter<>
// specializations.
#define GTEST_INTERNAL_HAS_OPTIONAL 1
@@ -2447,7 +2447,7 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
} // namespace testing
// The case where absl is configured NOT to alias std::optional is not
// supported.
-#endif // __has_include(<optional>) && __cplusplus >= 201703L
+#endif // __has_include(<optional>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
#endif // __has_include
#endif // GTEST_HAS_ABSL
@@ -2467,7 +2467,7 @@ using StringView = ::absl::string_view;
} // namespace testing
#else
#ifdef __has_include
-#if __has_include(<string_view>) && __cplusplus >= 201703L
+#if __has_include(<string_view>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
// Otherwise for C++17 and higher use std::string_view for Matcher<>
// specializations.
#define GTEST_INTERNAL_HAS_STRING_VIEW 1
@@ -2479,7 +2479,8 @@ using StringView = ::std::string_view;
} // namespace testing
// The case where absl is configured NOT to alias std::string_view is not
// supported.
-#endif // __has_include(<string_view>) && __cplusplus >= 201703L
+#endif // __has_include(<string_view>) && GTEST_INTERNAL_CPLUSPLUS_LANG >=
+ // 201703L
#endif // __has_include
#endif // GTEST_HAS_ABSL
@@ -2500,7 +2501,7 @@ using Variant = ::absl::variant<T...>;
} // namespace testing
#else
#ifdef __has_include
-#if __has_include(<variant>) && __cplusplus >= 201703L
+#if __has_include(<variant>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
// Otherwise for C++17 and higher use std::variant for UniversalPrinter<>
// specializations.
#define GTEST_INTERNAL_HAS_VARIANT 1
@@ -2512,7 +2513,7 @@ using Variant = ::std::variant<T...>;
} // namespace internal
} // namespace testing
// The case where absl is configured NOT to alias std::variant is not supported.
-#endif // __has_include(<variant>) && __cplusplus >= 201703L
+#endif // __has_include(<variant>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
#endif // __has_include
#endif // GTEST_HAS_ABSL
diff --git a/googletest/include/gtest/internal/gtest-type-util.h b/googletest/include/gtest/internal/gtest-type-util.h
index 17a470b..f94cf61 100644
--- a/googletest/include/gtest/internal/gtest-type-util.h
+++ b/googletest/include/gtest/internal/gtest-type-util.h
@@ -67,6 +67,22 @@ inline std::string CanonicalizeForStdLibVersioning(std::string s) {
s.erase(strlen("std"), end - strlen("std"));
}
}
+
+ // Strip redundant spaces in typename to match MSVC
+ // For example, std::pair<int, bool> -> std::pair<int,bool>
+ static const char to_search[] = ", ";
+ static const char replace_str[] = ",";
+ size_t pos = 0;
+ while (true) {
+ // Get the next occurrence from the current position
+ pos = s.find(to_search, pos);
+ if (pos == std::string::npos) {
+ break;
+ }
+ // Replace this occurrence of substring
+ s.replace(pos, strlen(to_search), replace_str);
+ pos += strlen(replace_str);
+ }
return s;
}
@@ -85,6 +101,20 @@ inline std::string GetTypeName(const std::type_info& type) {
const std::string name_str(status == 0 ? readable_name : name);
free(readable_name);
return CanonicalizeForStdLibVersioning(name_str);
+#elif defined(_MSC_VER)
+ // Strip struct and class due to differences between
+ // MSVC and other compilers. std::pair<int,bool> is printed as
+ // "struct std::pair<int,bool>" when using MSVC vs "std::pair<int, bool>" with
+ // other compilers.
+ std::string s = name;
+ // Only strip the leading "struct " and "class ", so uses rfind == 0 to
+ // ensure that
+ if (s.rfind("struct ", 0) == 0) {
+ s = s.substr(strlen("struct "));
+ } else if (s.rfind("class ", 0) == 0) {
+ s = s.substr(strlen("class "));
+ }
+ return s;
#else
return name;
#endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
diff --git a/googletest/samples/prime_tables.h b/googletest/samples/prime_tables.h
index 08ad949..14c016a 100644
--- a/googletest/samples/prime_tables.h
+++ b/googletest/samples/prime_tables.h
@@ -39,7 +39,7 @@
// The prime table interface.
class PrimeTable {
public:
- virtual ~PrimeTable() {}
+ virtual ~PrimeTable() = default;
// Returns true if and only if n is a prime number.
virtual bool IsPrime(int n) const = 0;
diff --git a/googletest/samples/sample10_unittest.cc b/googletest/samples/sample10_unittest.cc
index 95b4811..2107954 100644
--- a/googletest/samples/sample10_unittest.cc
+++ b/googletest/samples/sample10_unittest.cc
@@ -38,7 +38,6 @@ using ::testing::InitGoogleTest;
using ::testing::Test;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
-using ::testing::TestPartResult;
using ::testing::UnitTest;
namespace {
diff --git a/googletest/samples/sample8_unittest.cc b/googletest/samples/sample8_unittest.cc
index 9717e28..4df81df 100644
--- a/googletest/samples/sample8_unittest.cc
+++ b/googletest/samples/sample8_unittest.cc
@@ -32,6 +32,8 @@
// and each test is given one combination as a parameter.
// Use class definitions to test from this header.
+#include <tuple>
+
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace {
diff --git a/googletest/samples/sample9_unittest.cc b/googletest/samples/sample9_unittest.cc
index d627ea7..0a2f097 100644
--- a/googletest/samples/sample9_unittest.cc
+++ b/googletest/samples/sample9_unittest.cc
@@ -40,7 +40,6 @@ using ::testing::Test;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
-using ::testing::TestSuite;
using ::testing::UnitTest;
namespace {
// Provides alternative output mode which produces minimal amount of
diff --git a/googletest/src/gtest-assertion-result.cc b/googletest/src/gtest-assertion-result.cc
index f1c0b10..3998921 100644
--- a/googletest/src/gtest-assertion-result.cc
+++ b/googletest/src/gtest-assertion-result.cc
@@ -44,7 +44,7 @@ namespace testing {
// Used in EXPECT_TRUE/FALSE(assertion_result).
AssertionResult::AssertionResult(const AssertionResult& other)
: success_(other.success_),
- message_(other.message_.get() != nullptr
+ message_(other.message_ != nullptr
? new ::std::string(*other.message_)
: static_cast< ::std::string*>(nullptr)) {}
@@ -58,7 +58,7 @@ void AssertionResult::swap(AssertionResult& other) {
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
AssertionResult AssertionResult::operator!() const {
AssertionResult negation(!success_);
- if (message_.get() != nullptr) negation << *message_;
+ if (message_ != nullptr) negation << *message_;
return negation;
}
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 1bf2f31..4cf78e7 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -34,6 +34,8 @@
#include <functional>
#include <memory>
+#include <sstream>
+#include <string>
#include <utility>
#include <vector>
@@ -623,9 +625,11 @@ bool DeathTestImpl::Passed(bool status_ok) {
return success;
}
+#ifndef GTEST_OS_WINDOWS
// Note: The return value points into args, so the return value's lifetime is
// bound to that of args.
-std::unique_ptr<char*[]> CreateArgvFromArgs(std::vector<std::string>& args) {
+static std::unique_ptr<char*[]> CreateArgvFromArgs(
+ std::vector<std::string>& args) {
auto result = std::make_unique<char*[]>(args.size() + 1);
for (size_t i = 0; i < args.size(); ++i) {
result[i] = &args[i][0];
@@ -633,6 +637,7 @@ std::unique_ptr<char*[]> CreateArgvFromArgs(std::vector<std::string>& args) {
result[args.size()] = nullptr; // extra null terminator
return result;
}
+#endif
#ifdef GTEST_OS_WINDOWS
// WindowsDeathTest implements death tests on Windows. Due to the
@@ -1027,7 +1032,7 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
// Note: The test component must have `fuchsia.process.Launcher` declared
// in its manifest. (Fuchsia integration tests require creating a
// "Fuchsia Test Component" which contains a "Fuchsia Component Manifest")
- // Launching processes is a privileged operation in Fuschia, and the
+ // Launching processes is a privileged operation in Fuchsia, and the
// declaration indicates that the ability is required for the component.
std::unique_ptr<char*[]> argv = CreateArgvFromArgs(args);
status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(),
@@ -1328,8 +1333,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
#endif // GTEST_HAS_CLONE
if (use_fork && (child_pid = fork()) == 0) {
- ExecDeathTestChildMain(&args);
- _exit(0);
+ _exit(ExecDeathTestChildMain(&args));
}
#endif // GTEST_OS_QNX
#ifdef GTEST_OS_LINUX
@@ -1525,7 +1529,7 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
// the flag is specified; otherwise returns NULL.
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
- if (GTEST_FLAG_GET(internal_run_death_test) == "") return nullptr;
+ if (GTEST_FLAG_GET(internal_run_death_test).empty()) return nullptr;
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
// can use it here.
diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index 48dee13..75f52bc 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -31,6 +31,9 @@
#include <stdlib.h>
+#include <iterator>
+#include <string>
+
#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-port.h"
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 16841b5..be82166 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -93,7 +93,7 @@ GTEST_API_ TimeInMillis GetTimeInMillis();
GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
// Formats the given time in milliseconds as seconds. If the input is an exact N
-// seconds, the output has a trailing decimal point (e.g., "N." intead of "N").
+// seconds, the output has a trailing decimal point (e.g., "N." instead of "N").
GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);
// Converts the given time in milliseconds to a date string in the ISO 8601
@@ -407,8 +407,8 @@ GTEST_API_ FilePath GetCurrentExecutableName();
// The role interface for getting the OS stack trace as a string.
class OsStackTraceGetterInterface {
public:
- OsStackTraceGetterInterface() {}
- virtual ~OsStackTraceGetterInterface() {}
+ OsStackTraceGetterInterface() = default;
+ virtual ~OsStackTraceGetterInterface() = default;
// Returns the current OS stack trace as an std::string. Parameters:
//
@@ -436,7 +436,7 @@ class OsStackTraceGetterInterface {
// A working implementation of the OsStackTraceGetterInterface interface.
class OsStackTraceGetter : public OsStackTraceGetterInterface {
public:
- OsStackTraceGetter() {}
+ OsStackTraceGetter() = default;
std::string CurrentStackTrace(int max_depth, int skip_count) override;
void UponLeavingGTest() override;
@@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl {
void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
internal::TearDownTestSuiteFunc tear_down_tc,
TestInfo* test_info) {
-#ifdef GTEST_HAS_DEATH_TEST
+#ifdef GTEST_HAS_FILE_SYSTEM
// In order to support thread-safe death tests, we need to
// remember the original working directory when the test program
// was first invoked. We cannot do this in RUN_ALL_TESTS(), as
@@ -685,7 +685,7 @@ class GTEST_API_ UnitTestImpl {
GTEST_CHECK_(!original_working_dir_.IsEmpty())
<< "Failed to get the current working directory.";
}
-#endif // GTEST_HAS_DEATH_TEST
+#endif // GTEST_HAS_FILE_SYSTEM
GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
set_up_tc, tear_down_tc)
@@ -1064,7 +1064,7 @@ class StreamingListener : public EmptyTestEventListener {
// Abstract base class for writing strings to a socket.
class AbstractSocketWriter {
public:
- virtual ~AbstractSocketWriter() {}
+ virtual ~AbstractSocketWriter() = default;
// Sends a string to the socket.
virtual void Send(const std::string& message) = 0;
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 994fabd..2aaf2bc 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -37,6 +37,10 @@
#include <cstdint>
#include <fstream>
#include <memory>
+#include <ostream>
+#include <string>
+#include <utility>
+#include <vector>
#ifdef GTEST_OS_WINDOWS
#include <io.h>
@@ -195,8 +199,8 @@ size_t GetThreadCount() {
mib[5] = static_cast<int>(size / static_cast<size_t>(mib[4]));
// populate array of structs
- struct kinfo_proc info[mib[5]];
- if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
+ std::vector<struct kinfo_proc> info(mib[5]);
+ if (sysctl(mib, miblen, info.data(), &size, NULL, 0)) {
return 0;
}
diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc
index d475ad3..2b47067 100644
--- a/googletest/src/gtest-printers.cc
+++ b/googletest/src/gtest-printers.cc
@@ -47,6 +47,8 @@
#include <cctype>
#include <cstdint>
#include <cwchar>
+#include <iomanip>
+#include <ios>
#include <ostream> // NOLINT
#include <string>
#include <type_traits>
@@ -528,7 +530,7 @@ void PrintStringTo(const ::std::string& s, ostream* os) {
}
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
void PrintU8StringTo(const ::std::u8string& s, ostream* os) {
PrintCharsAsStringTo(s.data(), s.size(), os);
}
diff --git a/googletest/src/gtest-test-part.cc b/googletest/src/gtest-test-part.cc
index eb7c8d1..6f8ddd7 100644
--- a/googletest/src/gtest-test-part.cc
+++ b/googletest/src/gtest-test-part.cc
@@ -32,13 +32,14 @@
#include "gtest/gtest-test-part.h"
+#include <ostream>
+#include <string>
+
#include "gtest/internal/gtest-port.h"
#include "src/gtest-internal-inl.h"
namespace testing {
-using internal::GetUnitTestImpl;
-
// Gets the summary of the failure message by omitting the stack trace
// in it.
std::string TestPartResult::ExtractSummary(const char* message) {
diff --git a/googletest/src/gtest-typed-test.cc b/googletest/src/gtest-typed-test.cc
index a2828b8..b251c09 100644
--- a/googletest/src/gtest-typed-test.cc
+++ b/googletest/src/gtest-typed-test.cc
@@ -29,6 +29,10 @@
#include "gtest/gtest-typed-test.h"
+#include <set>
+#include <string>
+#include <vector>
+
#include "gtest/gtest.h"
namespace testing {
@@ -90,7 +94,7 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
}
const std::string& errors_str = errors.GetString();
- if (errors_str != "") {
+ if (!errors_str.empty()) {
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
errors_str.c_str());
fflush(stderr);
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 55f8e50..fb7512c 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -44,16 +44,21 @@
#include <chrono> // NOLINT
#include <cmath>
#include <cstdint>
+#include <cstdlib>
+#include <cstring>
#include <initializer_list>
#include <iomanip>
#include <ios>
+#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <ostream> // NOLINT
+#include <set>
#include <sstream>
#include <unordered_set>
+#include <utility>
#include <vector>
#include "gtest/gtest-assertion-result.h"
@@ -136,6 +141,7 @@
#endif
#ifdef GTEST_HAS_ABSL
+#include "absl/container/flat_hash_set.h"
#include "absl/debugging/failure_signal_handler.h"
#include "absl/debugging/stacktrace.h"
#include "absl/debugging/symbolize.h"
@@ -143,6 +149,8 @@
#include "absl/flags/usage.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_replace.h"
+#include "absl/strings/string_view.h"
+#include "absl/strings/strip.h"
#endif // GTEST_HAS_ABSL
// Checks builtin compiler feature |x| while avoiding an extra layer of #ifdefs
@@ -408,7 +416,7 @@ uint32_t Random::Generate(uint32_t range) {
// GTestIsInitialized() returns true if and only if the user has initialized
// Google Test. Useful for catching the user mistake of not initializing
// Google Test before calling RUN_ALL_TESTS().
-static bool GTestIsInitialized() { return GetArgvs().size() > 0; }
+static bool GTestIsInitialized() { return !GetArgvs().empty(); }
// Iterates over a vector of TestSuites, keeping a running sum of the
// results of calling a given int-returning method on each.
@@ -2237,7 +2245,7 @@ TestResult::TestResult()
: death_test_count_(0), start_timestamp_(0), elapsed_time_(0) {}
// D'tor.
-TestResult::~TestResult() {}
+TestResult::~TestResult() = default;
// Returns the i-th test part result among all the results. i can
// range from 0 to total_part_count() - 1. If i is not in that range,
@@ -2446,7 +2454,7 @@ Test::Test() : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {}
// The d'tor restores the states of all flags. The actual work is
// done by the d'tor of the gtest_flag_saver_ field, and thus not
// visible here.
-Test::~Test() {}
+Test::~Test() = default;
// Sets up the test fixture.
//
@@ -2981,6 +2989,25 @@ void TestSuite::Run() {
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
+ // Ensure our tests are in a deterministic order.
+ //
+ // We do this by sorting lexicographically on (file, line number), providing
+ // an order matching what the user can see in the source code.
+ //
+ // In the common case the line number comparison shouldn't be necessary,
+ // because the registrations made by the TEST macro are executed in order
+ // within a translation unit. But this is not true of the manual registration
+ // API, and in more exotic scenarios a single file may be part of multiple
+ // translation units.
+ std::stable_sort(test_info_list_.begin(), test_info_list_.end(),
+ [](const TestInfo* const a, const TestInfo* const b) {
+ if (const int result = std::strcmp(a->file(), b->file())) {
+ return result < 0;
+ }
+
+ return a->line() < b->line();
+ });
+
// Call both legacy and the new API
repeater->OnTestSuiteStart(*this);
// Legacy API is deprecated but still available
@@ -3339,7 +3366,7 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
// Class PrettyUnitTestResultPrinter is copyable.
class PrettyUnitTestResultPrinter : public TestEventListener {
public:
- PrettyUnitTestResultPrinter() {}
+ PrettyUnitTestResultPrinter() = default;
static void PrintTestName(const char* test_suite, const char* test) {
printf("%s.%s", test_suite, test);
}
@@ -3647,7 +3674,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// Class BriefUnitTestResultPrinter is copyable.
class BriefUnitTestResultPrinter : public TestEventListener {
public:
- BriefUnitTestResultPrinter() {}
+ BriefUnitTestResultPrinter() = default;
static void PrintTestName(const char* test_suite, const char* test) {
printf("%s.%s", test_suite, test);
}
@@ -3762,28 +3789,28 @@ class TestEventRepeater : public TestEventListener {
bool forwarding_enabled() const { return forwarding_enabled_; }
void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
- void OnTestProgramStart(const UnitTest& unit_test) override;
+ void OnTestProgramStart(const UnitTest& parameter) override;
void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;
- void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
- void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override;
+ void OnEnvironmentsSetUpStart(const UnitTest& parameter) override;
+ void OnEnvironmentsSetUpEnd(const UnitTest& parameter) override;
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestCaseStart(const TestSuite& parameter) override;
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestSuiteStart(const TestSuite& parameter) override;
- void OnTestStart(const TestInfo& test_info) override;
- void OnTestDisabled(const TestInfo& test_info) override;
- void OnTestPartResult(const TestPartResult& result) override;
- void OnTestEnd(const TestInfo& test_info) override;
+ void OnTestStart(const TestInfo& parameter) override;
+ void OnTestDisabled(const TestInfo& parameter) override;
+ void OnTestPartResult(const TestPartResult& parameter) override;
+ void OnTestEnd(const TestInfo& parameter) override;
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestCaseEnd(const TestCase& parameter) override;
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void OnTestSuiteEnd(const TestSuite& parameter) override;
- void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
- void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override;
+ void OnEnvironmentsTearDownStart(const UnitTest& parameter) override;
+ void OnEnvironmentsTearDownEnd(const UnitTest& parameter) override;
void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
- void OnTestProgramEnd(const UnitTest& unit_test) override;
+ void OnTestProgramEnd(const UnitTest& parameter) override;
private:
// Controls whether events will be forwarded to listeners_. Set to false
@@ -5306,7 +5333,7 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
msg << message;
internal::MutexLock lock(&mutex_);
- if (impl_->gtest_trace_stack().size() > 0) {
+ if (!impl_->gtest_trace_stack().empty()) {
msg << "\n" << GTEST_NAME_ << " trace:";
for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
@@ -5319,6 +5346,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
if (os_stack_trace.c_str() != nullptr && !os_stack_trace.empty()) {
msg << internal::kStackTraceMarker << os_stack_trace;
+ } else {
+ msg << "\n";
}
const TestPartResult result = TestPartResult(
@@ -5604,7 +5633,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
// Disables event forwarding if the control is currently in a death test
// subprocess. Must not be called before InitGoogleTest.
void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
- if (internal_run_death_test_flag_.get() != nullptr)
+ if (internal_run_death_test_flag_ != nullptr)
listeners()->SuppressEventForwarding();
}
#endif // GTEST_HAS_DEATH_TEST
@@ -5620,7 +5649,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
} else if (output_format == "json") {
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
- } else if (output_format != "") {
+ } else if (!output_format.empty()) {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format << "\" ignored.";
}
@@ -5802,8 +5831,7 @@ bool UnitTestImpl::RunAllTests() {
bool in_subprocess_for_death_test = false;
#ifdef GTEST_HAS_DEATH_TEST
- in_subprocess_for_death_test =
- (internal_run_death_test_flag_.get() != nullptr);
+ in_subprocess_for_death_test = (internal_run_death_test_flag_ != nullptr);
#if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
if (in_subprocess_for_death_test) {
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
@@ -6662,25 +6690,60 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
}
// Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.
+// other parts of Google Test. This function updates argc and argv by removing
+// flags that are known to GoogleTest (including other user flags defined using
+// ABSL_FLAG if GoogleTest is built with GTEST_USE_ABSL). Other arguments
+// remain in place. Unrecognized flags are not reported and do not cause the
+// program to exit.
void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
#ifdef GTEST_HAS_ABSL
- if (*argc > 0) {
- // absl::ParseCommandLine() requires *argc > 0.
- auto positional_args = absl::flags_internal::ParseCommandLineImpl(
- *argc, argv, absl::flags_internal::UsageFlagsAction::kHandleUsage,
- absl::flags_internal::OnUndefinedFlag::kReportUndefined);
- // Any command-line positional arguments not part of any command-line flag
- // (or arguments to a flag) are copied back out to argv, with the program
- // invocation name at position 0, and argc is resized. This includes
- // positional arguments after the flag-terminating delimiter '--'.
- // See https://abseil.io/docs/cpp/guides/flags.
- std::copy(positional_args.begin(), positional_args.end(), argv);
- if (static_cast<int>(positional_args.size()) < *argc) {
- argv[positional_args.size()] = nullptr;
- *argc = static_cast<int>(positional_args.size());
+ if (*argc <= 0) return;
+
+ std::vector<char*> positional_args;
+ std::vector<absl::UnrecognizedFlag> unrecognized_flags;
+ absl::ParseAbseilFlagsOnly(*argc, argv, positional_args, unrecognized_flags);
+ absl::flat_hash_set<absl::string_view> unrecognized;
+ for (const auto& flag : unrecognized_flags) {
+ unrecognized.insert(flag.flag_name);
+ }
+ absl::flat_hash_set<char*> positional;
+ for (const auto& arg : positional_args) {
+ positional.insert(arg);
+ }
+
+ int out_pos = 1;
+ int in_pos = 1;
+ for (; in_pos < *argc; ++in_pos) {
+ char* arg = argv[in_pos];
+ absl::string_view arg_str(arg);
+ if (absl::ConsumePrefix(&arg_str, "--")) {
+ // Flag-like argument. If the flag was unrecognized, keep it.
+ // If it was a GoogleTest flag, remove it.
+ if (unrecognized.contains(arg_str)) {
+ argv[out_pos++] = argv[in_pos];
+ continue;
+ }
+ }
+
+ if (arg_str.empty()) {
+ ++in_pos;
+ break; // '--' indicates that the rest of the arguments are positional
+ }
+
+ // Probably a positional argument. If it is in fact positional, keep it.
+ // If it was a value for the flag argument, remove it.
+ if (positional.contains(arg)) {
+ argv[out_pos++] = arg;
}
}
+
+ // The rest are positional args for sure.
+ while (in_pos < *argc) {
+ argv[out_pos++] = argv[in_pos++];
+ }
+
+ *argc = out_pos;
+ argv[out_pos] = nullptr;
#else
ParseGoogleTestFlagsOnlyImpl(argc, argv);
#endif
diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc
index 3579ce8..4cc81b7 100644
--- a/googletest/test/googletest-death-test-test.cc
+++ b/googletest/test/googletest-death-test-test.cc
@@ -52,6 +52,9 @@ using testing::internal::AlwaysTrue;
#include <signal.h>
#include <stdio.h>
+#include <string>
+#include <vector>
+
#ifdef GTEST_OS_LINUX
#include <sys/time.h>
#endif // GTEST_OS_LINUX
diff --git a/googletest/test/googletest-filepath-test.cc b/googletest/test/googletest-filepath-test.cc
index 0a33d71..3e9c79f 100644
--- a/googletest/test/googletest-filepath-test.cc
+++ b/googletest/test/googletest-filepath-test.cc
@@ -515,7 +515,7 @@ class DirectoryCreationTest : public Test {
}
// Strings representing a directory and a file, with identical paths
- // except for the trailing separator character that distinquishes
+ // except for the trailing separator character that distinguishes
// a directory named 'test' from a file named 'test'. Example names:
FilePath testdata_path_; // "/tmp/directory_creation/test/"
FilePath testdata_file_; // "/tmp/directory_creation/test"
diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py
index ff15722..5626004 100644
--- a/googletest/test/googletest-json-outfiles-test.py
+++ b/googletest/test/googletest-json-outfiles-test.py
@@ -90,7 +90,7 @@ EXPECTED_2 = {
'testsuite': [{
'name': 'TestInt64ConvertibleProperties',
'file': 'gtest_xml_outfile2_test_.cc',
- 'line': 41,
+ 'line': 43,
'status': 'RUN',
'result': 'COMPLETED',
'timestamp': '*',
diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py
index b3a08de..cb97694 100644
--- a/googletest/test/googletest-json-output-unittest.py
+++ b/googletest/test/googletest-json-output-unittest.py
@@ -54,7 +54,7 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
if SUPPORTS_STACK_TRACES:
STACK_TRACE_TEMPLATE = '\nStack trace:\n*'
else:
- STACK_TRACE_TEMPLATE = ''
+ STACK_TRACE_TEMPLATE = '\n'
EXPECTED_NON_EMPTY = {
'tests': 26,
@@ -77,7 +77,7 @@ EXPECTED_NON_EMPTY = {
'testsuite': [{
'name': 'Succeeds',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 51,
+ 'line': 53,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -96,7 +96,7 @@ EXPECTED_NON_EMPTY = {
'testsuite': [{
'name': 'Fails',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 59,
+ 'line': 61,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -124,7 +124,7 @@ EXPECTED_NON_EMPTY = {
'testsuite': [{
'name': 'DISABLED_test_not_run',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 66,
+ 'line': 68,
'status': 'NOTRUN',
'result': 'SUPPRESSED',
'time': '*',
@@ -144,7 +144,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'Skipped',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 73,
+ 'line': 75,
'status': 'RUN',
'result': 'SKIPPED',
'time': '*',
@@ -154,7 +154,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'SkippedWithMessage',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 77,
+ 'line': 79,
'status': 'RUN',
'result': 'SKIPPED',
'time': '*',
@@ -164,7 +164,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'SkippedAfterFailure',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 81,
+ 'line': 83,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -194,7 +194,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'Succeeds',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 86,
+ 'line': 88,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -204,7 +204,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'Fails',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 91,
+ 'line': 93,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -234,7 +234,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'DISABLED_test',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 96,
+ 'line': 98,
'status': 'NOTRUN',
'result': 'SUPPRESSED',
'time': '*',
@@ -254,7 +254,7 @@ EXPECTED_NON_EMPTY = {
'testsuite': [{
'name': 'OutputsCData',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 100,
+ 'line': 102,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -282,7 +282,7 @@ EXPECTED_NON_EMPTY = {
'testsuite': [{
'name': 'InvalidCharactersInMessage',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 107,
+ 'line': 109,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -313,7 +313,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'OneProperty',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 119,
+ 'line': 121,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -324,7 +324,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'IntValuedProperty',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 123,
+ 'line': 125,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -335,7 +335,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'ThreeProperties',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 127,
+ 'line': 129,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -348,7 +348,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'TwoValuesForOneKeyUsesLastValue',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 133,
+ 'line': 135,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -370,7 +370,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'RecordProperty',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 138,
+ 'line': 140,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -381,7 +381,7 @@ EXPECTED_NON_EMPTY = {
{
'name': 'ExternalUtilityThatCallsRecordIntValuedProperty',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 151,
+ 'line': 153,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -394,7 +394,7 @@ EXPECTED_NON_EMPTY = {
'ExternalUtilityThatCallsRecordStringValuedProperty'
),
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 155,
+ 'line': 157,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -416,7 +416,7 @@ EXPECTED_NON_EMPTY = {
'name': 'HasTypeParamAttribute',
'type_param': 'int',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 171,
+ 'line': 173,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -436,7 +436,7 @@ EXPECTED_NON_EMPTY = {
'name': 'HasTypeParamAttribute',
'type_param': 'long',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 171,
+ 'line': 173,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -456,7 +456,7 @@ EXPECTED_NON_EMPTY = {
'name': 'HasTypeParamAttribute',
'type_param': 'int',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 178,
+ 'line': 180,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -476,7 +476,7 @@ EXPECTED_NON_EMPTY = {
'name': 'HasTypeParamAttribute',
'type_param': 'long',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 178,
+ 'line': 180,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -497,7 +497,7 @@ EXPECTED_NON_EMPTY = {
'name': 'HasValueParamAttribute/0',
'value_param': '33',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 162,
+ 'line': 164,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -508,7 +508,7 @@ EXPECTED_NON_EMPTY = {
'name': 'HasValueParamAttribute/1',
'value_param': '42',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 162,
+ 'line': 164,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -519,7 +519,7 @@ EXPECTED_NON_EMPTY = {
'name': 'AnotherTestThatHasValueParamAttribute/0',
'value_param': '33',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 163,
+ 'line': 165,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -530,7 +530,7 @@ EXPECTED_NON_EMPTY = {
'name': 'AnotherTestThatHasValueParamAttribute/1',
'value_param': '42',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 163,
+ 'line': 165,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
@@ -562,7 +562,7 @@ EXPECTED_FILTERED = {
'testsuite': [{
'name': 'Succeeds',
'file': 'gtest_xml_output_unittest_.cc',
- 'line': 51,
+ 'line': 53,
'status': 'RUN',
'result': 'COMPLETED',
'time': '*',
diff --git a/googletest/test/googletest-list-tests-unittest_.cc b/googletest/test/googletest-list-tests-unittest_.cc
index 5577e89..a1ea6cf 100644
--- a/googletest/test/googletest-list-tests-unittest_.cc
+++ b/googletest/test/googletest-list-tests-unittest_.cc
@@ -36,6 +36,9 @@
// This program will be invoked from a Python unit test.
// Don't run it directly.
+#include <ostream>
+#include <string>
+
#include "gtest/gtest.h"
// Several different test cases and tests that will be listed.
diff --git a/googletest/test/googletest-listener-test.cc b/googletest/test/googletest-listener-test.cc
index 654486d..d7c47c2 100644
--- a/googletest/test/googletest-listener-test.cc
+++ b/googletest/test/googletest-listener-test.cc
@@ -32,6 +32,7 @@
// This file verifies Google Test event listeners receive events at the
// right times.
+#include <string>
#include <vector>
#include "gtest/gtest.h"
diff --git a/googletest/test/googletest-output-test.py b/googletest/test/googletest-output-test.py
index 347b854..6d80d53 100755
--- a/googletest/test/googletest-output-test.py
+++ b/googletest/test/googletest-output-test.py
@@ -132,7 +132,7 @@ def RemoveStackTraces(output):
"""Removes all traces of stack traces from a Google Test program's output."""
# *? means "find the shortest string that matches".
- return re.sub(r'Stack trace:(.|\n)*?\n\n', '', output)
+ return re.sub(r'Stack trace:(.|\n)*?\n', '', output)
def RemoveTime(output):
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index 44d0fc1..f1facf5 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -35,6 +35,9 @@
#include <stdlib.h>
+#include <algorithm>
+#include <string>
+
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
diff --git a/googletest/test/googletest-param-test-invalid-name2-test_.cc b/googletest/test/googletest-param-test-invalid-name2-test_.cc
index d0c44da..6d88a9c 100644
--- a/googletest/test/googletest-param-test-invalid-name2-test_.cc
+++ b/googletest/test/googletest-param-test-invalid-name2-test_.cc
@@ -27,6 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include <string>
+
#include "gtest/gtest.h"
namespace {
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 1ba3f50..32a2a7b 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -97,7 +97,7 @@ class Base {
explicit Base(int n) : member_(n) {}
Base(const Base&) = default;
Base& operator=(const Base&) = default;
- virtual ~Base() {}
+ virtual ~Base() = default;
int member() { return member_; }
private:
@@ -979,14 +979,14 @@ TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
EXPECT_EQ(&i, t2.get());
}
-class NoDefaultContructor {
+class NoDefaultConstructor {
public:
- explicit NoDefaultContructor(const char*) {}
- NoDefaultContructor(const NoDefaultContructor&) {}
+ explicit NoDefaultConstructor(const char*) {}
+ NoDefaultConstructor(const NoDefaultConstructor&) = default;
};
TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {
- ThreadLocal<NoDefaultContructor> bar(NoDefaultContructor("foo"));
+ ThreadLocal<NoDefaultConstructor> bar(NoDefaultConstructor("foo"));
bar.pointer();
}
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index 401e046..f44f29a 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -42,9 +42,11 @@
#include <list>
#include <map>
#include <memory>
+#include <ostream>
#include <set>
#include <sstream>
#include <string>
+#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
@@ -106,7 +108,7 @@ class UnprintableTemplateInGlobal {
// A user-defined streamable type in the global namespace.
class StreamableInGlobal {
public:
- virtual ~StreamableInGlobal() {}
+ virtual ~StreamableInGlobal() = default;
};
inline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) {
@@ -214,7 +216,7 @@ class PathLike {
using value_type = char;
using const_iterator = iterator;
- PathLike() {}
+ PathLike() = default;
iterator begin() const { return iterator(); }
iterator end() const { return iterator(); }
@@ -359,7 +361,7 @@ TEST(PrintCharTest, Char16) { EXPECT_EQ("U+0041", Print(u'A')); }
TEST(PrintCharTest, Char32) { EXPECT_EQ("U+0041", Print(U'A')); }
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
TEST(PrintCharTest, Char8) { EXPECT_EQ("U+0041", Print(u8'A')); }
#endif
@@ -412,7 +414,7 @@ TEST(PrintBuiltInTypeTest, Integer) {
Print(std::numeric_limits<uint64_t>::max())); // uint64
EXPECT_EQ("-9223372036854775808",
Print(std::numeric_limits<int64_t>::min())); // int64
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
EXPECT_EQ("U+0000",
Print(std::numeric_limits<char8_t>::min())); // char8_t
EXPECT_EQ("U+00FF",
@@ -518,7 +520,7 @@ TEST(PrintCStringTest, EscapesProperly) {
Print(p));
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// const char8_t*.
TEST(PrintU8StringTest, Const) {
const char8_t* p = u8"η•Œ";
@@ -747,7 +749,7 @@ AssertionResult HasPrefix(const StringType& str, const StringType& prefix) {
struct Foo {
public:
- virtual ~Foo() {}
+ virtual ~Foo() = default;
int MyMethod(char x) { return x + 1; }
virtual char MyVirtualMethod(int /* n */) { return 'a'; }
@@ -815,7 +817,7 @@ TEST(PrintArrayTest, CharArrayWithTerminatingNul) {
EXPECT_EQ("\"\\0Hi\"", PrintArrayHelper(a));
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// char_t array without terminating NUL.
TEST(PrintArrayTest, Char8ArrayWithNoTerminatingNul) {
// Array a contains '\0' in the middle and doesn't end with '\0'.
@@ -935,7 +937,7 @@ TEST(PrintWideStringTest, StringAmbiguousHex) {
}
#endif // GTEST_HAS_STD_WSTRING
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
TEST(PrintStringTest, U8String) {
std::u8string str = u8"Hello, δΈ–η•Œ";
EXPECT_EQ(str, str); // Verify EXPECT_EQ compiles with this type.
diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index fda40bf..85a0c33 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -43,6 +43,7 @@ import sys
from googletest.test import gtest_test_utils
+IS_DARWIN = os.name == 'posix' and os.uname()[0] == 'Darwin'
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_GNUHURD = os.name == 'posix' and os.uname()[0] == 'GNU'
IS_GNUKFREEBSD = os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
@@ -53,7 +54,6 @@ PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
FLAG_PREFIX = '--gtest_'
DEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style'
STREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to'
-UNKNOWN_GTEST_PREFIXED_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing'
LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'
INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing'
@@ -136,7 +136,7 @@ class GTestHelpTest(gtest_test_utils.TestCase):
self.assertTrue(HELP_REGEX.search(output), output)
- if IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
+ if IS_DARWIN or IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
self.assertIn(STREAM_RESULT_TO_FLAG, output)
else:
self.assertNotIn(STREAM_RESULT_TO_FLAG, output)
@@ -176,16 +176,6 @@ class GTestHelpTest(gtest_test_utils.TestCase):
def testPrintsHelpWithFullFlag(self):
self.TestHelpFlag('--help')
- def testPrintsHelpWithUnrecognizedGoogleTestFlag(self):
- # The behavior is slightly different when Abseil flags is
- # used. Abseil flags rejects all unknown flags, while the builtin
- # GTest flags implementation interprets an unknown flag with a
- # '--gtest_' prefix as a request for help.
- if HAS_ABSL_FLAGS:
- self.TestUnknownFlagWithAbseil(UNKNOWN_GTEST_PREFIXED_FLAG)
- else:
- self.TestHelpFlag(UNKNOWN_GTEST_PREFIXED_FLAG)
-
def testRunsTestsWithoutHelpFlag(self):
"""Verifies correct behavior when no help flag is specified.
diff --git a/googletest/test/gtest_repeat_test.cc b/googletest/test/gtest_repeat_test.cc
index 73fb8dc..f67b788 100644
--- a/googletest/test/gtest_repeat_test.cc
+++ b/googletest/test/gtest_repeat_test.cc
@@ -61,7 +61,7 @@ int g_environment_tear_down_count = 0;
class MyEnvironment : public testing::Environment {
public:
- MyEnvironment() {}
+ MyEnvironment() = default;
void SetUp() override { g_environment_set_up_count++; }
void TearDown() override { g_environment_tear_down_count++; }
};
diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc
index 0cf2185..af8e757 100644
--- a/googletest/test/gtest_stress_test.cc
+++ b/googletest/test/gtest_stress_test.cc
@@ -30,7 +30,9 @@
// Tests that SCOPED_TRACE() and various Google Test assertions can be
// used in a large number of threads concurrently.
+#include <algorithm>
#include <memory>
+#include <string>
#include <vector>
#include "gtest/gtest.h"
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 768911a..77d968a 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -63,6 +63,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <memory>
#include <ostream>
#include <set>
+#include <stdexcept>
#include <string>
#include <type_traits>
#include <unordered_set>
@@ -3311,11 +3312,7 @@ TEST_F(SingleEvaluationTest, OtherCases) {
#if GTEST_HAS_RTTI
-#ifdef _MSC_VER
-#define ERROR_DESC "class std::runtime_error"
-#else
#define ERROR_DESC "std::runtime_error"
-#endif
#else // GTEST_HAS_RTTI
@@ -4950,7 +4947,7 @@ TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) {
// both in a TEST and in a TEST_F.
class Foo {
public:
- Foo() {}
+ Foo() = default;
private:
int Bar() const { return 1; }
@@ -6219,6 +6216,15 @@ TEST_F(ParseFlagsTest, AbseilPositionalFlags) {
}
#endif
+TEST_F(ParseFlagsTest, UnrecognizedFlags) {
+ const char* argv[] = {"foo.exe", "--gtest_filter=abcd", "--other_flag",
+ nullptr};
+
+ const char* argv2[] = {"foo.exe", "--other_flag", nullptr};
+
+ GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abcd"), false);
+}
+
#ifdef GTEST_OS_WINDOWS
// Tests parsing wide strings.
TEST_F(ParseFlagsTest, WideStrings) {
@@ -6669,7 +6675,7 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
SetEnv("TERM", "linux"); // TERM supports colors.
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
- SetEnv("TERM", "cygwin"); // TERM supports colors.
+ SetEnv("TERM", "cygwin"); // TERM supports colors.
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
#endif // GTEST_OS_WINDOWS
}
@@ -6975,7 +6981,7 @@ TEST(EventListenerTest, SuppressEventForwarding) {
// Tests that events generated by Google Test are not forwarded in
// death test subprocesses.
-TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses) {
+TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprocesses) {
EXPECT_DEATH_IF_SUPPORTED(
{
GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled(
diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc
index ed58dc8..4a76429 100644
--- a/googletest/test/gtest_xml_outfile2_test_.cc
+++ b/googletest/test/gtest_xml_outfile2_test_.cc
@@ -30,6 +30,8 @@
// gtest_xml_outfile2_test_ writes some xml via TestProperty used by
// gtest_xml_outfiles_test.py
+#include <atomic>
+
#include "gtest/gtest.h"
class PropertyTwo : public testing::Test {
diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py
index 50291b0..d17cc0c 100755
--- a/googletest/test/gtest_xml_outfiles_test.py
+++ b/googletest/test/gtest_xml_outfiles_test.py
@@ -57,7 +57,7 @@ EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_2 = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuite name="PropertyTwo" tests="1" failures="0" skipped="0" disabled="0" errors="0" time="*" timestamp="*">
- <testcase name="TestInt64ConvertibleProperties" file="gtest_xml_outfile2_test_.cc" line="41" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo">
+ <testcase name="TestInt64ConvertibleProperties" file="gtest_xml_outfile2_test_.cc" line="43" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo">
<properties>
<property name="SetUpProp" value="2"/>
<property name="TestFloatProperty" value="3.25"/>
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
index 5ca11cb..422569e 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -59,135 +59,138 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
if SUPPORTS_STACK_TRACES:
STACK_TRACE_TEMPLATE = '\nStack trace:\n*'
+ STACK_TRACE_ENTITY_TEMPLATE = ''
else:
- STACK_TRACE_TEMPLATE = ''
+ STACK_TRACE_TEMPLATE = '\n'
+ STACK_TRACE_ENTITY_TEMPLATE = '&#x0A;'
# unittest.main() can't handle unknown flags
sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG)
EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="26" failures="5" disabled="2" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="51" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
+ <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="53" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
</testsuite>
<testsuite name="FailedTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="59" status="run" result="completed" time="*" timestamp="*" classname="FailedTest">
- <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="61" status="run" result="completed" time="*" timestamp="*" classname="FailedTest">
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values:
1
2%(stack)s]]></failure>
</testcase>
</testsuite>
<testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="86" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest"/>
- <testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="91" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest">
- <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="88" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest"/>
+ <testcase name="Fails" file="gtest_xml_output_unittest_.cc" line="93" status="run" result="completed" time="*" timestamp="*" classname="MixedResultTest">
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values:
1
2%(stack)s]]></failure>
- <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 2&#x0A; 3" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 2&#x0A; 3%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values:
2
3%(stack)s]]></failure>
</testcase>
- <testcase name="DISABLED_test" file="gtest_xml_output_unittest_.cc" line="96" status="notrun" result="suppressed" time="*" timestamp="*" classname="MixedResultTest"/>
+ <testcase name="DISABLED_test" file="gtest_xml_output_unittest_.cc" line="98" status="notrun" result="suppressed" time="*" timestamp="*" classname="MixedResultTest"/>
</testsuite>
<testsuite name="XmlQuotingTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="OutputsCData" file="gtest_xml_output_unittest_.cc" line="100" status="run" result="completed" time="*" timestamp="*" classname="XmlQuotingTest">
- <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <testcase name="OutputsCData" file="gtest_xml_output_unittest_.cc" line="102" status="run" result="completed" time="*" timestamp="*" classname="XmlQuotingTest">
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed
XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]>]]&gt;<![CDATA[</top>%(stack)s]]></failure>
</testcase>
</testsuite>
<testsuite name="InvalidCharactersTest" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="InvalidCharactersInMessage" file="gtest_xml_output_unittest_.cc" line="107" status="run" result="completed" time="*" timestamp="*" classname="InvalidCharactersTest">
- <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;Invalid characters in brackets []" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <testcase name="InvalidCharactersInMessage" file="gtest_xml_output_unittest_.cc" line="109" status="run" result="completed" time="*" timestamp="*" classname="InvalidCharactersTest">
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;Invalid characters in brackets []%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed
Invalid characters in brackets []%(stack)s]]></failure>
</testcase>
</testsuite>
<testsuite name="DisabledTest" tests="1" failures="0" disabled="1" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="DISABLED_test_not_run" file="gtest_xml_output_unittest_.cc" line="66" status="notrun" result="suppressed" time="*" timestamp="*" classname="DisabledTest"/>
+ <testcase name="DISABLED_test_not_run" file="gtest_xml_output_unittest_.cc" line="68" status="notrun" result="suppressed" time="*" timestamp="*" classname="DisabledTest"/>
</testsuite>
<testsuite name="SkippedTest" tests="3" failures="1" disabled="0" skipped="2" errors="0" time="*" timestamp="*">
- <testcase name="Skipped" status="run" file="gtest_xml_output_unittest_.cc" line="73" result="skipped" time="*" timestamp="*" classname="SkippedTest">
- <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;"><![CDATA[gtest_xml_output_unittest_.cc:*
+ <testcase name="Skipped" status="run" file="gtest_xml_output_unittest_.cc" line="75" result="skipped" time="*" timestamp="*" classname="SkippedTest">
+ <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
%(stack)s]]></skipped>
</testcase>
- <testcase name="SkippedWithMessage" file="gtest_xml_output_unittest_.cc" line="77" status="run" result="skipped" time="*" timestamp="*" classname="SkippedTest">
- <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test."><![CDATA[gtest_xml_output_unittest_.cc:*
+ <testcase name="SkippedWithMessage" file="gtest_xml_output_unittest_.cc" line="79" status="run" result="skipped" time="*" timestamp="*" classname="SkippedTest">
+ <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack)s]]></skipped>
</testcase>
- <testcase name="SkippedAfterFailure" file="gtest_xml_output_unittest_.cc" line="81" status="run" result="completed" time="*" timestamp="*" classname="SkippedTest">
- <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <testcase name="SkippedAfterFailure" file="gtest_xml_output_unittest_.cc" line="83" status="run" result="completed" time="*" timestamp="*" classname="SkippedTest">
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values:
1
2%(stack)s]]></failure>
- <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test."><![CDATA[gtest_xml_output_unittest_.cc:*
+ <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack)s]]></skipped>
</testcase>
</testsuite>
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*" SetUpTestSuite="yes" TearDownTestSuite="aye">
- <testcase name="OneProperty" file="gtest_xml_output_unittest_.cc" line="119" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
+ <testcase name="OneProperty" file="gtest_xml_output_unittest_.cc" line="121" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties>
<property name="key_1" value="1"/>
</properties>
</testcase>
- <testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="123" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
+ <testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="125" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties>
<property name="key_int" value="1"/>
</properties>
</testcase>
- <testcase name="ThreeProperties" file="gtest_xml_output_unittest_.cc" line="127" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
+ <testcase name="ThreeProperties" file="gtest_xml_output_unittest_.cc" line="129" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties>
<property name="key_1" value="1"/>
<property name="key_2" value="2"/>
<property name="key_3" value="3"/>
</properties>
</testcase>
- <testcase name="TwoValuesForOneKeyUsesLastValue" file="gtest_xml_output_unittest_.cc" line="133" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
+ <testcase name="TwoValuesForOneKeyUsesLastValue" file="gtest_xml_output_unittest_.cc" line="135" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties>
<property name="key_1" value="2"/>
</properties>
</testcase>
</testsuite>
<testsuite name="NoFixtureTest" tests="3" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="RecordProperty" file="gtest_xml_output_unittest_.cc" line="138" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
+ <testcase name="RecordProperty" file="gtest_xml_output_unittest_.cc" line="140" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
<properties>
<property name="key" value="1"/>
</properties>
</testcase>
- <testcase name="ExternalUtilityThatCallsRecordIntValuedProperty" file="gtest_xml_output_unittest_.cc" line="151" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
+ <testcase name="ExternalUtilityThatCallsRecordIntValuedProperty" file="gtest_xml_output_unittest_.cc" line="153" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
<properties>
<property name="key_for_utility_int" value="1"/>
</properties>
</testcase>
- <testcase name="ExternalUtilityThatCallsRecordStringValuedProperty" file="gtest_xml_output_unittest_.cc" line="155" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
+ <testcase name="ExternalUtilityThatCallsRecordStringValuedProperty" file="gtest_xml_output_unittest_.cc" line="157" status="run" result="completed" time="*" timestamp="*" classname="NoFixtureTest">
<properties>
<property name="key_for_utility_string" value="1"/>
</properties>
</testcase>
</testsuite>
<testsuite name="Single/ValueParamTest" tests="4" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="162" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
- <testcase name="HasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="162" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
- <testcase name="AnotherTestThatHasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="163" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
- <testcase name="AnotherTestThatHasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="163" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
+ <testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="164" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
+ <testcase name="HasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="164" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
+ <testcase name="AnotherTestThatHasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="165" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
+ <testcase name="AnotherTestThatHasValueParamAttribute/1" file="gtest_xml_output_unittest_.cc" line="165" value_param="42" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
</testsuite>
<testsuite name="TypedTest/0" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="171" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/0" />
+ <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="173" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/0" />
</testsuite>
<testsuite name="TypedTest/1" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="171" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/1" />
+ <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="173" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="TypedTest/1" />
</testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/0" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="178" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/0" />
+ <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="180" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/0" />
</testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/1" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="178" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/1" />
+ <testcase name="HasTypeParamAttribute" file="gtest_xml_output_unittest_.cc" line="180" type_param="*" status="run" result="completed" time="*" timestamp="*" classname="Single/TypeParameterizedTestSuite/1" />
</testsuite>
</testsuites>""" % {
- 'stack': STACK_TRACE_TEMPLATE
+ 'stack': STACK_TRACE_TEMPLATE,
+ 'stack_entity': STACK_TRACE_ENTITY_TEMPLATE,
}
EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
@@ -195,24 +198,24 @@ EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0"
errors="0" time="*" timestamp="*">
- <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="51" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
+ <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="53" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
</testsuite>
</testsuites>"""
EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="51" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
+ <testcase name="Succeeds" file="gtest_xml_output_unittest_.cc" line="53" status="run" result="completed" time="*" timestamp="*" classname="SuccessfulTest"/>
</testsuite>
<testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*" SetUpTestSuite="yes" TearDownTestSuite="aye">
- <testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="123" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
+ <testcase name="IntValuedProperty" file="gtest_xml_output_unittest_.cc" line="125" status="run" result="completed" time="*" timestamp="*" classname="PropertyRecordingTest">
<properties>
<property name="key_int" value="1"/>
</properties>
</testcase>
</testsuite>
<testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
- <testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="162" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
+ <testcase name="HasValueParamAttribute/0" file="gtest_xml_output_unittest_.cc" line="164" value_param="33" status="run" result="completed" time="*" timestamp="*" classname="Single/ValueParamTest" />
</testsuite>
</testsuites>"""
@@ -221,14 +224,15 @@ EXPECTED_NO_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
timestamp="*" name="AllTests">
<testsuite name="NonTestSuiteFailure" tests="1" failures="1" disabled="0" skipped="0" errors="0" time="*" timestamp="*">
<testcase name="" status="run" result="completed" time="*" timestamp="*" classname="">
- <failure message="gtest_no_test_unittest.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_no_test_unittest.cc:*
+ <failure message="gtest_no_test_unittest.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_no_test_unittest.cc:*
Expected equality of these values:
1
2%(stack)s]]></failure>
</testcase>
</testsuite>
</testsuites>""" % {
- 'stack': STACK_TRACE_TEMPLATE
+ 'stack': STACK_TRACE_TEMPLATE,
+ 'stack_entity': STACK_TRACE_ENTITY_TEMPLATE,
}
GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)
diff --git a/googletest/test/gtest_xml_output_unittest_.cc b/googletest/test/gtest_xml_output_unittest_.cc
index 4bdb0c7..0ab3302 100644
--- a/googletest/test/gtest_xml_output_unittest_.cc
+++ b/googletest/test/gtest_xml_output_unittest_.cc
@@ -37,6 +37,8 @@
// directly.
// clang-format off
+#include <string>
+
#include "gtest/gtest.h"
using ::testing::InitGoogleTest;
diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py
index 8fcb693..74e0f4a 100755
--- a/googletest/test/gtest_xml_test_utils.py
+++ b/googletest/test/gtest_xml_test_utils.py
@@ -218,7 +218,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
)
if element.tagName in ('testsuites', 'testsuite', 'testcase'):
time = element.getAttributeNode('time')
- # The value for exact N seconds has a traling decimal point (e.g., "10."
+ # The value for exact N seconds has a trailing decimal point (e.g., "10."
# instead of "10")
time.value = re.sub(r'^\d+\.(\d+)?$', '*', time.value)
type_param = element.getAttributeNode('type_param')
diff --git a/googletest_deps.bzl b/googletest_deps.bzl
new file mode 100644
index 0000000..5e807d7
--- /dev/null
+++ b/googletest_deps.bzl
@@ -0,0 +1,22 @@
+"""Load dependencies needed to use the googletest library as a 3rd-party consumer."""
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+def googletest_deps():
+ """Loads common dependencies needed to use the googletest library."""
+
+ if not native.existing_rule("com_googlesource_code_re2"):
+ http_archive(
+ name = "com_googlesource_code_re2", # 2023-06-01
+ sha256 = "1726508efc93a50854c92e3f7ac66eb28f0e57652e413f11d7c1e28f97d997ba",
+ strip_prefix = "re2-03da4fc0857c285e3a26782f6bc8931c4c950df4",
+ urls = ["https://github.com/google/re2/archive/03da4fc0857c285e3a26782f6bc8931c4c950df4.zip"],
+ )
+
+ if not native.existing_rule("com_google_absl"):
+ http_archive(
+ name = "com_google_absl", # 2023-04-06T14:42:25Z
+ sha256 = "a50452f02402262f9a61a8eedda60f76dda6b9538d36b34b55bce9f74a4d5ef8",
+ strip_prefix = "abseil-cpp-e73b9139ee9b853a4bd7812531442c138da09084",
+ urls = ["https://github.com/abseil/abseil-cpp/archive/e73b9139ee9b853a4bd7812531442c138da09084.zip"],
+ )