aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/docs/cook_book.md37
-rw-r--r--googlemock/include/gmock/gmock-actions.h40
-rw-r--r--googlemock/include/gmock/gmock-generated-actions.h127
-rw-r--r--googlemock/include/gmock/gmock-generated-actions.h.pump48
-rw-r--r--googlemock/include/gmock/gmock-spec-builders.h8
-rw-r--r--googlemock/test/gmock-generated-matchers_test.cc9
6 files changed, 58 insertions, 211 deletions
diff --git a/googlemock/docs/cook_book.md b/googlemock/docs/cook_book.md
index ea55ab35..a4935214 100644
--- a/googlemock/docs/cook_book.md
+++ b/googlemock/docs/cook_book.md
@@ -1024,9 +1024,8 @@ using ::testing::Lt;
says that the first argument of `InRange()` must not be 0, and must be less than
the second argument.
-The expression inside `With()` must be a matcher of type
-`Matcher< ::std::tuple<A1, ..., An> >`, where `A1`, ..., `An` are the types of
-the function arguments.
+The expression inside `With()` must be a matcher of type `Matcher<std::tuple<A1,
+..., An>>`, where `A1`, ..., `An` are the types of the function arguments.
You can also write `AllArgs(m)` instead of `m` inside `.With()`. The two forms
are equivalent, but `.With(AllArgs(Lt()))` is more readable than `.With(Lt())`.
@@ -1054,8 +1053,8 @@ complete list.
Note that if you want to pass the arguments to a predicate of your own (e.g.
`.With(Args<0, 1>(Truly(&MyPredicate)))`), that predicate MUST be written to
-take a `::std::tuple` as its argument; gMock will pass the `n` selected
-arguments as *one* single tuple to the predicate.
+take a `std::tuple` as its argument; gMock will pass the `n` selected arguments
+as *one* single tuple to the predicate.
### Using Matchers as Predicates
@@ -1331,11 +1330,11 @@ class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
return (foo.bar() + foo.baz()) == expected_sum_;
}
- void DescribeTo(::std::ostream* os) const override {
+ void DescribeTo(std::ostream* os) const override {
*os << "bar() + baz() equals " << expected_sum_;
}
- void DescribeNegationTo(::std::ostream* os) const override {
+ void DescribeNegationTo(std::ostream* os) const override {
*os << "bar() + baz() does not equal " << expected_sum_;
}
private:
@@ -2203,7 +2202,7 @@ class Helper {
.WillOnce(&CalculateSum)
.WillRepeatedly(Invoke(NewPermanentCallback(Sum3, 1)));
EXPECT_CALL(foo, ComplexJob(_))
- .WillOnce(Invoke(&helper, &Helper::ComplexJob));
+ .WillOnce(Invoke(&helper, &Helper::ComplexJob))
.WillRepeatedly([](int x) { return x > 0; });
foo.Sum(5, 6); // Invokes CalculateSum(5, 6).
@@ -3565,7 +3564,7 @@ class MatchResultListener {
MatchResultListener& operator<<(const T& x);
// Returns the underlying ostream.
- ::std::ostream* stream();
+ std::ostream* stream();
};
template <typename T>
@@ -3578,10 +3577,10 @@ class MatcherInterface {
virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
// Describes this matcher to an ostream.
- virtual void DescribeTo(::std::ostream* os) const = 0;
+ virtual void DescribeTo(std::ostream* os) const = 0;
// Describes the negation of this matcher to an ostream.
- virtual void DescribeNegationTo(::std::ostream* os) const;
+ virtual void DescribeNegationTo(std::ostream* os) const;
};
```
@@ -3609,11 +3608,11 @@ class DivisibleBy7Matcher : public MatcherInterface<int> {
return (n % 7) == 0;
}
- void DescribeTo(::std::ostream* os) const override {
+ void DescribeTo(std::ostream* os) const override {
*os << "is divisible by 7";
}
- void DescribeNegationTo(::std::ostream* os) const override {
+ void DescribeNegationTo(std::ostream* os) const override {
*os << "is not divisible by 7";
}
};
@@ -3995,7 +3994,7 @@ ACTION_TEMPLATE(DuplicateArg,
// Note the comma between int and k:
HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
AND_1_VALUE_PARAMS(output)) {
- *output = T(::std::get<k>(args));
+ *output = T(std::get<k>(args));
}
```
@@ -4087,7 +4086,7 @@ class ActionInterface {
//
// For example, if F is int(bool, const string&), then Result would
- // be int, and ArgumentTuple would be ::std::tuple<bool, const string&>.
+ // be int, and ArgumentTuple would be std::tuple<bool, const string&>.
virtual Result Perform(const ArgumentTuple& args) = 0;
};
```
@@ -4102,8 +4101,8 @@ typedef int IncrementMethod(int*);
class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
public:
- int Perform(const ::std::tuple<int*>& args) override {
- int* p = ::std::get<0>(args); // Grabs the first argument.
+ int Perform(const std::tuple<int*>& args) override {
+ int* p = std::get<0>(args); // Grabs the first argument.
return *p++;
}
};
@@ -4148,8 +4147,8 @@ class ReturnSecondArgumentAction {
public:
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) const {
- // To get the i-th (0-based) argument, use ::std::get(args).
- return ::std::get<1>(args);
+ // To get the i-th (0-based) argument, use std::get(args).
+ return std::get<1>(args);
}
};
```
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index c08d97b9..4b8dcebb 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -1184,6 +1184,46 @@ inline ::std::reference_wrapper<T> ByRef(T& l_value) { // NOLINT
return ::std::reference_wrapper<T>(l_value);
}
+namespace internal {
+
+// A macro from the ACTION* family (defined later in gmock-generated-actions.h)
+// defines an action that can be used in a mock function. Typically,
+// these actions only care about a subset of the arguments of the mock
+// function. For example, if such an action only uses the second
+// argument, it can be used in any mock function that takes >= 2
+// arguments where the type of the second argument is compatible.
+//
+// Therefore, the action implementation must be prepared to take more
+// arguments than it needs. The ExcessiveArg type is used to
+// represent those excessive arguments. In order to keep the compiler
+// error messages tractable, we define it in the testing namespace
+// instead of testing::internal. However, this is an INTERNAL TYPE
+// and subject to change without notice, so a user MUST NOT USE THIS
+// TYPE DIRECTLY.
+struct ExcessiveArg {};
+
+// A helper class needed for implementing the ACTION* macros.
+template <typename Result, class Impl>
+class ActionHelper {
+ public:
+ template <typename... Ts>
+ static Result Perform(Impl* impl, const std::tuple<Ts...>& args) {
+ return Apply(impl, args, MakeIndexSequence<sizeof...(Ts)>{},
+ MakeIndexSequence<10 - sizeof...(Ts)>{});
+ }
+
+ private:
+ template <typename... Ts, std::size_t... tuple_ids, std::size_t... rest_ids>
+ static Result Apply(Impl* impl, const std::tuple<Ts...>& args,
+ IndexSequence<tuple_ids...>, IndexSequence<rest_ids...>) {
+ return impl->template gmock_PerformImpl<Ts...>(
+ args, std::get<tuple_ids>(args)...,
+ ((void)rest_ids, ExcessiveArg())...);
+ }
+};
+
+} // namespace internal
+
} // namespace testing
#ifdef _MSC_VER
diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h
index 5bb62667..20b78cd4 100644
--- a/googlemock/include/gmock/gmock-generated-actions.h
+++ b/googlemock/include/gmock/gmock-generated-actions.h
@@ -47,133 +47,6 @@
#include "gmock/gmock-actions.h"
#include "gmock/internal/gmock-port.h"
-namespace testing {
-namespace internal {
-
-// A macro from the ACTION* family (defined later in this file)
-// defines an action that can be used in a mock function. Typically,
-// these actions only care about a subset of the arguments of the mock
-// function. For example, if such an action only uses the second
-// argument, it can be used in any mock function that takes >= 2
-// arguments where the type of the second argument is compatible.
-//
-// Therefore, the action implementation must be prepared to take more
-// arguments than it needs. The ExcessiveArg type is used to
-// represent those excessive arguments. In order to keep the compiler
-// error messages tractable, we define it in the testing namespace
-// instead of testing::internal. However, this is an INTERNAL TYPE
-// and subject to change without notice, so a user MUST NOT USE THIS
-// TYPE DIRECTLY.
-struct ExcessiveArg {};
-
-// A helper class needed for implementing the ACTION* macros.
-template <typename Result, class Impl>
-class ActionHelper {
- public:
- static Result Perform(Impl* impl, const ::std::tuple<>& args) {
- return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg());
- }
-
- template <typename A0>
- static Result Perform(Impl* impl, const ::std::tuple<A0>& args) {
- return impl->template gmock_PerformImpl<A0>(args, std::get<0>(args),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg());
- }
-
- template <typename A0, typename A1>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1>& args) {
- return impl->template gmock_PerformImpl<A0, A1>(args, std::get<0>(args),
- std::get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2>(args,
- std::get<0>(args), std::get<1>(args), std::get<2>(args),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2, typename A3>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args,
- std::get<0>(args), std::get<1>(args), std::get<2>(args),
- std::get<3>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2, typename A3, typename A4>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3,
- A4>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
- std::get<0>(args), std::get<1>(args), std::get<2>(args),
- std::get<3>(args), std::get<4>(args), ExcessiveArg(), ExcessiveArg(),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2, typename A3, typename A4,
- typename A5>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4,
- A5>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
- std::get<0>(args), std::get<1>(args), std::get<2>(args),
- std::get<3>(args), std::get<4>(args), std::get<5>(args),
- ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
- A6>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
- std::get<0>(args), std::get<1>(args), std::get<2>(args),
- std::get<3>(args), std::get<4>(args), std::get<5>(args),
- std::get<6>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
- A6, A7>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
- A7>(args, std::get<0>(args), std::get<1>(args), std::get<2>(args),
- std::get<3>(args), std::get<4>(args), std::get<5>(args),
- std::get<6>(args), std::get<7>(args), ExcessiveArg(), ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7, typename A8>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
- A6, A7, A8>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
- A8>(args, std::get<0>(args), std::get<1>(args), std::get<2>(args),
- std::get<3>(args), std::get<4>(args), std::get<5>(args),
- std::get<6>(args), std::get<7>(args), std::get<8>(args),
- ExcessiveArg());
- }
-
- template <typename A0, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7, typename A8, typename A9>
- static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
- A6, A7, A8, A9>& args) {
- return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
- A9>(args, std::get<0>(args), std::get<1>(args), std::get<2>(args),
- std::get<3>(args), std::get<4>(args), std::get<5>(args),
- std::get<6>(args), std::get<7>(args), std::get<8>(args),
- std::get<9>(args));
- }
-};
-
-} // namespace internal
-} // namespace testing
-
// The ACTION* family of macros can be used in a namespace scope to
// define custom actions easily. The syntax:
//
diff --git a/googlemock/include/gmock/gmock-generated-actions.h.pump b/googlemock/include/gmock/gmock-generated-actions.h.pump
index 1fa5e776..1121fbde 100644
--- a/googlemock/include/gmock/gmock-generated-actions.h.pump
+++ b/googlemock/include/gmock/gmock-generated-actions.h.pump
@@ -49,54 +49,6 @@ $$}} This meta comment fixes auto-indentation in editors.
#include "gmock/gmock-actions.h"
#include "gmock/internal/gmock-port.h"
-namespace testing {
-namespace internal {
-
-// A macro from the ACTION* family (defined later in this file)
-// defines an action that can be used in a mock function. Typically,
-// these actions only care about a subset of the arguments of the mock
-// function. For example, if such an action only uses the second
-// argument, it can be used in any mock function that takes >= 2
-// arguments where the type of the second argument is compatible.
-//
-// Therefore, the action implementation must be prepared to take more
-// arguments than it needs. The ExcessiveArg type is used to
-// represent those excessive arguments. In order to keep the compiler
-// error messages tractable, we define it in the testing namespace
-// instead of testing::internal. However, this is an INTERNAL TYPE
-// and subject to change without notice, so a user MUST NOT USE THIS
-// TYPE DIRECTLY.
-struct ExcessiveArg {};
-
-// A helper class needed for implementing the ACTION* macros.
-template <typename Result, class Impl>
-class ActionHelper {
- public:
-$range i 0..n
-$for i
-
-[[
-$var template = [[$if i==0 [[]] $else [[
-$range j 0..i-1
- template <$for j, [[typename A$j]]>
-]]]]
-$range j 0..i-1
-$var As = [[$for j, [[A$j]]]]
-$var as = [[$for j, [[std::get<$j>(args)]]]]
-$range k 1..n-i
-$var eas = [[$for k, [[ExcessiveArg()]]]]
-$var arg_list = [[$if (i==0) | (i==n) [[$as$eas]] $else [[$as, $eas]]]]
-$template
- static Result Perform(Impl* impl, const ::std::tuple<$As>& args) {
- return impl->template gmock_PerformImpl<$As>(args, $arg_list);
- }
-
-]]
-};
-
-} // namespace internal
-} // namespace testing
-
// The ACTION* family of macros can be used in a namespace scope to
// define custom actions easily. The syntax:
//
diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h
index 80c13b55..718c9484 100644
--- a/googlemock/include/gmock/gmock-spec-builders.h
+++ b/googlemock/include/gmock/gmock-spec-builders.h
@@ -1350,12 +1350,6 @@ class ReferenceOrValueWrapper<T&> {
T* value_ptr_;
};
-// MSVC warns about using 'this' in base member initializer list, so
-// we need to temporarily disable the warning. We have to do it for
-// the entire class to suppress the warning, even though it's about
-// the constructor only.
-GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355)
-
// C++ treats the void type specially. For example, you cannot define
// a void-typed variable or pass a void value to a function.
// ActionResultHolder<T> holds a value of type T, where T must be a
@@ -1786,8 +1780,6 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
}
}; // class FunctionMocker
-GTEST_DISABLE_MSC_WARNINGS_POP_() // 4355
-
// Reports an uninteresting call (whose description is in msg) in the
// manner specified by 'reaction'.
void ReportUninterestingCall(CallReaction reaction, const std::string& msg);
diff --git a/googlemock/test/gmock-generated-matchers_test.cc b/googlemock/test/gmock-generated-matchers_test.cc
index f3f49a68..6783f8f8 100644
--- a/googlemock/test/gmock-generated-matchers_test.cc
+++ b/googlemock/test/gmock-generated-matchers_test.cc
@@ -392,13 +392,6 @@ TEST(ElementsAreTest, AcceptsStringLiteral) {
EXPECT_THAT(array, Not(ElementsAre("hi", "one", "too")));
}
-#ifndef _MSC_VER
-
-// The following test passes a value of type const char[] to a
-// function template that expects const T&. Some versions of MSVC
-// generates a compiler error C2665 for that. We believe it's a bug
-// in MSVC. Therefore this test is #if-ed out for MSVC.
-
// Declared here with the size unknown. Defined AFTER the following test.
extern const char kHi[];
@@ -415,8 +408,6 @@ TEST(ElementsAreTest, AcceptsArrayWithUnknownSize) {
const char kHi[] = "hi";
-#endif // _MSC_VER
-
TEST(ElementsAreTest, MakesCopyOfArguments) {
int x = 1;
int y = 2;