aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/googletest/googlemock
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2023-08-19 23:25:59 +0300
committerthegeorg <thegeorg@yandex-team.com>2023-08-20 00:09:53 +0300
commit759857fab05dac463877ff6ef8b8776ff2076f47 (patch)
tree4fe3b988759a9301a8ad04cbd4abc83765d549e3 /contrib/restricted/googletest/googlemock
parentfe66a32be1aa1ad38fecdd32a7c4fd1ba72d3685 (diff)
downloadydb-759857fab05dac463877ff6ef8b8776ff2076f47.tar.gz
Update contrib/restricted/googletest to 1.14.0
Diffstat (limited to 'contrib/restricted/googletest/googlemock')
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-actions.h73
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-cardinalities.h4
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-function-mocker.h5
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-matchers.h35
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-more-actions.h30
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-more-matchers.h14
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-nice-strict.h2
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/gmock-spec-builders.h77
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h17
-rw-r--r--contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-port.h4
-rw-r--r--contrib/restricted/googletest/googlemock/src/gmock-internal-utils.cc10
-rw-r--r--contrib/restricted/googletest/googlemock/src/gmock-matchers.cc2
-rw-r--r--contrib/restricted/googletest/googlemock/src/gmock-spec-builders.cc32
-rw-r--r--contrib/restricted/googletest/googlemock/src/gmock.cc2
14 files changed, 169 insertions, 138 deletions
diff --git a/contrib/restricted/googletest/googlemock/include/gmock/gmock-actions.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-actions.h
index aad07d51cc..bd9ba73ee6 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-actions.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/gmock-actions.h
@@ -146,10 +146,7 @@
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-pp.h"
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4100)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100)
namespace testing {
@@ -614,7 +611,7 @@ class DefaultValue {
private:
class ValueProducer {
public:
- virtual ~ValueProducer() {}
+ virtual ~ValueProducer() = default;
virtual T Produce() = 0;
};
@@ -702,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
@@ -752,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
@@ -1276,7 +1273,7 @@ class AssignAction {
const T2 value_;
};
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
// Implements the SetErrnoAndReturn action to simulate return from
// various system calls and libc functions.
@@ -1420,19 +1417,19 @@ struct WithArgsAction {
// providing a call operator because even with a particular set of arguments
// they don't have a fixed return type.
- template <typename R, typename... Args,
- typename std::enable_if<
- std::is_convertible<
- InnerAction,
- // Unfortunately we can't use the InnerSignature alias here;
- // MSVC complains about the I parameter pack not being
- // expanded (error C3520) despite it being expanded in the
- // type alias.
- // TupleElement is also an MSVC workaround.
- // See its definition for details.
- OnceAction<R(internal::TupleElement<
- I, std::tuple<Args...>>...)>>::value,
- int>::type = 0>
+ template <
+ typename R, typename... Args,
+ typename std::enable_if<
+ std::is_convertible<InnerAction,
+ // Unfortunately we can't use the InnerSignature
+ // alias here; MSVC complains about the I
+ // parameter pack not being expanded (error C3520)
+ // despite it being expanded in the type alias.
+ // TupleElement is also an MSVC workaround.
+ // See its definition for details.
+ OnceAction<R(internal::TupleElement<
+ I, std::tuple<Args...>>...)>>::value,
+ int>::type = 0>
operator OnceAction<R(Args...)>() && { // NOLINT
struct OA {
OnceAction<InnerSignature<R, Args...>> inner_action;
@@ -1447,19 +1444,19 @@ struct WithArgsAction {
return OA{std::move(inner_action)};
}
- template <typename R, typename... Args,
- typename std::enable_if<
- std::is_convertible<
- const InnerAction&,
- // Unfortunately we can't use the InnerSignature alias here;
- // MSVC complains about the I parameter pack not being
- // expanded (error C3520) despite it being expanded in the
- // type alias.
- // TupleElement is also an MSVC workaround.
- // See its definition for details.
- Action<R(internal::TupleElement<
- I, std::tuple<Args...>>...)>>::value,
- int>::type = 0>
+ template <
+ typename R, typename... Args,
+ typename std::enable_if<
+ std::is_convertible<const InnerAction&,
+ // Unfortunately we can't use the InnerSignature
+ // alias here; MSVC complains about the I
+ // parameter pack not being expanded (error C3520)
+ // despite it being expanded in the type alias.
+ // TupleElement is also an MSVC workaround.
+ // See its definition for details.
+ Action<R(internal::TupleElement<
+ I, std::tuple<Args...>>...)>>::value,
+ int>::type = 0>
operator Action<R(Args...)>() const { // NOLINT
Action<InnerSignature<R, Args...>> converted(inner_action);
@@ -1929,7 +1926,7 @@ PolymorphicAction<internal::AssignAction<T1, T2>> Assign(T1* ptr, T2 val) {
return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
}
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
// Creates an action that sets errno and returns the appropriate error.
template <typename T>
@@ -2295,8 +2292,6 @@ template <typename F, typename Impl>
} // namespace testing
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
diff --git a/contrib/restricted/googletest/googlemock/include/gmock/gmock-cardinalities.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-cardinalities.h
index b6ab648e50..533e604f32 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-cardinalities.h
+++ b/contrib/restricted/googletest/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/contrib/restricted/googletest/googlemock/include/gmock/gmock-function-mocker.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-function-mocker.h
index 73065493b3..1a1f126e49 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-function-mocker.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/gmock-function-mocker.h
@@ -180,8 +180,9 @@ using internal::FunctionMocker;
_Signature)>::Result \
GMOCK_INTERNAL_EXPAND(_CallType) \
_MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N)) \
- GMOCK_PP_IF(_Constness, const, ) _RefSpec _NoexceptSpec \
- GMOCK_PP_IF(_Override, override, ) GMOCK_PP_IF(_Final, final, ) { \
+ GMOCK_PP_IF(_Constness, const, ) \
+ _RefSpec _NoexceptSpec GMOCK_PP_IF(_Override, override, ) \
+ GMOCK_PP_IF(_Final, final, ) { \
GMOCK_MOCKER_(_N, _Constness, _MethodName) \
.SetOwnerAndName(this, #_MethodName); \
return GMOCK_MOCKER_(_N, _Constness, _MethodName) \
diff --git a/contrib/restricted/googletest/googlemock/include/gmock/gmock-matchers.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-matchers.h
index 9e634f7f1c..0f67713776 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-matchers.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/gmock-matchers.h
@@ -257,6 +257,8 @@
#include <algorithm>
#include <cmath>
+#include <exception>
+#include <functional>
#include <initializer_list>
#include <ios>
#include <iterator>
@@ -562,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;
}
}
@@ -1199,27 +1201,27 @@ class PairMatchBase {
};
};
-class Eq2Matcher : public PairMatchBase<Eq2Matcher, AnyEq> {
+class Eq2Matcher : public PairMatchBase<Eq2Matcher, std::equal_to<>> {
public:
static const char* Desc() { return "an equal pair"; }
};
-class Ne2Matcher : public PairMatchBase<Ne2Matcher, AnyNe> {
+class Ne2Matcher : public PairMatchBase<Ne2Matcher, std::not_equal_to<>> {
public:
static const char* Desc() { return "an unequal pair"; }
};
-class Lt2Matcher : public PairMatchBase<Lt2Matcher, AnyLt> {
+class Lt2Matcher : public PairMatchBase<Lt2Matcher, std::less<>> {
public:
static const char* Desc() { return "a pair where the first < the second"; }
};
-class Gt2Matcher : public PairMatchBase<Gt2Matcher, AnyGt> {
+class Gt2Matcher : public PairMatchBase<Gt2Matcher, std::greater<>> {
public:
static const char* Desc() { return "a pair where the first > the second"; }
};
-class Le2Matcher : public PairMatchBase<Le2Matcher, AnyLe> {
+class Le2Matcher : public PairMatchBase<Le2Matcher, std::less_equal<>> {
public:
static const char* Desc() { return "a pair where the first <= the second"; }
};
-class Ge2Matcher : public PairMatchBase<Ge2Matcher, AnyGe> {
+class Ge2Matcher : public PairMatchBase<Ge2Matcher, std::greater_equal<>> {
public:
static const char* Desc() { return "a pair where the first >= the second"; }
};
@@ -1473,6 +1475,7 @@ class SomeOfArrayMatcher {
operator Matcher<U>() const { // NOLINT
using RawU = typename std::decay<U>::type;
std::vector<Matcher<RawU>> matchers;
+ matchers.reserve(matchers_.size());
for (const auto& matcher : matchers_) {
matchers.push_back(MatcherCast<RawU>(matcher));
}
@@ -2964,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;
@@ -3111,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 ";
@@ -3317,8 +3320,8 @@ class FieldsAreMatcherImpl<Struct, IndexSequence<I...>>
std::vector<StringMatchResultListener> inner_listener(sizeof...(I));
VariadicExpand(
- {failed_pos == ~size_t{}&& !std::get<I>(matchers_).MatchAndExplain(
- std::get<I>(tuple), &inner_listener[I])
+ {failed_pos == ~size_t{} && !std::get<I>(matchers_).MatchAndExplain(
+ std::get<I>(tuple), &inner_listener[I])
? failed_pos = I
: 0 ...});
if (failed_pos != ~size_t{}) {
@@ -5474,8 +5477,7 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \
- name \
- GMOCK_INTERNAL_WARNING_POP()() { \
+ name GMOCK_INTERNAL_WARNING_POP()() { \
return {}; \
} \
template <typename arg_type> \
@@ -5543,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/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-actions.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-actions.h
index 148ac01721..40300766f0 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-actions.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-actions.h
@@ -526,9 +526,10 @@
GMOCK_INTERNAL_LIST_##value_params)){}) \
GMOCK_ACTION_CLASS_(name, value_params)(const GMOCK_ACTION_CLASS_( \
name, value_params) &) noexcept GMOCK_INTERNAL_DEFN_COPY_ \
- ##value_params GMOCK_ACTION_CLASS_(name, value_params)( \
- GMOCK_ACTION_CLASS_(name, value_params) &&) noexcept \
- GMOCK_INTERNAL_DEFN_COPY_##value_params template <typename F> \
+ ##value_params \
+ GMOCK_ACTION_CLASS_(name, value_params)(GMOCK_ACTION_CLASS_( \
+ name, value_params) &&) noexcept GMOCK_INTERNAL_DEFN_COPY_ \
+ ##value_params template <typename F> \
operator ::testing::Action<F>() const { \
return GMOCK_PP_IF( \
GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
@@ -582,10 +583,7 @@ namespace testing {
// the macro definition, as the warnings are generated when the macro
// is expanded and macro expansion cannot contain #pragma. Therefore
// we suppress them here.
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4100)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100)
namespace internal {
@@ -602,13 +600,13 @@ template <std::size_t index, typename... Params>
struct InvokeArgumentAction {
template <typename... Args,
typename = typename std::enable_if<(index < sizeof...(Args))>::type>
- auto operator()(Args&&... args) const -> decltype(internal::InvokeArgument(
+ auto operator()(Args &&...args) const -> decltype(internal::InvokeArgument(
std::get<index>(std::forward_as_tuple(std::forward<Args>(args)...)),
- std::declval<const Params&>()...)) {
- internal::FlatTuple<Args&&...> args_tuple(FlatTupleConstructTag{},
- std::forward<Args>(args)...);
- return params.Apply([&](const Params&... unpacked_params) {
- auto&& callable = args_tuple.template Get<index>();
+ std::declval<const Params &>()...)) {
+ internal::FlatTuple<Args &&...> args_tuple(FlatTupleConstructTag{},
+ std::forward<Args>(args)...);
+ return params.Apply([&](const Params &...unpacked_params) {
+ auto &&callable = args_tuple.template Get<index>();
return internal::InvokeArgument(
std::forward<decltype(callable)>(callable), unpacked_params...);
});
@@ -648,14 +646,12 @@ struct InvokeArgumentAction {
// later.
template <std::size_t index, typename... Params>
internal::InvokeArgumentAction<index, typename std::decay<Params>::type...>
-InvokeArgument(Params&&... params) {
+InvokeArgument(Params &&...params) {
return {internal::FlatTuple<typename std::decay<Params>::type...>(
internal::FlatTupleConstructTag{}, std::forward<Params>(params)...)};
}
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100
} // namespace testing
diff --git a/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-matchers.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-matchers.h
index d9a9210738..54ea68be96 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-matchers.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/gmock-more-matchers.h
@@ -49,14 +49,11 @@ namespace testing {
// Silence C4100 (unreferenced formal
// parameter) for MSVC
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4100)
-#if (_MSC_VER == 1900)
+GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100)
+#if defined(_MSC_VER) && (_MSC_VER == 1900)
// and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14
-#pragma warning(disable : 4800)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800)
#endif
namespace internal {
@@ -113,9 +110,10 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
return !static_cast<bool>(arg);
}
-#ifdef _MSC_VER
-#pragma warning(pop)
+#if defined(_MSC_VER) && (_MSC_VER == 1900)
+GTEST_DISABLE_MSC_WARNINGS_POP_() // 4800
#endif
+GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100
} // namespace testing
diff --git a/contrib/restricted/googletest/googlemock/include/gmock/gmock-nice-strict.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-nice-strict.h
index 4f0eb35db7..056d471417 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-nice-strict.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/gmock-nice-strict.h
@@ -98,7 +98,7 @@ constexpr bool HasStrictnessModifier() {
// deregistration. This guarantees that MockClass's constructor and destructor
// run with the same level of strictness as its instance methods.
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW && \
+#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW) && \
(defined(_MSC_VER) || defined(__clang__))
// We need to mark these classes with this declspec to ensure that
// the empty base class optimization is performed.
diff --git a/contrib/restricted/googletest/googlemock/include/gmock/gmock-spec-builders.h b/contrib/restricted/googletest/googlemock/include/gmock/gmock-spec-builders.h
index 4e498d8f54..78ca15d05e 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/gmock-spec-builders.h
+++ b/contrib/restricted/googletest/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/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h b/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h
index 36ab8e26a8..ead6d7c805 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -58,11 +58,7 @@ namespace internal {
// Silence MSVC C4100 (unreferenced formal parameter) and
// C4805('==': unsafe mix of type 'const int' and type 'const bool')
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4100)
-#pragma warning(disable : 4805)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100 4805)
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string.
@@ -228,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,
@@ -315,7 +311,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers();
// crashes).
template <typename T>
inline T Invalid() {
- Assert(false, "", -1, "Internal error: attempt to return invalid value");
+ Assert(/*condition=*/false, /*file=*/"", /*line=*/-1,
+ "Internal error: attempt to return invalid value");
#if defined(__GNUC__) || defined(__clang__)
__builtin_unreachable();
#elif defined(_MSC_VER)
@@ -468,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.
@@ -480,9 +479,7 @@ using TupleElement = typename std::tuple_element<I, T>::type;
bool Base64Unescape(const std::string& encoded, std::string* decoded);
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
+GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 4805
} // namespace internal
} // namespace testing
diff --git a/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-port.h b/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-port.h
index f399e28b49..0fe58798d4 100644
--- a/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-port.h
+++ b/contrib/restricted/googletest/googlemock/include/gmock/internal/gmock-port.h
@@ -56,7 +56,7 @@
#include "gmock/internal/custom/gmock-port.h"
#include "gtest/internal/gtest-port.h"
-#if GTEST_HAS_ABSL
+#ifdef GTEST_HAS_ABSL
#error #include "absl/flags/declare.h"
#error #include "absl/flags/flag.h"
#endif
@@ -73,7 +73,7 @@
#define GMOCK_FLAG(name) FLAGS_gmock_##name
// Pick a command line flags implementation.
-#if GTEST_HAS_ABSL
+#ifdef GTEST_HAS_ABSL
// Macros for defining flags.
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
diff --git a/contrib/restricted/googletest/googlemock/src/gmock-internal-utils.cc b/contrib/restricted/googletest/googlemock/src/gmock-internal-utils.cc
index 7bfff02a33..5c2ce0d57e 100644
--- a/contrib/restricted/googletest/googlemock/src/gmock-internal-utils.cc
+++ b/contrib/restricted/googletest/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>
@@ -87,7 +88,7 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
(!IsDigit(prev_char) && IsDigit(*p));
if (IsAlNum(*p)) {
- if (starts_new_word && result != "") result += ' ';
+ if (starts_new_word && !result.empty()) result += ' ';
result += ToLower(*p);
}
}
@@ -198,6 +199,10 @@ GTEST_API_ void IllegalDoDefault(const char* file, int line) {
"the variable in various places.");
}
+constexpr char UndoWebSafeEncoding(char c) {
+ return c == '-' ? '+' : c == '_' ? '/' : c;
+}
+
constexpr char UnBase64Impl(char c, const char* const base64, char carry) {
return *base64 == 0 ? static_cast<char>(65)
: *base64 == c
@@ -208,7 +213,8 @@ constexpr char UnBase64Impl(char c, const char* const base64, char carry) {
template <size_t... I>
constexpr std::array<char, 256> UnBase64Impl(IndexSequence<I...>,
const char* const base64) {
- return {{UnBase64Impl(static_cast<char>(I), base64, 0)...}};
+ return {
+ {UnBase64Impl(UndoWebSafeEncoding(static_cast<char>(I)), base64, 0)...}};
}
constexpr std::array<char, 256> UnBase64(const char* const base64) {
diff --git a/contrib/restricted/googletest/googlemock/src/gmock-matchers.cc b/contrib/restricted/googletest/googlemock/src/gmock-matchers.cc
index 5810b6aa39..07bba4f010 100644
--- a/contrib/restricted/googletest/googlemock/src/gmock-matchers.cc
+++ b/contrib/restricted/googletest/googlemock/src/gmock-matchers.cc
@@ -53,7 +53,7 @@ GTEST_API_ std::string FormatMatcherDescription(
bool negation, const char* matcher_name,
const std::vector<const char*>& param_names, const Strings& param_values) {
std::string result = ConvertIdentifierNameToWords(matcher_name);
- if (param_values.size() >= 1) {
+ if (!param_values.empty()) {
result += " " + JoinAsKeyValueTuple(param_names, param_values);
}
return negation ? "not (" + result + ")" : result;
diff --git a/contrib/restricted/googletest/googlemock/src/gmock-spec-builders.cc b/contrib/restricted/googletest/googlemock/src/gmock-spec-builders.cc
index 7cc3bcc28d..a1d8a6ebd5 100644
--- a/contrib/restricted/googletest/googlemock/src/gmock-spec-builders.cc
+++ b/contrib/restricted/googletest/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>
@@ -48,20 +49,17 @@
#include "gtest/gtest.h"
#include "gtest/internal/gtest-port.h"
-#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
+#if defined(GTEST_OS_CYGWIN) || defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC)
#include <unistd.h> // NOLINT
#endif
-#if GTEST_OS_QURT
+#ifdef GTEST_OS_QURT
#error #include <qurt_event.h>
#endif
// Silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 15
-#ifdef _MSC_VER
-#if _MSC_VER == 1900
-#pragma warning(push)
-#pragma warning(disable : 4800)
-#endif
+#if defined(_MSC_VER) && (_MSC_VER == 1900)
+GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800)
#endif
namespace testing {
@@ -98,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.
@@ -300,7 +298,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) {
"See "
"https://github.com/google/googletest/blob/main/docs/"
"gmock_cook_book.md#"
- "knowing-when-to-expect for details.\n",
+ "knowing-when-to-expect-useoncall for details.\n",
stack_frames_to_skip);
break;
default: // FAIL
@@ -311,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
@@ -506,7 +504,7 @@ class MockObjectRegistry {
std::cout << internal::FormatFileLocation(state.first_used_file,
state.first_used_line);
std::cout << " ERROR: this mock object";
- if (state.first_used_test != "") {
+ if (!state.first_used_test.empty()) {
std::cout << " (used in test " << state.first_used_test_suite << "."
<< state.first_used_test << ")";
}
@@ -529,7 +527,7 @@ class MockObjectRegistry {
// RUN_ALL_TESTS() has already returned when this destructor is
// called. Therefore we cannot use the normal Google Test
// failure reporting mechanism.
-#if GTEST_OS_QURT
+#ifdef GTEST_OS_QURT
qurt_exception_raise_fatal();
#else
_exit(1); // We cannot call exit() as it is not reentrant and
@@ -748,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 {
@@ -788,8 +786,6 @@ InSequence::~InSequence() {
} // namespace testing
-#ifdef _MSC_VER
-#if _MSC_VER == 1900
-#pragma warning(pop)
-#endif
+#if defined(_MSC_VER) && (_MSC_VER == 1900)
+GTEST_DISABLE_MSC_WARNINGS_POP_() // 4800
#endif
diff --git a/contrib/restricted/googletest/googlemock/src/gmock.cc b/contrib/restricted/googletest/googlemock/src/gmock.cc
index 5025656a02..b5e714da7d 100644
--- a/contrib/restricted/googletest/googlemock/src/gmock.cc
+++ b/contrib/restricted/googletest/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,