summaryrefslogtreecommitdiffstats
path: root/googlemock/include
diff options
context:
space:
mode:
Diffstat (limited to 'googlemock/include')
-rw-r--r--googlemock/include/gmock/gmock-function-mocker.h29
-rw-r--r--googlemock/include/gmock/gmock-generated-actions.h24
-rw-r--r--googlemock/include/gmock/gmock-generated-actions.h.pump4
-rw-r--r--googlemock/include/gmock/gmock-generated-matchers.h88
-rw-r--r--googlemock/include/gmock/gmock-generated-matchers.h.pump8
-rw-r--r--googlemock/include/gmock/gmock-matchers.h32
-rw-r--r--googlemock/include/gmock/internal/gmock-internal-utils.h97
-rw-r--r--googlemock/include/gmock/internal/gmock-pp.h29
8 files changed, 155 insertions, 156 deletions
diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h
index cc1535c..684db13 100644
--- a/googlemock/include/gmock/gmock-function-mocker.h
+++ b/googlemock/include/gmock/gmock-function-mocker.h
@@ -39,6 +39,13 @@
#include "gmock/gmock-generated-function-mockers.h" // NOLINT
#include "gmock/internal/gmock-pp.h"
+namespace testing {
+namespace internal {
+template <typename T>
+using identity_t = T;
+} // namespace internal
+} // namespace testing
+
#define MOCK_METHOD(...) \
GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__)
@@ -207,10 +214,24 @@
#define GMOCK_INTERNAL_IS_CALLTYPE_HELPER_Calltype
-#define GMOCK_INTERNAL_SIGNATURE(_Ret, _Args) \
- GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_Ret), GMOCK_PP_REMOVE_PARENS, \
- GMOCK_PP_IDENTITY) \
- (_Ret)(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_TYPE, _, _Args))
+// Note: The use of `identity_t` here allows _Ret to represent return types that
+// would normally need to be specified in a different way. For example, a method
+// returning a function pointer must be written as
+//
+// fn_ptr_return_t (*method(method_args_t...))(fn_ptr_args_t...)
+//
+// But we only support placing the return type at the beginning. To handle this,
+// we wrap all calls in identity_t, so that a declaration will be expanded to
+//
+// identity_t<fn_ptr_return_t (*)(fn_ptr_args_t...)> method(method_args_t...)
+//
+// This allows us to work around the syntactic oddities of function/method
+// types.
+#define GMOCK_INTERNAL_SIGNATURE(_Ret, _Args) \
+ ::testing::internal::identity_t<GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_Ret), \
+ GMOCK_PP_REMOVE_PARENS, \
+ GMOCK_PP_IDENTITY)(_Ret)>( \
+ GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_TYPE, _, _Args))
#define GMOCK_INTERNAL_GET_TYPE(_i, _, _elem) \
GMOCK_PP_COMMA_IF(_i) \
diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h
index 981af78..cee96da 100644
--- a/googlemock/include/gmock/gmock-generated-actions.h
+++ b/googlemock/include/gmock/gmock-generated-actions.h
@@ -663,7 +663,7 @@ class ActionHelper {
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -726,7 +726,7 @@ class ActionHelper {
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl() {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -776,7 +776,7 @@ class ActionHelper {
args_type;\
explicit gmock_Impl(p0##_type gmock_p0) : \
p0(::std::forward<p0##_type>(gmock_p0)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -832,7 +832,7 @@ class ActionHelper {
gmock_Impl(p0##_type gmock_p0, \
p1##_type gmock_p1) : p0(::std::forward<p0##_type>(gmock_p0)), \
p1(::std::forward<p1##_type>(gmock_p1)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -893,7 +893,7 @@ class ActionHelper {
p2##_type gmock_p2) : p0(::std::forward<p0##_type>(gmock_p0)), \
p1(::std::forward<p1##_type>(gmock_p1)), \
p2(::std::forward<p2##_type>(gmock_p2)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -961,7 +961,7 @@ class ActionHelper {
p1(::std::forward<p1##_type>(gmock_p1)), \
p2(::std::forward<p2##_type>(gmock_p2)), \
p3(::std::forward<p3##_type>(gmock_p3)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -1038,7 +1038,7 @@ class ActionHelper {
p2(::std::forward<p2##_type>(gmock_p2)), \
p3(::std::forward<p3##_type>(gmock_p3)), \
p4(::std::forward<p4##_type>(gmock_p4)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -1119,7 +1119,7 @@ class ActionHelper {
p3(::std::forward<p3##_type>(gmock_p3)), \
p4(::std::forward<p4##_type>(gmock_p4)), \
p5(::std::forward<p5##_type>(gmock_p5)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -1206,7 +1206,7 @@ class ActionHelper {
p4(::std::forward<p4##_type>(gmock_p4)), \
p5(::std::forward<p5##_type>(gmock_p5)), \
p6(::std::forward<p6##_type>(gmock_p6)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -1302,7 +1302,7 @@ class ActionHelper {
p5(::std::forward<p5##_type>(gmock_p5)), \
p6(::std::forward<p6##_type>(gmock_p6)), \
p7(::std::forward<p7##_type>(gmock_p7)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -1404,7 +1404,7 @@ class ActionHelper {
p6(::std::forward<p6##_type>(gmock_p6)), \
p7(::std::forward<p7##_type>(gmock_p7)), \
p8(::std::forward<p8##_type>(gmock_p8)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -1513,7 +1513,7 @@ class ActionHelper {
p7(::std::forward<p7##_type>(gmock_p7)), \
p8(::std::forward<p8##_type>(gmock_p8)), \
p9(::std::forward<p9##_type>(gmock_p9)) {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
diff --git a/googlemock/include/gmock/gmock-generated-actions.h.pump b/googlemock/include/gmock/gmock-generated-actions.h.pump
index 209603c..283abcd 100644
--- a/googlemock/include/gmock/gmock-generated-actions.h.pump
+++ b/googlemock/include/gmock/gmock-generated-actions.h.pump
@@ -395,7 +395,7 @@ $range k 0..n-1
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
@@ -482,7 +482,7 @@ $var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
[[$if i==1 [[explicit ]]]]gmock_Impl($ctor_param_list)$inits {}\
- virtual return_type Perform(const args_type& args) {\
+ return_type Perform(const args_type& args) override {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
Perform(this, args);\
}\
diff --git a/googlemock/include/gmock/gmock-generated-matchers.h b/googlemock/include/gmock/gmock-generated-matchers.h
index 690a57f..6189238 100644
--- a/googlemock/include/gmock/gmock-generated-matchers.h
+++ b/googlemock/include/gmock/gmock-generated-matchers.h
@@ -269,13 +269,13 @@
public:\
gmock_Impl()\
{}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
private:\
@@ -318,13 +318,13 @@
public:\
explicit gmock_Impl(p0##_type gmock_p0)\
: p0(::std::move(gmock_p0)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -371,13 +371,13 @@
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -431,13 +431,13 @@
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p2(::std::move(gmock_p2)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -495,13 +495,13 @@
p3##_type gmock_p3)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -568,13 +568,13 @@
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p4(::std::move(gmock_p4)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -644,13 +644,13 @@
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -726,13 +726,13 @@
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p6(::std::move(gmock_p6)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -814,13 +814,13 @@
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -909,13 +909,13 @@
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \
p8(::std::move(gmock_p8)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
@@ -1009,13 +1009,13 @@
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \
p8(::std::move(gmock_p8)), p9(::std::move(gmock_p9)) {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\
p0##_type const p0;\
diff --git a/googlemock/include/gmock/gmock-generated-matchers.h.pump b/googlemock/include/gmock/gmock-generated-matchers.h.pump
index ae90917..69d2ae4 100644
--- a/googlemock/include/gmock/gmock-generated-matchers.h.pump
+++ b/googlemock/include/gmock/gmock-generated-matchers.h.pump
@@ -302,13 +302,13 @@ $var param_field_decls2 = [[$for j
public:\
[[$if i==1 [[explicit ]]]]gmock_Impl($impl_ctor_param_list)\
$impl_inits {}\
- virtual bool MatchAndExplain(\
+ bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
- ::testing::MatchResultListener* result_listener) const;\
- virtual void DescribeTo(::std::ostream* gmock_os) const {\
+ ::testing::MatchResultListener* result_listener) const override;\
+ void DescribeTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(false);\
}\
- virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
+ void DescribeNegationTo(::std::ostream* gmock_os) const override {\
*gmock_os << FormatDescription(true);\
}\$param_field_decls
private:\
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 28e188b..bb047da 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -42,8 +42,8 @@
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
-#include <math.h>
#include <algorithm>
+#include <cmath>
#include <initializer_list>
#include <iterator>
#include <limits>
@@ -54,6 +54,7 @@
#include <type_traits>
#include <utility>
#include <vector>
+
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
@@ -141,7 +142,7 @@ class MatcherCastImpl {
template <bool Ignore>
static Matcher<T> CastImpl(const M& polymorphic_matcher_or_value,
std::true_type /* convertible_to_matcher */,
- bool_constant<Ignore>) {
+ std::integral_constant<bool, Ignore>) {
// M is implicitly convertible to Matcher<T>, which means that either
// M is a polymorphic matcher or Matcher<T> has an implicit constructor
// from M. In both cases using the implicit conversion will produce a
@@ -1349,6 +1350,22 @@ MakePredicateFormatterFromMatcher(M matcher) {
return PredicateFormatterFromMatcher<M>(std::move(matcher));
}
+// Implements the polymorphic IsNan() matcher, which matches any floating type
+// value that is Nan.
+class IsNanMatcher {
+ public:
+ template <typename FloatType>
+ bool MatchAndExplain(const FloatType& f,
+ MatchResultListener* /* listener */) const {
+ return (::std::isnan)(f);
+ }
+
+ void DescribeTo(::std::ostream* os) const { *os << "is NaN"; }
+ void DescribeNegationTo(::std::ostream* os) const {
+ *os << "isn't NaN";
+ }
+};
+
// Implements the polymorphic floating point equality matcher, which matches
// two float values using ULP-based approximation or, optionally, a
// user-specified epsilon. The template is meant to be instantiated with
@@ -1409,7 +1426,7 @@ class FloatingEqMatcher {
}
const FloatType diff = value - expected_;
- if (fabs(diff) <= max_abs_error_) {
+ if (::std::fabs(diff) <= max_abs_error_) {
return true;
}
@@ -1607,8 +1624,8 @@ class PointeeMatcher {
template <typename Pointer>
class Impl : public MatcherInterface<Pointer> {
public:
- typedef typename PointeeOf<typename std::remove_const<
- typename std::remove_reference<Pointer>::type>::type>::type Pointee;
+ typedef typename PointeeOf<GTEST_REMOVE_REFERENCE_AND_CONST_(Pointer)>::type
+ Pointee;
explicit Impl(const InnerMatcher& matcher)
: matcher_(MatcherCast<const Pointee&>(matcher)) {}
@@ -3626,6 +3643,11 @@ inline internal::RefMatcher<T&> Ref(T& x) { // NOLINT
return internal::RefMatcher<T&>(x);
}
+// Creates a polymorphic matcher that matches any NaN floating point.
+inline PolymorphicMatcher<internal::IsNanMatcher> IsNan() {
+ return MakePolymorphicMatcher(internal::IsNanMatcher());
+}
+
// Creates a matcher that matches any double argument approximately
// equal to rhs, where two NANs are considered unequal.
inline internal::FloatingEqMatcher<double> DoubleEq(double rhs) {
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index fdc049c..5fd169e 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -157,9 +157,6 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value)
-// Evaluates to true if and only if integer type T is signed.
-#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
-
// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
// is true if and only if arithmetic type From can be losslessly converted to
// arithmetic type To.
@@ -170,65 +167,30 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
// From, and kToKind is the kind of To; the value is
// implementation-defined when the above pre-condition is violated.
template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
-struct LosslessArithmeticConvertibleImpl : public std::false_type {};
-
-// Converting bool to bool is lossless.
-template <>
-struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>
- : public std::true_type {};
-
-// Converting bool to any integer type is lossless.
-template <typename To>
-struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>
- : public std::true_type {};
-
-// Converting bool to any floating-point type is lossless.
-template <typename To>
-struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>
- : public std::true_type {};
-
-// Converting an integer to bool is lossy.
-template <typename From>
-struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
- : public std::false_type {};
-
-// Converting an integer to another non-bool integer is lossless
-// if and only if the target type's range encloses the source type's range.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
- : public bool_constant<
- // When converting from a smaller size to a larger size, we are
- // fine as long as we are not converting from signed to unsigned.
- ((sizeof(From) < sizeof(To)) &&
- (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
- // When converting between the same size, the signedness must match.
- ((sizeof(From) == sizeof(To)) &&
- (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
-
-#undef GMOCK_IS_SIGNED_
-
-// Converting an integer to a floating-point type may be lossy, since
-// the format of a floating-point number is implementation-defined.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
- : public std::false_type {};
-
-// Converting a floating-point to bool is lossy.
-template <typename From>
-struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
- : public std::false_type {};
-
-// Converting a floating-point to an integer is lossy.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
- : public std::false_type {};
-
-// Converting a floating-point to another floating-point is lossless
-// if and only if the target type is at least as big as the source type.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<
- kFloatingPoint, From, kFloatingPoint, To>
- : public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
+using LosslessArithmeticConvertibleImpl = std::integral_constant<
+ bool,
+ // clang-format off
+ // Converting from bool is always lossless
+ (kFromKind == kBool) ? true
+ // Converting between any other type kinds will be lossy if the type
+ // kinds are not the same.
+ : (kFromKind != kToKind) ? false
+ : (kFromKind == kInteger &&
+ // Converting between integers of different widths is allowed so long
+ // as the conversion does not go from signed to unsigned.
+ (((sizeof(From) < sizeof(To)) &&
+ !(std::is_signed<From>::value && !std::is_signed<To>::value)) ||
+ // Converting between integers of the same width only requires the
+ // two types to have the same signedness.
+ ((sizeof(From) == sizeof(To)) &&
+ (std::is_signed<From>::value == std::is_signed<To>::value)))
+ ) ? true
+ // Floating point conversions are lossless if and only if `To` is at least
+ // as wide as `From`.
+ : (kFromKind == kFloatingPoint && (sizeof(From) <= sizeof(To))) ? true
+ : false
+ // clang-format on
+ >;
// LosslessArithmeticConvertible<From, To>::value is true if and only if
// arithmetic type From can be losslessly converted to arithmetic type To.
@@ -238,9 +200,9 @@ struct LosslessArithmeticConvertibleImpl<
// reference) built-in arithmetic types; the value is
// implementation-defined when the above pre-condition is violated.
template <typename From, typename To>
-struct LosslessArithmeticConvertible
- : public LosslessArithmeticConvertibleImpl<
- GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT
+using LosslessArithmeticConvertible =
+ LosslessArithmeticConvertibleImpl<GMOCK_KIND_OF_(From), From,
+ GMOCK_KIND_OF_(To), To>;
// This interface knows how to report a Google Mock failure (either
// non-fatal or fatal).
@@ -334,8 +296,6 @@ class WithoutMatchers {
// Internal use only: access the singleton instance of WithoutMatchers.
GTEST_API_ WithoutMatchers GetWithoutMatchers();
-// Type traits.
-
// Disable MSVC warnings for infinite recursion, since in this case the
// the recursion is unreachable.
#ifdef _MSC_VER
@@ -492,8 +452,7 @@ struct Function<R(Args...)> {
using Result = R;
static constexpr size_t ArgumentCount = sizeof...(Args);
template <size_t I>
- using Arg = ElemFromList<I, typename MakeIndexSequence<sizeof...(Args)>::type,
- Args...>;
+ using Arg = ElemFromList<I, Args...>;
using ArgumentTuple = std::tuple<Args...>;
using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;
using MakeResultVoid = void(Args...);
diff --git a/googlemock/include/gmock/internal/gmock-pp.h b/googlemock/include/gmock/internal/gmock-pp.h
index a077f77..c3759f6 100644
--- a/googlemock/include/gmock/internal/gmock-pp.h
+++ b/googlemock/include/gmock/internal/gmock-pp.h
@@ -28,27 +28,25 @@
// Requires: the number of arguments after expansion is at most 15.
#define GMOCK_PP_NARG(...) \
GMOCK_PP_INTERNAL_16TH( \
- (__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))
+ (__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))
// Returns 1 if the expansion of arguments has an unprotected comma. Otherwise
// returns 0. Requires no more than 15 unprotected commas.
#define GMOCK_PP_HAS_COMMA(...) \
GMOCK_PP_INTERNAL_16TH( \
- (__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0))
+ (__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0))
// Returns the first argument.
-#define GMOCK_PP_HEAD(...) \
- GMOCK_PP_INTERNAL_HEAD((__VA_ARGS__))
+#define GMOCK_PP_HEAD(...) GMOCK_PP_INTERNAL_HEAD((__VA_ARGS__))
// Returns the tail. A variadic list of all arguments minus the first. Requires
// at least one argument.
-#define GMOCK_PP_TAIL(...) \
- GMOCK_PP_INTERNAL_TAIL((__VA_ARGS__))
+#define GMOCK_PP_TAIL(...) GMOCK_PP_INTERNAL_TAIL((__VA_ARGS__))
// Calls CAT(_Macro, NARG(__VA_ARGS__))(__VA_ARGS__)
#define GMOCK_PP_VARIADIC_CALL(_Macro, ...) \
GMOCK_PP_IDENTITY( \
- GMOCK_PP_CAT(_Macro, GMOCK_PP_NARG(__VA_ARGS__))(__VA_ARGS__))
+ GMOCK_PP_CAT(_Macro, GMOCK_PP_NARG(__VA_ARGS__))(__VA_ARGS__))
// If the arguments after expansion have no tokens, evaluates to `1`. Otherwise
// evaluates to `0`.
@@ -106,10 +104,9 @@
// Expands to 1 if the first argument starts with something in parentheses,
// otherwise to 0.
-#define GMOCK_PP_IS_BEGIN_PARENS(...) \
- GMOCK_PP_HEAD( \
- GMOCK_PP_CAT(GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_, \
- GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C __VA_ARGS__))
+#define GMOCK_PP_IS_BEGIN_PARENS(...) \
+ GMOCK_PP_HEAD(GMOCK_PP_CAT(GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_, \
+ GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C __VA_ARGS__))
// Expands to 1 is there is only one argument and it is enclosed in parentheses.
#define GMOCK_PP_IS_ENCLOSED_PARENS(...) \
@@ -154,11 +151,11 @@
#define GMOCK_PP_INTERNAL_IF_1(_Then, _Else) _Then
#define GMOCK_PP_INTERNAL_IF_0(_Then, _Else) _Else
-// Because of MSVC treating a token with a comma in it as a single token when passed
-// to another macro, we need to force it to evaluate it as multiple tokens. We do that
-// by using a "IDENTITY(MACRO PARENTHESIZED_ARGS)" macro.
-// We define one per possible macro that relies on this behavior.
-// Note "_Args" must be parenthesized.
+// Because of MSVC treating a token with a comma in it as a single token when
+// passed to another macro, we need to force it to evaluate it as multiple
+// tokens. We do that by using a "IDENTITY(MACRO PARENTHESIZED_ARGS)" macro. We
+// define one per possible macro that relies on this behavior. Note "_Args" must
+// be parenthesized.
#define GMOCK_PP_INTERNAL_INTERNAL_16TH(_1, _2, _3, _4, _5, _6, _7, _8, _9, \
_10, _11, _12, _13, _14, _15, _16, \
...) \