Compare commits

..

No commits in common. "ff233bdd4cac0a0bf6e5cd45bda3406814cb2796" and "417158b8bca158426cbdc0c547fdd7d9fbd46904" have entirely different histories.

20 changed files with 99 additions and 223 deletions

View File

@ -138,19 +138,19 @@ cc_library(
}), }),
deps = select({ deps = select({
":has_absl": [ ":has_absl": [
"@abseil-cpp//absl/container:flat_hash_set", "@com_google_absl//absl/container:flat_hash_set",
"@abseil-cpp//absl/debugging:failure_signal_handler", "@com_google_absl//absl/debugging:failure_signal_handler",
"@abseil-cpp//absl/debugging:stacktrace", "@com_google_absl//absl/debugging:stacktrace",
"@abseil-cpp//absl/debugging:symbolize", "@com_google_absl//absl/debugging:symbolize",
"@abseil-cpp//absl/flags:flag", "@com_google_absl//absl/flags:flag",
"@abseil-cpp//absl/flags:parse", "@com_google_absl//absl/flags:parse",
"@abseil-cpp//absl/flags:reflection", "@com_google_absl//absl/flags:reflection",
"@abseil-cpp//absl/flags:usage", "@com_google_absl//absl/flags:usage",
"@abseil-cpp//absl/strings", "@com_google_absl//absl/strings",
"@abseil-cpp//absl/types:any", "@com_google_absl//absl/types:any",
"@abseil-cpp//absl/types:optional", "@com_google_absl//absl/types:optional",
"@abseil-cpp//absl/types:variant", "@com_google_absl//absl/types:variant",
"@re2//:re2", "@com_googlesource_code_re2//:re2",
], ],
"//conditions:default": [], "//conditions:default": [],
}) + select({ }) + select({

View File

@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(googletest-distribution) project(googletest-distribution)
set(GOOGLETEST_VERSION 1.15.2) set(GOOGLETEST_VERSION 1.14.0)
if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)

View File

@ -40,28 +40,22 @@ module(
# Please keep the versions in sync with the versions in the WORKSPACE file. # Please keep the versions in sync with the versions in the WORKSPACE file.
bazel_dep(name = "abseil-cpp", bazel_dep(name = "abseil-cpp",
version = "20240116.2") version = "20240116.2",
repo_name = "com_google_absl")
bazel_dep(name = "platforms", bazel_dep(name = "platforms",
version = "0.0.10") version = "0.0.10")
bazel_dep(name = "re2", bazel_dep(name = "re2",
repo_name = "com_googlesource_code_re2",
version = "2024-07-02") version = "2024-07-02")
bazel_dep(name = "rules_python", bazel_dep(name = "rules_python",
version = "0.34.0", version = "0.29.0")
dev_dependency = True)
# https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage
python = use_extension(
"@rules_python//python/extensions:python.bzl",
"python",
dev_dependency = True
)
python.toolchain(python_version = "3.12",
is_default = True,
ignore_root_user_error = True)
fake_fuchsia_sdk = use_repo_rule("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk") fake_fuchsia_sdk = use_repo_rule("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")
fake_fuchsia_sdk(name = "fuchsia_sdk") fake_fuchsia_sdk(name = "fuchsia_sdk")
# https://github.com/bazelbuild/rules_python/blob/main/BZLMOD_SUPPORT.md#default-toolchain-is-not-the-local-system-python
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")

View File

@ -9,7 +9,7 @@ GoogleTest now follows the
We recommend 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). [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 We do publish occasional semantic versions, tagged with
`v${major}.${minor}.${patch}` (e.g. `v1.15.2`). `v${major}.${minor}.${patch}` (e.g. `v1.14.0`).
#### Documentation Updates #### Documentation Updates
@ -17,12 +17,12 @@ Our documentation is now live on GitHub Pages at
https://google.github.io/googletest/. We recommend browsing the documentation on https://google.github.io/googletest/. We recommend browsing the documentation on
GitHub Pages rather than directly in the repository. GitHub Pages rather than directly in the repository.
#### Release 1.15.2 #### Release 1.14.0
[Release 1.15.2](https://github.com/google/googletest/releases/tag/v1.15.2) is [Release 1.14.0](https://github.com/google/googletest/releases/tag/v1.14.0) is
now available. now available.
The 1.15.x branch requires at least C++14. The 1.14.x branch requires at least C++14.
#### Continuous Integration #### Continuous Integration

View File

@ -1,34 +1,4 @@
# Copyright 2024 Google Inc. workspace(name = "com_google_googletest")
# All Rights Reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
workspace(name = "googletest")
load("//:googletest_deps.bzl", "googletest_deps") load("//:googletest_deps.bzl", "googletest_deps")
googletest_deps() googletest_deps()

View File

@ -46,13 +46,8 @@ RMDIR /S /Q cmake_msvc2022
:: ---------------------------------------------------------------------------- :: ----------------------------------------------------------------------------
:: Bazel :: Bazel
:: The default home directory on Kokoro is a long path which causes errors
:: because of Windows limitations on path length.
:: --output_user_root=C:\tmp causes Bazel to use a shorter path.
SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
%BAZEL_EXE% ^ %BAZEL_EXE% test ... ^
--output_user_root=C:\tmp ^
test ... ^
--compilation_mode=dbg ^ --compilation_mode=dbg ^
--copt=/std:c++14 ^ --copt=/std:c++14 ^
--copt=/WX ^ --copt=/WX ^

View File

@ -10,8 +10,8 @@ To complete this tutorial, you'll need:
* A compatible operating system (e.g. Linux, macOS, Windows). * A compatible operating system (e.g. Linux, macOS, Windows).
* A compatible C++ compiler that supports at least C++14. * A compatible C++ compiler that supports at least C++14.
* [Bazel](https://bazel.build/) 7.0 or higher, the preferred build system used * [Bazel](https://bazel.build/), the preferred build system used by the
by the GoogleTest team. GoogleTest team.
See [Supported Platforms](platforms.md) for more information about platforms See [Supported Platforms](platforms.md) for more information about platforms
compatible with GoogleTest. compatible with GoogleTest.
@ -28,7 +28,7 @@ A
[Bazel workspace](https://docs.bazel.build/versions/main/build-ref.html#workspace) [Bazel workspace](https://docs.bazel.build/versions/main/build-ref.html#workspace)
is a directory on your filesystem that you use to manage source files for the is a directory on your filesystem that you use to manage source files for the
software you want to build. Each workspace directory has a text file named software you want to build. Each workspace directory has a text file named
`MODULE.bazel` which may be empty, or may contain references to external `WORKSPACE` which may be empty, or may contain references to external
dependencies required to build the outputs. dependencies required to build the outputs.
First, create a directory for your workspace: First, create a directory for your workspace:
@ -37,20 +37,30 @@ First, create a directory for your workspace:
$ mkdir my_workspace && cd my_workspace $ mkdir my_workspace && cd my_workspace
``` ```
Next, youll create the `MODULE.bazel` file to specify dependencies. As of Bazel Next, youll create the `WORKSPACE` file to specify dependencies. A common and
7.0, the recommended way to consume GoogleTest is through the recommended way to depend on GoogleTest is to use a
[Bazel Central Registry](https://registry.bazel.build/modules/googletest). To do [Bazel external dependency](https://docs.bazel.build/versions/main/external.html)
this, create a `MODULE.bazel` file in the root directory of your Bazel workspace via the
with the following content: [`http_archive` rule](https://docs.bazel.build/versions/main/repo/http.html#http_archive).
To do this, in the root directory of your workspace (`my_workspace/`), create a
file named `WORKSPACE` with the following contents:
``` ```
# MODULE.bazel load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Choose the most recent version available at http_archive(
# https://registry.bazel.build/modules/googletest name = "com_google_googletest",
bazel_dep(name = "googletest", version = "1.15.2") urls = ["https://github.com/google/googletest/archive/5ab508a01f9eb089207ee87fd547d290da39d015.zip"],
strip_prefix = "googletest-5ab508a01f9eb089207ee87fd547d290da39d015",
)
``` ```
The above configuration declares a dependency on GoogleTest which is downloaded
as a ZIP archive from GitHub. In the above example,
`5ab508a01f9eb089207ee87fd547d290da39d015` is the Git commit hash of the
GoogleTest version to use; we recommend updating the hash often to point to the
latest version. Use a recent hash on the `main` branch.
Now you're ready to build C++ code that uses GoogleTest. Now you're ready to build C++ code that uses GoogleTest.
## Create and run a binary ## Create and run a binary
@ -82,20 +92,17 @@ following contents:
``` ```
cc_test( cc_test(
name = "hello_test", name = "hello_test",
size = "small", size = "small",
srcs = ["hello_test.cc"], srcs = ["hello_test.cc"],
deps = [ deps = ["@com_google_googletest//:gtest_main"],
"@googletest//:gtest",
"@googletest//:gtest_main",
],
) )
``` ```
This `cc_test` rule declares the C++ test binary you want to build, and links to This `cc_test` rule declares the C++ test binary you want to build, and links to
the GoogleTest library (`@googletest//:gtest"`) and the GoogleTest `main()` GoogleTest (`//:gtest_main`) using the prefix you specified in the `WORKSPACE`
function (`@googletest//:gtest_main`). For more information about Bazel `BUILD` file (`@com_google_googletest`). For more information about Bazel `BUILD` files,
files, see the see the
[Bazel C++ Tutorial](https://docs.bazel.build/versions/main/tutorial/cpp.html). [Bazel C++ Tutorial](https://docs.bazel.build/versions/main/tutorial/cpp.html).
{: .callout .note} {: .callout .note}
@ -108,7 +115,7 @@ on supported language versions.
Now you can build and run your test: Now you can build and run your test:
<pre> <pre>
<strong>$ bazel test --cxxopt=-std=c++14 --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: Analyzed target //:hello_test (26 packages loaded, 362 targets configured).
INFO: Found 1 test target... INFO: Found 1 test target...
INFO: From Testing //:hello_test: INFO: From Testing //:hello_test:

View File

@ -1493,7 +1493,6 @@ class DoAllAction<FinalAction> {
// providing a call operator because even with a particular set of arguments // providing a call operator because even with a particular set of arguments
// they don't have a fixed return type. // they don't have a fixed return type.
// We support conversion to OnceAction whenever the sub-action does.
template <typename R, typename... Args, template <typename R, typename... Args,
typename std::enable_if< typename std::enable_if<
std::is_convertible<FinalAction, OnceAction<R(Args...)>>::value, std::is_convertible<FinalAction, OnceAction<R(Args...)>>::value,
@ -1502,21 +1501,6 @@ class DoAllAction<FinalAction> {
return std::move(final_action_); return std::move(final_action_);
} }
// We also support conversion to OnceAction whenever the sub-action supports
// conversion to Action (since any Action can also be a OnceAction).
template <
typename R, typename... Args,
typename std::enable_if<
conjunction<
negation<
std::is_convertible<FinalAction, OnceAction<R(Args...)>>>,
std::is_convertible<FinalAction, Action<R(Args...)>>>::value,
int>::type = 0>
operator OnceAction<R(Args...)>() && { // NOLINT
return Action<R(Args...)>(std::move(final_action_));
}
// We support conversion to Action whenever the sub-action does.
template < template <
typename R, typename... Args, typename R, typename... Args,
typename std::enable_if< typename std::enable_if<
@ -1596,16 +1580,16 @@ class DoAllAction<InitialAction, OtherActions...>
: Base({}, std::forward<U>(other_actions)...), : Base({}, std::forward<U>(other_actions)...),
initial_action_(std::forward<T>(initial_action)) {} initial_action_(std::forward<T>(initial_action)) {}
// We support conversion to OnceAction whenever both the initial action and template <typename R, typename... Args,
// the rest support conversion to OnceAction. typename std::enable_if<
template < conjunction<
typename R, typename... Args, // Both the initial action and the rest must support
typename std::enable_if< // conversion to OnceAction.
conjunction<std::is_convertible< std::is_convertible<
InitialAction, InitialAction,
OnceAction<void(InitialActionArgType<Args>...)>>, OnceAction<void(InitialActionArgType<Args>...)>>,
std::is_convertible<Base, OnceAction<R(Args...)>>>::value, std::is_convertible<Base, OnceAction<R(Args...)>>>::value,
int>::type = 0> int>::type = 0>
operator OnceAction<R(Args...)>() && { // NOLINT operator OnceAction<R(Args...)>() && { // NOLINT
// Return an action that first calls the initial action with arguments // Return an action that first calls the initial action with arguments
// filtered through InitialActionArgType, then forwards arguments directly // filtered through InitialActionArgType, then forwards arguments directly
@ -1628,34 +1612,12 @@ class DoAllAction<InitialAction, OtherActions...>
}; };
} }
// We also support conversion to OnceAction whenever the initial action
// supports conversion to Action (since any Action can also be a OnceAction).
//
// The remaining sub-actions must also be compatible, but we don't need to
// special case them because the base class deals with them.
template <
typename R, typename... Args,
typename std::enable_if<
conjunction<
negation<std::is_convertible<
InitialAction,
OnceAction<void(InitialActionArgType<Args>...)>>>,
std::is_convertible<InitialAction,
Action<void(InitialActionArgType<Args>...)>>,
std::is_convertible<Base, OnceAction<R(Args...)>>>::value,
int>::type = 0>
operator OnceAction<R(Args...)>() && { // NOLINT
return DoAll(
Action<void(InitialActionArgType<Args>...)>(std::move(initial_action_)),
std::move(static_cast<Base&>(*this)));
}
// We support conversion to Action whenever both the initial action and the
// rest support conversion to Action.
template < template <
typename R, typename... Args, typename R, typename... Args,
typename std::enable_if< typename std::enable_if<
conjunction< conjunction<
// Both the initial action and the rest must support conversion to
// Action.
std::is_convertible<const InitialAction&, std::is_convertible<const InitialAction&,
Action<void(InitialActionArgType<Args>...)>>, Action<void(InitialActionArgType<Args>...)>>,
std::is_convertible<const Base&, Action<R(Args...)>>>::value, std::is_convertible<const Base&, Action<R(Args...)>>>::value,
@ -1703,9 +1665,8 @@ template <size_t k>
struct ReturnArgAction { struct ReturnArgAction {
template <typename... Args, template <typename... Args,
typename = typename std::enable_if<(k < sizeof...(Args))>::type> typename = typename std::enable_if<(k < sizeof...(Args))>::type>
auto operator()(Args&&... args) const auto operator()(Args&&... args) const -> decltype(std::get<k>(
-> decltype(std::get<k>( std::forward_as_tuple(std::forward<Args>(args)...))) {
std::forward_as_tuple(std::forward<Args>(args)...))) {
return std::get<k>(std::forward_as_tuple(std::forward<Args>(args)...)); return std::get<k>(std::forward_as_tuple(std::forward<Args>(args)...));
} }
}; };

View File

@ -601,10 +601,9 @@ template <std::size_t index, typename... Params>
struct InvokeArgumentAction { struct InvokeArgumentAction {
template <typename... Args, template <typename... Args,
typename = typename std::enable_if<(index < sizeof...(Args))>::type> typename = typename std::enable_if<(index < sizeof...(Args))>::type>
auto operator()(Args &&...args) const auto operator()(Args &&...args) const -> decltype(internal::InvokeArgument(
-> decltype(internal::InvokeArgument( std::get<index>(std::forward_as_tuple(std::forward<Args>(args)...)),
std::get<index>(std::forward_as_tuple(std::forward<Args>(args)...)), std::declval<const Params &>()...)) {
std::declval<const Params &>()...)) {
internal::FlatTuple<Args &&...> args_tuple(FlatTupleConstructTag{}, internal::FlatTuple<Args &&...> args_tuple(FlatTupleConstructTag{},
std::forward<Args>(args)...); std::forward<Args>(args)...);
return params.Apply([&](const Params &...unpacked_params) { return params.Apply([&](const Params &...unpacked_params) {

View File

@ -868,7 +868,7 @@ class GTEST_API_ ExpectationBase {
Clause last_clause_; Clause last_clause_;
mutable bool action_count_checked_; // Under mutex_. mutable bool action_count_checked_; // Under mutex_.
mutable Mutex mutex_; // Protects action_count_checked_. mutable Mutex mutex_; // Protects action_count_checked_.
}; // class ExpectationBase }; // class ExpectationBase
template <typename F> template <typename F>
class TypedExpectation; class TypedExpectation;
@ -1838,8 +1838,9 @@ R FunctionMocker<R(Args...)>::InvokeWith(ArgumentTuple&& args)
// Doing so slows down compilation dramatically because the *constructor* of // Doing so slows down compilation dramatically because the *constructor* of
// std::function<T> is re-instantiated with different template // std::function<T> is re-instantiated with different template
// parameters each time. // parameters each time.
const UninterestingCallCleanupHandler report_uninteresting_call = {reaction, const UninterestingCallCleanupHandler report_uninteresting_call = {
ss}; reaction, ss
};
return PerformActionAndPrintResult(nullptr, std::move(args), ss.str(), ss); return PerformActionAndPrintResult(nullptr, std::move(args), ss.str(), ss);
} }
@ -1889,7 +1890,8 @@ R FunctionMocker<R(Args...)>::InvokeWith(ArgumentTuple&& args)
// std::function<T> is re-instantiated with different template // std::function<T> is re-instantiated with different template
// parameters each time. // parameters each time.
const FailureCleanupHandler handle_failures = { const FailureCleanupHandler handle_failures = {
ss, why, loc, untyped_expectation, found, is_excessive}; ss, why, loc, untyped_expectation, found, is_excessive
};
return PerformActionAndPrintResult(untyped_action, std::move(args), ss.str(), return PerformActionAndPrintResult(untyped_action, std::move(args), ss.str(),
ss); ss);

View File

@ -42,7 +42,6 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <cstdint> #include <cstdint>
#include <iostream> #include <iostream>

View File

@ -53,12 +53,12 @@ class BetweenCardinalityImpl : public CardinalityInterface {
: min_(min >= 0 ? min : 0), max_(max >= min_ ? max : min_) { : min_(min >= 0 ? min : 0), max_(max >= min_ ? max : min_) {
std::stringstream ss; std::stringstream ss;
if (min < 0) { if (min < 0) {
ss << "The invocation lower bound must be >= 0, " << "but is actually " ss << "The invocation lower bound must be >= 0, "
<< min << "."; << "but is actually " << min << ".";
internal::Expect(false, __FILE__, __LINE__, ss.str()); internal::Expect(false, __FILE__, __LINE__, ss.str());
} else if (max < 0) { } else if (max < 0) {
ss << "The invocation upper bound must be >= 0, " << "but is actually " ss << "The invocation upper bound must be >= 0, "
<< max << "."; << "but is actually " << max << ".";
internal::Expect(false, __FILE__, __LINE__, ss.str()); internal::Expect(false, __FILE__, __LINE__, ss.str());
} else if (min > max) { } else if (min > max) {
ss << "The invocation upper bound (" << max ss << "The invocation upper bound (" << max

View File

@ -441,8 +441,8 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_EQ(0, DefaultValue<int>::Get()); EXPECT_EQ(0, DefaultValue<int>::Get());
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<MyNonDefaultConstructible>::Get(); },
{ DefaultValue<MyNonDefaultConstructible>::Get(); }, ""); "");
} }
TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) { TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) {
@ -505,8 +505,8 @@ TEST(DefaultValueOfReferenceDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_FALSE(DefaultValue<MyNonDefaultConstructible&>::IsSet()); EXPECT_FALSE(DefaultValue<MyNonDefaultConstructible&>::IsSet());
EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<int&>::Get(); }, ""); EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<int&>::Get(); }, "");
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<MyNonDefaultConstructible>::Get(); },
{ DefaultValue<MyNonDefaultConstructible>::Get(); }, ""); "");
} }
// Tests that ActionInterface can be implemented by defining the // Tests that ActionInterface can be implemented by defining the
@ -1477,54 +1477,6 @@ TEST(DoAll, SupportsTypeErasedActions) {
} }
} }
// A DoAll action should be convertible to a OnceAction, even when its component
// sub-actions are user-provided types that define only an Action conversion
// operator. If they supposed being called more than once then they also support
// being called at most once.
TEST(DoAll, ConvertibleToOnceActionWithUserProvidedActionConversion) {
// Simplest case: only one sub-action.
struct CustomFinal final {
operator Action<int()>() { // NOLINT
return Return(17);
}
operator Action<int(int, char)>() { // NOLINT
return Return(19);
}
};
{
OnceAction<int()> action = DoAll(CustomFinal{});
EXPECT_EQ(17, std::move(action).Call());
}
{
OnceAction<int(int, char)> action = DoAll(CustomFinal{});
EXPECT_EQ(19, std::move(action).Call(0, 0));
}
// It should also work with multiple sub-actions.
struct CustomInitial final {
operator Action<void()>() { // NOLINT
return [] {};
}
operator Action<void(int, char)>() { // NOLINT
return [] {};
}
};
{
OnceAction<int()> action = DoAll(CustomInitial{}, CustomFinal{});
EXPECT_EQ(17, std::move(action).Call());
}
{
OnceAction<int(int, char)> action = DoAll(CustomInitial{}, CustomFinal{});
EXPECT_EQ(19, std::move(action).Call(0, 0));
}
}
// Tests using WithArgs and with an action that takes 1 argument. // Tests using WithArgs and with an action that takes 1 argument.
TEST(WithArgsTest, OneArg) { TEST(WithArgsTest, OneArg) {
Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary)); // NOLINT Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary)); // NOLINT

View File

@ -36,9 +36,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "gmock/gmock.h"
#include "test/gmock-matchers_test.h" #include "test/gmock-matchers_test.h"
#include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short', // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
// possible loss of data and C4100, unreferenced local parameter // possible loss of data and C4100, unreferenced local parameter

View File

@ -37,14 +37,13 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "gmock/gmock.h"
#include "test/gmock-matchers_test.h" #include "test/gmock-matchers_test.h"
#include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short', // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
// possible loss of data and C4100, unreferenced local parameter // possible loss of data and C4100, unreferenced local parameter
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100)
namespace testing { namespace testing {
namespace gmock_matchers_test { namespace gmock_matchers_test {
namespace { namespace {

View File

@ -43,14 +43,14 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "gmock/gmock.h"
#include "test/gmock-matchers_test.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short', // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
// possible loss of data and C4100, unreferenced local parameter // possible loss of data and C4100, unreferenced local parameter
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100)
#include "test/gmock-matchers_test.h"
namespace testing { namespace testing {
namespace gmock_matchers_test { namespace gmock_matchers_test {
namespace { namespace {

View File

@ -39,14 +39,14 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "gmock/gmock.h"
#include "test/gmock-matchers_test.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
// Silence warning C4244: 'initializing': conversion from 'int' to 'short', // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
// possible loss of data and C4100, unreferenced local parameter // possible loss of data and C4100, unreferenced local parameter
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100)
#include "test/gmock-matchers_test.h"
namespace testing { namespace testing {
namespace gmock_matchers_test { namespace gmock_matchers_test {
namespace { namespace {

View File

@ -186,8 +186,8 @@ using testing::SetErrnoAndReturn;
#endif #endif
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
using testing::Rethrow;
using testing::Throw; using testing::Throw;
using testing::Rethrow;
#endif #endif
using testing::ContainsRegex; using testing::ContainsRegex;

View File

@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts
with with
``` ```
git clone https://github.com/google/googletest.git -b v1.15.2 git clone https://github.com/google/googletest.git -b v1.14.0
cd googletest # Main directory of the cloned repository. cd googletest # Main directory of the cloned repository.
mkdir build # Create a directory to hold the build output. mkdir build # Create a directory to hold the build output.
cd build cd build

View File

@ -6,17 +6,17 @@ load("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")
def googletest_deps(): def googletest_deps():
"""Loads common dependencies needed to use the googletest library.""" """Loads common dependencies needed to use the googletest library."""
if not native.existing_rule("re2"): if not native.existing_rule("com_googlesource_code_re2"):
http_archive( http_archive(
name = "re2", name = "com_googlesource_code_re2",
sha256 = "eb2df807c781601c14a260a507a5bb4509be1ee626024cb45acbd57cb9d4032b", sha256 = "eb2df807c781601c14a260a507a5bb4509be1ee626024cb45acbd57cb9d4032b",
strip_prefix = "re2-2024-07-02", strip_prefix = "re2-2024-07-02",
urls = ["https://github.com/google/re2/releases/download/2024-07-02/re2-2024-07-02.tar.gz"], urls = ["https://github.com/google/re2/releases/download/2024-07-02/re2-2024-07-02.tar.gz"],
) )
if not native.existing_rule("abseil-cpp"): if not native.existing_rule("com_google_absl"):
http_archive( http_archive(
name = "abseil-cpp", name = "com_google_absl",
sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc", sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc",
strip_prefix = "abseil-cpp-20240116.2", strip_prefix = "abseil-cpp-20240116.2",
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.2/abseil-cpp-20240116.2.tar.gz"], urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.2/abseil-cpp-20240116.2.tar.gz"],