mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
Update googletest and googlemock to 1.8.0. (#90)
This commit is contained in:
@@ -46,6 +46,10 @@
|
||||
#include "gmock/internal/gmock-internal-utils.h"
|
||||
#include "gmock/internal/gmock-port.h"
|
||||
|
||||
#if GTEST_HAS_STD_TYPE_TRAITS_ // Defined by gtest-port.h via gmock-port.h.
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace testing {
|
||||
|
||||
// To implement an action Foo, define:
|
||||
@@ -62,16 +66,17 @@ namespace internal {
|
||||
template <typename F1, typename F2>
|
||||
class ActionAdaptor;
|
||||
|
||||
// BuiltInDefaultValue<T>::Get() returns the "built-in" default
|
||||
// value for type T, which is NULL when T is a pointer type, 0 when T
|
||||
// is a numeric type, false when T is bool, or "" when T is string or
|
||||
// std::string. For any other type T, this value is undefined and the
|
||||
// function will abort the process.
|
||||
// BuiltInDefaultValueGetter<T, true>::Get() returns a
|
||||
// default-constructed T value. BuiltInDefaultValueGetter<T,
|
||||
// false>::Get() crashes with an error.
|
||||
//
|
||||
// This primary template is used when kDefaultConstructible is true.
|
||||
template <typename T, bool kDefaultConstructible>
|
||||
struct BuiltInDefaultValueGetter {
|
||||
static T Get() { return T(); }
|
||||
};
|
||||
template <typename T>
|
||||
class BuiltInDefaultValue {
|
||||
public:
|
||||
// This function returns true iff type T has a built-in default value.
|
||||
static bool Exists() { return false; }
|
||||
struct BuiltInDefaultValueGetter<T, false> {
|
||||
static T Get() {
|
||||
Assert(false, __FILE__, __LINE__,
|
||||
"Default action undefined for the function return type.");
|
||||
@@ -81,6 +86,40 @@ class BuiltInDefaultValue {
|
||||
}
|
||||
};
|
||||
|
||||
// BuiltInDefaultValue<T>::Get() returns the "built-in" default value
|
||||
// for type T, which is NULL when T is a raw pointer type, 0 when T is
|
||||
// a numeric type, false when T is bool, or "" when T is string or
|
||||
// std::string. In addition, in C++11 and above, it turns a
|
||||
// default-constructed T value if T is default constructible. For any
|
||||
// other type T, the built-in default T value is undefined, and the
|
||||
// function will abort the process.
|
||||
template <typename T>
|
||||
class BuiltInDefaultValue {
|
||||
public:
|
||||
#if GTEST_HAS_STD_TYPE_TRAITS_
|
||||
// This function returns true iff type T has a built-in default value.
|
||||
static bool Exists() {
|
||||
return ::std::is_default_constructible<T>::value;
|
||||
}
|
||||
|
||||
static T Get() {
|
||||
return BuiltInDefaultValueGetter<
|
||||
T, ::std::is_default_constructible<T>::value>::Get();
|
||||
}
|
||||
|
||||
#else // GTEST_HAS_STD_TYPE_TRAITS_
|
||||
// This function returns true iff type T has a built-in default value.
|
||||
static bool Exists() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static T Get() {
|
||||
return BuiltInDefaultValueGetter<T, false>::Get();
|
||||
}
|
||||
|
||||
#endif // GTEST_HAS_STD_TYPE_TRAITS_
|
||||
};
|
||||
|
||||
// This partial specialization says that we use the same built-in
|
||||
// default value for T and const T.
|
||||
template <typename T>
|
||||
@@ -163,18 +202,27 @@ class DefaultValue {
|
||||
// Sets the default value for type T; requires T to be
|
||||
// copy-constructable and have a public destructor.
|
||||
static void Set(T x) {
|
||||
delete value_;
|
||||
value_ = new T(x);
|
||||
delete producer_;
|
||||
producer_ = new FixedValueProducer(x);
|
||||
}
|
||||
|
||||
// Provides a factory function to be called to generate the default value.
|
||||
// This method can be used even if T is only move-constructible, but it is not
|
||||
// limited to that case.
|
||||
typedef T (*FactoryFunction)();
|
||||
static void SetFactory(FactoryFunction factory) {
|
||||
delete producer_;
|
||||
producer_ = new FactoryValueProducer(factory);
|
||||
}
|
||||
|
||||
// Unsets the default value for type T.
|
||||
static void Clear() {
|
||||
delete value_;
|
||||
value_ = NULL;
|
||||
delete producer_;
|
||||
producer_ = NULL;
|
||||
}
|
||||
|
||||
// Returns true iff the user has set the default value for type T.
|
||||
static bool IsSet() { return value_ != NULL; }
|
||||
static bool IsSet() { return producer_ != NULL; }
|
||||
|
||||
// Returns true if T has a default return value set by the user or there
|
||||
// exists a built-in default value.
|
||||
@@ -183,15 +231,42 @@ class DefaultValue {
|
||||
}
|
||||
|
||||
// Returns the default value for type T if the user has set one;
|
||||
// otherwise returns the built-in default value if there is one;
|
||||
// otherwise aborts the process.
|
||||
// otherwise returns the built-in default value. Requires that Exists()
|
||||
// is true, which ensures that the return value is well-defined.
|
||||
static T Get() {
|
||||
return value_ == NULL ?
|
||||
internal::BuiltInDefaultValue<T>::Get() : *value_;
|
||||
return producer_ == NULL ?
|
||||
internal::BuiltInDefaultValue<T>::Get() : producer_->Produce();
|
||||
}
|
||||
|
||||
private:
|
||||
static const T* value_;
|
||||
class ValueProducer {
|
||||
public:
|
||||
virtual ~ValueProducer() {}
|
||||
virtual T Produce() = 0;
|
||||
};
|
||||
|
||||
class FixedValueProducer : public ValueProducer {
|
||||
public:
|
||||
explicit FixedValueProducer(T value) : value_(value) {}
|
||||
virtual T Produce() { return value_; }
|
||||
|
||||
private:
|
||||
const T value_;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(FixedValueProducer);
|
||||
};
|
||||
|
||||
class FactoryValueProducer : public ValueProducer {
|
||||
public:
|
||||
explicit FactoryValueProducer(FactoryFunction factory)
|
||||
: factory_(factory) {}
|
||||
virtual T Produce() { return factory_(); }
|
||||
|
||||
private:
|
||||
const FactoryFunction factory_;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(FactoryValueProducer);
|
||||
};
|
||||
|
||||
static ValueProducer* producer_;
|
||||
};
|
||||
|
||||
// This partial specialization allows a user to set default values for
|
||||
@@ -241,7 +316,7 @@ class DefaultValue<void> {
|
||||
|
||||
// Points to the user-set default value for type T.
|
||||
template <typename T>
|
||||
const T* DefaultValue<T>::value_ = NULL;
|
||||
typename DefaultValue<T>::ValueProducer* DefaultValue<T>::producer_ = NULL;
|
||||
|
||||
// Points to the user-set default value for type T&.
|
||||
template <typename T>
|
||||
@@ -423,6 +498,14 @@ class ActionAdaptor : public ActionInterface<F1> {
|
||||
GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
|
||||
};
|
||||
|
||||
// Helper struct to specialize ReturnAction to execute a move instead of a copy
|
||||
// on return. Useful for move-only types, but could be used on any type.
|
||||
template <typename T>
|
||||
struct ByMoveWrapper {
|
||||
explicit ByMoveWrapper(T value) : payload(internal::move(value)) {}
|
||||
T payload;
|
||||
};
|
||||
|
||||
// Implements the polymorphic Return(x) action, which can be used in
|
||||
// any function that returns the type of x, regardless of the argument
|
||||
// types.
|
||||
@@ -453,7 +536,7 @@ class ReturnAction {
|
||||
// Constructs a ReturnAction object from the value to be returned.
|
||||
// 'value' is passed by value instead of by const reference in order
|
||||
// to allow Return("string literal") to compile.
|
||||
explicit ReturnAction(R value) : value_(value) {}
|
||||
explicit ReturnAction(R value) : value_(new R(internal::move(value))) {}
|
||||
|
||||
// This template type conversion operator allows Return(x) to be
|
||||
// used in ANY function that returns x's type.
|
||||
@@ -469,14 +552,14 @@ class ReturnAction {
|
||||
// in the Impl class. But both definitions must be the same.
|
||||
typedef typename Function<F>::Result Result;
|
||||
GTEST_COMPILE_ASSERT_(
|
||||
!internal::is_reference<Result>::value,
|
||||
!is_reference<Result>::value,
|
||||
use_ReturnRef_instead_of_Return_to_return_a_reference);
|
||||
return Action<F>(new Impl<F>(value_));
|
||||
return Action<F>(new Impl<R, F>(value_));
|
||||
}
|
||||
|
||||
private:
|
||||
// Implements the Return(x) action for a particular function type F.
|
||||
template <typename F>
|
||||
template <typename R_, typename F>
|
||||
class Impl : public ActionInterface<F> {
|
||||
public:
|
||||
typedef typename Function<F>::Result Result;
|
||||
@@ -489,20 +572,49 @@ class ReturnAction {
|
||||
// Result to call. ImplicitCast_ forces the compiler to convert R to
|
||||
// Result without considering explicit constructors, thus resolving the
|
||||
// ambiguity. value_ is then initialized using its copy constructor.
|
||||
explicit Impl(R value)
|
||||
: value_(::testing::internal::ImplicitCast_<Result>(value)) {}
|
||||
explicit Impl(const linked_ptr<R>& value)
|
||||
: value_before_cast_(*value),
|
||||
value_(ImplicitCast_<Result>(value_before_cast_)) {}
|
||||
|
||||
virtual Result Perform(const ArgumentTuple&) { return value_; }
|
||||
|
||||
private:
|
||||
GTEST_COMPILE_ASSERT_(!internal::is_reference<Result>::value,
|
||||
GTEST_COMPILE_ASSERT_(!is_reference<Result>::value,
|
||||
Result_cannot_be_a_reference_type);
|
||||
// We save the value before casting just in case it is being cast to a
|
||||
// wrapper type.
|
||||
R value_before_cast_;
|
||||
Result value_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
// Partially specialize for ByMoveWrapper. This version of ReturnAction will
|
||||
// move its contents instead.
|
||||
template <typename R_, typename F>
|
||||
class Impl<ByMoveWrapper<R_>, F> : public ActionInterface<F> {
|
||||
public:
|
||||
typedef typename Function<F>::Result Result;
|
||||
typedef typename Function<F>::ArgumentTuple ArgumentTuple;
|
||||
|
||||
explicit Impl(const linked_ptr<R>& wrapper)
|
||||
: performed_(false), wrapper_(wrapper) {}
|
||||
|
||||
virtual Result Perform(const ArgumentTuple&) {
|
||||
GTEST_CHECK_(!performed_)
|
||||
<< "A ByMove() action should only be performed once.";
|
||||
performed_ = true;
|
||||
return internal::move(wrapper_->payload);
|
||||
}
|
||||
|
||||
private:
|
||||
bool performed_;
|
||||
const linked_ptr<R> wrapper_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
R value_;
|
||||
const linked_ptr<R> value_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ReturnAction);
|
||||
};
|
||||
@@ -510,12 +622,18 @@ class ReturnAction {
|
||||
// Implements the ReturnNull() action.
|
||||
class ReturnNullAction {
|
||||
public:
|
||||
// Allows ReturnNull() to be used in any pointer-returning function.
|
||||
// Allows ReturnNull() to be used in any pointer-returning function. In C++11
|
||||
// this is enforced by returning nullptr, and in non-C++11 by asserting a
|
||||
// pointer type on compile time.
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
static Result Perform(const ArgumentTuple&) {
|
||||
#if GTEST_LANG_CXX11
|
||||
return nullptr;
|
||||
#else
|
||||
GTEST_COMPILE_ASSERT_(internal::is_pointer<Result>::value,
|
||||
ReturnNull_can_be_used_to_return_a_pointer_only);
|
||||
return NULL;
|
||||
#endif // GTEST_LANG_CXX11
|
||||
}
|
||||
};
|
||||
|
||||
@@ -692,7 +810,7 @@ class SetArgumentPointeeAction {
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
void Perform(const ArgumentTuple& args) const {
|
||||
CompileAssertTypesEqual<void, Result>();
|
||||
*::std::tr1::get<N>(args) = value_;
|
||||
*::testing::get<N>(args) = value_;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -715,7 +833,7 @@ class SetArgumentPointeeAction<N, Proto, true> {
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
void Perform(const ArgumentTuple& args) const {
|
||||
CompileAssertTypesEqual<void, Result>();
|
||||
::std::tr1::get<N>(args)->CopyFrom(*proto_);
|
||||
::testing::get<N>(args)->CopyFrom(*proto_);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -941,7 +1059,7 @@ Action<To>::Action(const Action<From>& from)
|
||||
// will trigger a compiler error about using array as initializer.
|
||||
template <typename R>
|
||||
internal::ReturnAction<R> Return(R value) {
|
||||
return internal::ReturnAction<R>(value);
|
||||
return internal::ReturnAction<R>(internal::move(value));
|
||||
}
|
||||
|
||||
// Creates an action that returns NULL.
|
||||
@@ -968,6 +1086,15 @@ inline internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy(const R& x) {
|
||||
return internal::ReturnRefOfCopyAction<R>(x);
|
||||
}
|
||||
|
||||
// Modifies the parent action (a Return() action) to perform a move of the
|
||||
// argument instead of a copy.
|
||||
// Return(ByMove()) actions can only be executed once and will assert this
|
||||
// invariant.
|
||||
template <typename R>
|
||||
internal::ByMoveWrapper<R> ByMove(R x) {
|
||||
return internal::ByMoveWrapper<R>(internal::move(x));
|
||||
}
|
||||
|
||||
// Creates an action that does the default action for the give mock function.
|
||||
inline internal::DoDefaultAction DoDefault() {
|
||||
return internal::DoDefaultAction();
|
||||
|
||||
@@ -51,356 +51,240 @@ template <typename Result, typename ArgumentTuple>
|
||||
class InvokeHelper;
|
||||
|
||||
template <typename R>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<> > {
|
||||
class InvokeHelper<R, ::testing::tuple<> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<>&) {
|
||||
return function();
|
||||
static R Invoke(Function function, const ::testing::tuple<>&) {
|
||||
return function();
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<>&) {
|
||||
return (obj_ptr->*method_ptr)();
|
||||
const ::testing::tuple<>&) {
|
||||
return (obj_ptr->*method_ptr)();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1>& args) {
|
||||
return function(get<0>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args));
|
||||
const ::testing::tuple<A1>& args) {
|
||||
return (obj_ptr->*method_ptr)(get<0>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2>& args) {
|
||||
return function(get<0>(args), get<1>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
|
||||
const ::testing::tuple<A1, A2>& args) {
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2,
|
||||
A3>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3>& args) {
|
||||
return function(get<0>(args), get<1>(args), get<2>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args));
|
||||
const ::testing::tuple<A1, A2, A3>& args) {
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3,
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3,
|
||||
A4>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args));
|
||||
return function(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3, A4>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args));
|
||||
const ::testing::tuple<A1, A2, A3, A4>& args) {
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args), get<3>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4,
|
||||
A5>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args));
|
||||
return function(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3, A4, A5>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args));
|
||||
const ::testing::tuple<A1, A2, A3, A4, A5>& args) {
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args), get<3>(args), get<4>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
|
||||
A5, A6>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
|
||||
A6>& args) {
|
||||
return function(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args));
|
||||
const ::testing::tuple<A1, A2, A3, A4, A5, A6>& args) {
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args), get<3>(args), get<4>(args), get<5>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6, typename A7>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
|
||||
A5, A6, A7>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args), get<6>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
|
||||
A6, A7>& args) {
|
||||
return function(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6,
|
||||
const ::testing::tuple<A1, A2, A3, A4, A5, A6,
|
||||
A7>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args));
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
|
||||
get<6>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6, typename A7, typename A8>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
|
||||
A5, A6, A7, A8>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args), get<6>(args), get<7>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
|
||||
A6, A7, A8>& args) {
|
||||
return function(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args),
|
||||
get<7>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7,
|
||||
const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7,
|
||||
A8>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args));
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
|
||||
get<6>(args), get<7>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6, typename A7, typename A8, typename A9>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
|
||||
A5, A6, A7, A8, A9>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
|
||||
A6, A7, A8, A9>& args) {
|
||||
return function(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args),
|
||||
get<7>(args), get<8>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
A9>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
|
||||
get<8>(args));
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
|
||||
get<6>(args), get<7>(args), get<8>(args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6, typename A7, typename A8, typename A9,
|
||||
typename A10>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
A10> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
|
||||
A5, A6, A7, A8, A9, A10>& args) {
|
||||
using ::std::tr1::get;
|
||||
return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
|
||||
get<9>(args));
|
||||
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
|
||||
A6, A7, A8, A9, A10>& args) {
|
||||
return function(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args),
|
||||
get<7>(args), get<8>(args), get<9>(args));
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
A9, A10>& args) {
|
||||
using ::std::tr1::get;
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
|
||||
get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
|
||||
get<8>(args), get<9>(args));
|
||||
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
|
||||
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
|
||||
get<6>(args), get<7>(args), get<8>(args), get<9>(args));
|
||||
}
|
||||
};
|
||||
|
||||
// CallableHelper has static methods for invoking "callables",
|
||||
// i.e. function pointers and functors. It uses overloading to
|
||||
// provide a uniform interface for invoking different kinds of
|
||||
// callables. In particular, you can use:
|
||||
//
|
||||
// CallableHelper<R>::Call(callable, a1, a2, ..., an)
|
||||
//
|
||||
// to invoke an n-ary callable, where R is its return type. If an
|
||||
// argument, say a2, needs to be passed by reference, you should write
|
||||
// ByRef(a2) instead of a2 in the above expression.
|
||||
template <typename R>
|
||||
class CallableHelper {
|
||||
public:
|
||||
// Calls a nullary callable.
|
||||
template <typename Function>
|
||||
static R Call(Function function) { return function(); }
|
||||
|
||||
// Calls a unary callable.
|
||||
|
||||
// We deliberately pass a1 by value instead of const reference here
|
||||
// in case it is a C-string literal. If we had declared the
|
||||
// parameter as 'const A1& a1' and write Call(function, "Hi"), the
|
||||
// compiler would've thought A1 is 'char[3]', which causes trouble
|
||||
// when you need to copy a value of type A1. By declaring the
|
||||
// parameter as 'A1 a1', the compiler will correctly infer that A1
|
||||
// is 'const char*' when it sees Call(function, "Hi").
|
||||
//
|
||||
// Since this function is defined inline, the compiler can get rid
|
||||
// of the copying of the arguments. Therefore the performance won't
|
||||
// be hurt.
|
||||
template <typename Function, typename A1>
|
||||
static R Call(Function function, A1 a1) { return function(a1); }
|
||||
|
||||
// Calls a binary callable.
|
||||
template <typename Function, typename A1, typename A2>
|
||||
static R Call(Function function, A1 a1, A2 a2) {
|
||||
return function(a1, a2);
|
||||
}
|
||||
|
||||
// Calls a ternary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3) {
|
||||
return function(a1, a2, a3);
|
||||
}
|
||||
|
||||
// Calls a 4-ary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3,
|
||||
typename A4>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4) {
|
||||
return function(a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
// Calls a 5-ary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
|
||||
return function(a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
// Calls a 6-ary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
|
||||
return function(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
|
||||
// Calls a 7-ary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7) {
|
||||
return function(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
|
||||
// Calls a 8-ary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7, A8 a8) {
|
||||
return function(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
|
||||
// Calls a 9-ary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7, typename A8,
|
||||
typename A9>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7, A8 a8, A9 a9) {
|
||||
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
|
||||
// Calls a 10-ary callable.
|
||||
template <typename Function, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7, typename A8,
|
||||
typename A9, typename A10>
|
||||
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7, A8 a8, A9 a9, A10 a10) {
|
||||
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
|
||||
}
|
||||
}; // class CallableHelper
|
||||
|
||||
// An INTERNAL macro for extracting the type of a tuple field. It's
|
||||
// subject to change without notice - DO NOT USE IN USER CODE!
|
||||
#define GMOCK_FIELD_(Tuple, N) \
|
||||
typename ::std::tr1::tuple_element<N, Tuple>::type
|
||||
typename ::testing::tuple_element<N, Tuple>::type
|
||||
|
||||
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
|
||||
// type of an n-ary function whose i-th (1-based) argument type is the
|
||||
// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
|
||||
// type, and whose return type is Result. For example,
|
||||
// SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type
|
||||
// SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
|
||||
// is int(bool, long).
|
||||
//
|
||||
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
|
||||
// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
|
||||
// For example,
|
||||
// SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(
|
||||
// ::std::tr1::make_tuple(true, 'a', 2.5))
|
||||
// returns ::std::tr1::tuple (2.5, true).
|
||||
// SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
|
||||
// ::testing::make_tuple(true, 'a', 2.5))
|
||||
// returns tuple (2.5, true).
|
||||
//
|
||||
// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
|
||||
// in the range [0, 10]. Duplicates are allowed and they don't have
|
||||
@@ -418,7 +302,6 @@ class SelectArgs {
|
||||
GMOCK_FIELD_(ArgumentTuple, k10));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
|
||||
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
|
||||
get<k8>(args), get<k9>(args), get<k10>(args));
|
||||
@@ -432,7 +315,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
typedef Result type();
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& /* args */) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs();
|
||||
}
|
||||
};
|
||||
@@ -444,7 +326,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args));
|
||||
}
|
||||
};
|
||||
@@ -457,7 +338,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k2));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args));
|
||||
}
|
||||
};
|
||||
@@ -470,7 +350,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
|
||||
}
|
||||
};
|
||||
@@ -485,7 +364,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k4));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
|
||||
get<k4>(args));
|
||||
}
|
||||
@@ -501,7 +379,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
|
||||
get<k4>(args), get<k5>(args));
|
||||
}
|
||||
@@ -518,7 +395,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k6));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
|
||||
get<k4>(args), get<k5>(args), get<k6>(args));
|
||||
}
|
||||
@@ -535,7 +411,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
|
||||
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
|
||||
}
|
||||
@@ -553,7 +428,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k8));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
|
||||
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
|
||||
get<k8>(args));
|
||||
@@ -572,7 +446,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
|
||||
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
|
||||
get<k8>(args), get<k9>(args));
|
||||
@@ -638,8 +511,7 @@ struct ExcessiveArg {};
|
||||
template <typename Result, class Impl>
|
||||
class ActionHelper {
|
||||
public:
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<>& args) {
|
||||
using ::std::tr1::get;
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<>& args) {
|
||||
return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -647,8 +519,7 @@ class ActionHelper {
|
||||
}
|
||||
|
||||
template <typename A0>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0>& args) {
|
||||
using ::std::tr1::get;
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0>& args) {
|
||||
return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -656,8 +527,7 @@ class ActionHelper {
|
||||
}
|
||||
|
||||
template <typename A0, typename A1>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1>& args) {
|
||||
using ::std::tr1::get;
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1>& args) {
|
||||
return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
|
||||
get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -665,8 +535,7 @@ class ActionHelper {
|
||||
}
|
||||
|
||||
template <typename A0, typename A1, typename A2>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2>& args) {
|
||||
using ::std::tr1::get;
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2>& args) {
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
|
||||
get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -674,9 +543,8 @@ class ActionHelper {
|
||||
}
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2,
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2,
|
||||
A3>& args) {
|
||||
using ::std::tr1::get;
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
|
||||
get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -684,9 +552,8 @@ class ActionHelper {
|
||||
}
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3,
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3,
|
||||
A4>& args) {
|
||||
using ::std::tr1::get;
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
|
||||
get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
|
||||
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -695,9 +562,8 @@ class ActionHelper {
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
|
||||
A5>& args) {
|
||||
using ::std::tr1::get;
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
|
||||
get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
|
||||
get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -706,9 +572,8 @@ class ActionHelper {
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
|
||||
A5, A6>& args) {
|
||||
using ::std::tr1::get;
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
|
||||
get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
|
||||
get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
|
||||
@@ -717,9 +582,8 @@ class ActionHelper {
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4,
|
||||
typename A5, typename A6, typename A7>
|
||||
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
|
||||
A5, A6, A7>& args) {
|
||||
using ::std::tr1::get;
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
|
||||
A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
|
||||
@@ -728,9 +592,8 @@ class ActionHelper {
|
||||
|
||||
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::tr1::tuple<A0, A1, A2, A3, A4,
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
|
||||
A5, A6, A7, A8>& args) {
|
||||
using ::std::tr1::get;
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
|
||||
A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
|
||||
@@ -739,9 +602,8 @@ class ActionHelper {
|
||||
|
||||
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::tr1::tuple<A0, A1, A2, A3, A4,
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
|
||||
A5, A6, A7, A8, A9>& args) {
|
||||
using ::std::tr1::get;
|
||||
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
|
||||
get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
|
||||
@@ -1053,7 +915,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
// ACTION_TEMPLATE(DuplicateArg,
|
||||
// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
|
||||
// AND_1_VALUE_PARAMS(output)) {
|
||||
// *output = T(std::tr1::get<k>(args));
|
||||
// *output = T(::testing::get<k>(args));
|
||||
// }
|
||||
// ...
|
||||
// int n;
|
||||
@@ -1384,7 +1246,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
|
||||
class GMOCK_ACTION_CLASS_(name, value_params) {\
|
||||
public:\
|
||||
GMOCK_ACTION_CLASS_(name, value_params)\
|
||||
explicit GMOCK_ACTION_CLASS_(name, value_params)\
|
||||
GMOCK_INTERNAL_INIT_##value_params {}\
|
||||
template <typename F>\
|
||||
class gmock_Impl : public ::testing::ActionInterface<F> {\
|
||||
@@ -1492,7 +1354,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
template <typename p0##_type>\
|
||||
class name##ActionP {\
|
||||
public:\
|
||||
name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
|
||||
explicit name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
|
||||
template <typename F>\
|
||||
class gmock_Impl : public ::testing::ActionInterface<F> {\
|
||||
public:\
|
||||
@@ -2218,6 +2080,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
|
||||
namespace testing {
|
||||
|
||||
|
||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
||||
// the macro definition, as the warnings are generated when the macro
|
||||
@@ -2258,81 +2121,175 @@ namespace testing {
|
||||
// InvokeArgument action from temporary values and have it performed
|
||||
// later.
|
||||
|
||||
namespace internal {
|
||||
namespace invoke_argument {
|
||||
|
||||
// Appears in InvokeArgumentAdl's argument list to help avoid
|
||||
// accidental calls to user functions of the same name.
|
||||
struct AdlTag {};
|
||||
|
||||
// InvokeArgumentAdl - a helper for InvokeArgument.
|
||||
// The basic overloads are provided here for generic functors.
|
||||
// Overloads for other custom-callables are provided in the
|
||||
// internal/custom/callback-actions.h header.
|
||||
|
||||
template <typename R, typename F>
|
||||
R InvokeArgumentAdl(AdlTag, F f) {
|
||||
return f();
|
||||
}
|
||||
template <typename R, typename F, typename A1>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1) {
|
||||
return f(a1);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2) {
|
||||
return f(a1, a2);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3) {
|
||||
return f(a1, a2, a3);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3,
|
||||
typename A4>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4) {
|
||||
return f(a1, a2, a3, a4);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
|
||||
return f(a1, a2, a3, a4, a5);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
|
||||
return f(a1, a2, a3, a4, a5, a6);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7) {
|
||||
return f(a1, a2, a3, a4, a5, a6, a7);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7, A8 a8) {
|
||||
return f(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7, typename A8,
|
||||
typename A9>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7, A8 a8, A9 a9) {
|
||||
return f(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
}
|
||||
template <typename R, typename F, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7, typename A8,
|
||||
typename A9, typename A10>
|
||||
R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
|
||||
A7 a7, A8 a8, A9 a9, A10 a10) {
|
||||
return f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
|
||||
}
|
||||
} // namespace invoke_argument
|
||||
} // namespace internal
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_0_VALUE_PARAMS()) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args));
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args));
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_1_VALUE_PARAMS(p0)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_2_VALUE_PARAMS(p0, p1)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_3_VALUE_PARAMS(p0, p1, p2)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2, p3);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2, p3, p4);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2, p3, p4, p5);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
|
||||
}
|
||||
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
||||
}
|
||||
|
||||
// Various overloads for ReturnNew<T>().
|
||||
@@ -2412,4 +2369,9 @@ ACTION_TEMPLATE(ReturnNew,
|
||||
|
||||
} // namespace testing
|
||||
|
||||
// Include any custom actions added by the local installation.
|
||||
// We must include this header at the end to make sure it can use the
|
||||
// declarations from this file.
|
||||
#include "gmock/internal/custom/gmock-generated-actions.h"
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
@@ -61,87 +61,29 @@ $range j 1..i
|
||||
$var types = [[$for j [[, typename A$j]]]]
|
||||
$var as = [[$for j, [[A$j]]]]
|
||||
$var args = [[$if i==0 [[]] $else [[ args]]]]
|
||||
$var import = [[$if i==0 [[]] $else [[
|
||||
using ::std::tr1::get;
|
||||
|
||||
]]]]
|
||||
$var gets = [[$for j, [[get<$(j - 1)>(args)]]]]
|
||||
template <typename R$types>
|
||||
class InvokeHelper<R, ::std::tr1::tuple<$as> > {
|
||||
class InvokeHelper<R, ::testing::tuple<$as> > {
|
||||
public:
|
||||
template <typename Function>
|
||||
static R Invoke(Function function, const ::std::tr1::tuple<$as>&$args) {
|
||||
$import return function($gets);
|
||||
static R Invoke(Function function, const ::testing::tuple<$as>&$args) {
|
||||
return function($gets);
|
||||
}
|
||||
|
||||
template <class Class, typename MethodPtr>
|
||||
static R InvokeMethod(Class* obj_ptr,
|
||||
MethodPtr method_ptr,
|
||||
const ::std::tr1::tuple<$as>&$args) {
|
||||
$import return (obj_ptr->*method_ptr)($gets);
|
||||
const ::testing::tuple<$as>&$args) {
|
||||
return (obj_ptr->*method_ptr)($gets);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
]]
|
||||
// CallableHelper has static methods for invoking "callables",
|
||||
// i.e. function pointers and functors. It uses overloading to
|
||||
// provide a uniform interface for invoking different kinds of
|
||||
// callables. In particular, you can use:
|
||||
//
|
||||
// CallableHelper<R>::Call(callable, a1, a2, ..., an)
|
||||
//
|
||||
// to invoke an n-ary callable, where R is its return type. If an
|
||||
// argument, say a2, needs to be passed by reference, you should write
|
||||
// ByRef(a2) instead of a2 in the above expression.
|
||||
template <typename R>
|
||||
class CallableHelper {
|
||||
public:
|
||||
// Calls a nullary callable.
|
||||
template <typename Function>
|
||||
static R Call(Function function) { return function(); }
|
||||
|
||||
// Calls a unary callable.
|
||||
|
||||
// We deliberately pass a1 by value instead of const reference here
|
||||
// in case it is a C-string literal. If we had declared the
|
||||
// parameter as 'const A1& a1' and write Call(function, "Hi"), the
|
||||
// compiler would've thought A1 is 'char[3]', which causes trouble
|
||||
// when you need to copy a value of type A1. By declaring the
|
||||
// parameter as 'A1 a1', the compiler will correctly infer that A1
|
||||
// is 'const char*' when it sees Call(function, "Hi").
|
||||
//
|
||||
// Since this function is defined inline, the compiler can get rid
|
||||
// of the copying of the arguments. Therefore the performance won't
|
||||
// be hurt.
|
||||
template <typename Function, typename A1>
|
||||
static R Call(Function function, A1 a1) { return function(a1); }
|
||||
|
||||
$range i 2..n
|
||||
$for i
|
||||
[[
|
||||
$var arity = [[$if i==2 [[binary]] $elif i==3 [[ternary]] $else [[$i-ary]]]]
|
||||
|
||||
// Calls a $arity callable.
|
||||
|
||||
$range j 1..i
|
||||
$var typename_As = [[$for j, [[typename A$j]]]]
|
||||
$var Aas = [[$for j, [[A$j a$j]]]]
|
||||
$var as = [[$for j, [[a$j]]]]
|
||||
$var typename_Ts = [[$for j, [[typename T$j]]]]
|
||||
$var Ts = [[$for j, [[T$j]]]]
|
||||
template <typename Function, $typename_As>
|
||||
static R Call(Function function, $Aas) {
|
||||
return function($as);
|
||||
}
|
||||
|
||||
]]
|
||||
}; // class CallableHelper
|
||||
|
||||
// An INTERNAL macro for extracting the type of a tuple field. It's
|
||||
// subject to change without notice - DO NOT USE IN USER CODE!
|
||||
#define GMOCK_FIELD_(Tuple, N) \
|
||||
typename ::std::tr1::tuple_element<N, Tuple>::type
|
||||
typename ::testing::tuple_element<N, Tuple>::type
|
||||
|
||||
$range i 1..n
|
||||
|
||||
@@ -149,15 +91,15 @@ $range i 1..n
|
||||
// type of an n-ary function whose i-th (1-based) argument type is the
|
||||
// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
|
||||
// type, and whose return type is Result. For example,
|
||||
// SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type
|
||||
// SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
|
||||
// is int(bool, long).
|
||||
//
|
||||
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
|
||||
// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
|
||||
// For example,
|
||||
// SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(
|
||||
// ::std::tr1::make_tuple(true, 'a', 2.5))
|
||||
// returns ::std::tr1::tuple (2.5, true).
|
||||
// SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
|
||||
// ::testing::make_tuple(true, 'a', 2.5))
|
||||
// returns tuple (2.5, true).
|
||||
//
|
||||
// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
|
||||
// in the range [0, $n]. Duplicates are allowed and they don't have
|
||||
@@ -169,7 +111,6 @@ class SelectArgs {
|
||||
typedef Result type($for i, [[GMOCK_FIELD_(ArgumentTuple, k$i)]]);
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& args) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs($for i, [[get<k$i>(args)]]);
|
||||
}
|
||||
};
|
||||
@@ -186,7 +127,6 @@ class SelectArgs<Result, ArgumentTuple,
|
||||
typedef typename Function<type>::ArgumentTuple SelectedArgs;
|
||||
static SelectedArgs Select(const ArgumentTuple& [[]]
|
||||
$if i == 1 [[/* args */]] $else [[args]]) {
|
||||
using ::std::tr1::get;
|
||||
return SelectedArgs($for j1, [[get<k$j1>(args)]]);
|
||||
}
|
||||
};
|
||||
@@ -266,8 +206,7 @@ $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::tr1::tuple<$As>& args) {
|
||||
using ::std::tr1::get;
|
||||
static Result Perform(Impl* impl, const ::testing::tuple<$As>& args) {
|
||||
return impl->template gmock_PerformImpl<$As>(args, $arg_list);
|
||||
}
|
||||
|
||||
@@ -454,7 +393,7 @@ $for k [[, \
|
||||
// ACTION_TEMPLATE(DuplicateArg,
|
||||
// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
|
||||
// AND_1_VALUE_PARAMS(output)) {
|
||||
// *output = T(std::tr1::get<k>(args));
|
||||
// *output = T(::testing::get<k>(args));
|
||||
// }
|
||||
// ...
|
||||
// int n;
|
||||
@@ -613,7 +552,7 @@ $range k 0..n-1
|
||||
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
|
||||
class GMOCK_ACTION_CLASS_(name, value_params) {\
|
||||
public:\
|
||||
GMOCK_ACTION_CLASS_(name, value_params)\
|
||||
explicit GMOCK_ACTION_CLASS_(name, value_params)\
|
||||
GMOCK_INTERNAL_INIT_##value_params {}\
|
||||
template <typename F>\
|
||||
class gmock_Impl : public ::testing::ActionInterface<F> {\
|
||||
@@ -701,7 +640,7 @@ $var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
|
||||
#define $macro_name(name$for j [[, p$j]])\$template
|
||||
class $class_name {\
|
||||
public:\
|
||||
$class_name($ctor_param_list)$inits {}\
|
||||
[[$if i==1 [[explicit ]]]]$class_name($ctor_param_list)$inits {}\
|
||||
template <typename F>\
|
||||
class gmock_Impl : public ::testing::ActionInterface<F> {\
|
||||
public:\
|
||||
@@ -741,6 +680,7 @@ $$ // show up in the generated code.
|
||||
|
||||
namespace testing {
|
||||
|
||||
|
||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
||||
// the macro definition, as the warnings are generated when the macro
|
||||
@@ -781,6 +721,32 @@ namespace testing {
|
||||
// InvokeArgument action from temporary values and have it performed
|
||||
// later.
|
||||
|
||||
namespace internal {
|
||||
namespace invoke_argument {
|
||||
|
||||
// Appears in InvokeArgumentAdl's argument list to help avoid
|
||||
// accidental calls to user functions of the same name.
|
||||
struct AdlTag {};
|
||||
|
||||
// InvokeArgumentAdl - a helper for InvokeArgument.
|
||||
// The basic overloads are provided here for generic functors.
|
||||
// Overloads for other custom-callables are provided in the
|
||||
// internal/custom/callback-actions.h header.
|
||||
|
||||
$range i 0..n
|
||||
$for i
|
||||
[[
|
||||
$range j 1..i
|
||||
|
||||
template <typename R, typename F[[$for j [[, typename A$j]]]]>
|
||||
R InvokeArgumentAdl(AdlTag, F f[[$for j [[, A$j a$j]]]]) {
|
||||
return f([[$for j, [[a$j]]]]);
|
||||
}
|
||||
]]
|
||||
|
||||
} // namespace invoke_argument
|
||||
} // namespace internal
|
||||
|
||||
$range i 0..n
|
||||
$for i [[
|
||||
$range j 0..i-1
|
||||
@@ -788,8 +754,10 @@ $range j 0..i-1
|
||||
ACTION_TEMPLATE(InvokeArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) {
|
||||
return internal::CallableHelper<return_type>::Call(
|
||||
::std::tr1::get<k>(args)$for j [[, p$j]]);
|
||||
using internal::invoke_argument::InvokeArgumentAdl;
|
||||
return InvokeArgumentAdl<return_type>(
|
||||
internal::invoke_argument::AdlTag(),
|
||||
::testing::get<k>(args)$for j [[, p$j]]);
|
||||
}
|
||||
|
||||
]]
|
||||
@@ -818,4 +786,9 @@ ACTION_TEMPLATE(ReturnNew,
|
||||
|
||||
} // namespace testing
|
||||
|
||||
// Include any custom callback actions added by the local installation.
|
||||
// We must include this header at the end to make sure it can use the
|
||||
// declarations from this file.
|
||||
#include "gmock/internal/custom/gmock-generated-actions.h"
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
#include "gmock/gmock-spec-builders.h"
|
||||
#include "gmock/internal/gmock-internal-utils.h"
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
# include <functional>
|
||||
#endif
|
||||
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
|
||||
@@ -85,7 +89,7 @@ class FunctionMocker<R(A1)> : public
|
||||
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
|
||||
|
||||
MockSpec<F>& With(const Matcher<A1>& m1) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1));
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1));
|
||||
return this->current_spec();
|
||||
}
|
||||
|
||||
@@ -106,7 +110,7 @@ class FunctionMocker<R(A1, A2)> : public
|
||||
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
|
||||
|
||||
MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2));
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2));
|
||||
return this->current_spec();
|
||||
}
|
||||
|
||||
@@ -128,7 +132,7 @@ class FunctionMocker<R(A1, A2, A3)> : public
|
||||
|
||||
MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
|
||||
const Matcher<A3>& m3) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3));
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3));
|
||||
return this->current_spec();
|
||||
}
|
||||
|
||||
@@ -150,7 +154,7 @@ class FunctionMocker<R(A1, A2, A3, A4)> : public
|
||||
|
||||
MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
|
||||
const Matcher<A3>& m3, const Matcher<A4>& m4) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4));
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4));
|
||||
return this->current_spec();
|
||||
}
|
||||
|
||||
@@ -173,8 +177,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
|
||||
|
||||
MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
|
||||
const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
|
||||
m5));
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5));
|
||||
return this->current_spec();
|
||||
}
|
||||
|
||||
@@ -198,7 +201,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
|
||||
MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
|
||||
const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
|
||||
const Matcher<A6>& m6) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
|
||||
m6));
|
||||
return this->current_spec();
|
||||
}
|
||||
@@ -223,7 +226,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
|
||||
MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
|
||||
const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
|
||||
const Matcher<A6>& m6, const Matcher<A7>& m7) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
|
||||
m6, m7));
|
||||
return this->current_spec();
|
||||
}
|
||||
@@ -248,7 +251,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
|
||||
MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
|
||||
const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
|
||||
const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
|
||||
m6, m7, m8));
|
||||
return this->current_spec();
|
||||
}
|
||||
@@ -274,7 +277,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
|
||||
const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
|
||||
const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
|
||||
const Matcher<A9>& m9) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
|
||||
m6, m7, m8, m9));
|
||||
return this->current_spec();
|
||||
}
|
||||
@@ -301,7 +304,7 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
|
||||
const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
|
||||
const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
|
||||
const Matcher<A9>& m9, const Matcher<A10>& m10) {
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
|
||||
this->current_spec().SetMatchers(::testing::make_tuple(m1, m2, m3, m4, m5,
|
||||
m6, m7, m8, m9, m10));
|
||||
return this->current_spec();
|
||||
}
|
||||
@@ -353,7 +356,7 @@ using internal::FunctionMocker;
|
||||
#define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
|
||||
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
|
||||
) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 0), \
|
||||
this_method_does_not_take_0_arguments); \
|
||||
@@ -372,7 +375,7 @@ using internal::FunctionMocker;
|
||||
#define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
|
||||
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
|
||||
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 1), \
|
||||
this_method_does_not_take_1_argument); \
|
||||
@@ -392,7 +395,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
|
||||
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
|
||||
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 2), \
|
||||
this_method_does_not_take_2_arguments); \
|
||||
@@ -414,7 +417,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
|
||||
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
|
||||
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 3), \
|
||||
this_method_does_not_take_3_arguments); \
|
||||
@@ -440,7 +443,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
|
||||
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
|
||||
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 4), \
|
||||
this_method_does_not_take_4_arguments); \
|
||||
@@ -468,7 +471,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
|
||||
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
|
||||
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 5), \
|
||||
this_method_does_not_take_5_arguments); \
|
||||
@@ -498,7 +501,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
|
||||
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
|
||||
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 6), \
|
||||
this_method_does_not_take_6_arguments); \
|
||||
@@ -530,7 +533,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
|
||||
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
|
||||
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 7), \
|
||||
this_method_does_not_take_7_arguments); \
|
||||
@@ -564,7 +567,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
|
||||
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
|
||||
GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 8), \
|
||||
this_method_does_not_take_8_arguments); \
|
||||
@@ -600,7 +603,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
|
||||
GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
|
||||
GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 9), \
|
||||
this_method_does_not_take_9_arguments); \
|
||||
@@ -640,7 +643,7 @@ using internal::FunctionMocker;
|
||||
GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
|
||||
GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
|
||||
GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
|
||||
== 10), \
|
||||
this_method_does_not_take_10_arguments); \
|
||||
@@ -855,6 +858,17 @@ using internal::FunctionMocker;
|
||||
// point "2", and nothing should happen between the two check
|
||||
// points. The explicit check points make it easy to tell which
|
||||
// Bar("a") is called by which call to Foo().
|
||||
//
|
||||
// MockFunction<F> can also be used to exercise code that accepts
|
||||
// std::function<F> callbacks. To do so, use AsStdFunction() method
|
||||
// to create std::function proxy forwarding to original object's Call.
|
||||
// Example:
|
||||
//
|
||||
// TEST(FooTest, RunsCallbackWithBarArgument) {
|
||||
// MockFunction<int(string)> callback;
|
||||
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
|
||||
// Foo(callback.AsStdFunction());
|
||||
// }
|
||||
template <typename F>
|
||||
class MockFunction;
|
||||
|
||||
@@ -865,6 +879,14 @@ class MockFunction<R()> {
|
||||
|
||||
MOCK_METHOD0_T(Call, R());
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R()> AsStdFunction() {
|
||||
return [this]() -> R {
|
||||
return this->Call();
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -876,6 +898,14 @@ class MockFunction<R(A0)> {
|
||||
|
||||
MOCK_METHOD1_T(Call, R(A0));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0)> AsStdFunction() {
|
||||
return [this](A0 a0) -> R {
|
||||
return this->Call(a0);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -887,6 +917,14 @@ class MockFunction<R(A0, A1)> {
|
||||
|
||||
MOCK_METHOD2_T(Call, R(A0, A1));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1) -> R {
|
||||
return this->Call(a0, a1);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -898,6 +936,14 @@ class MockFunction<R(A0, A1, A2)> {
|
||||
|
||||
MOCK_METHOD3_T(Call, R(A0, A1, A2));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2) -> R {
|
||||
return this->Call(a0, a1, a2);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -909,6 +955,14 @@ class MockFunction<R(A0, A1, A2, A3)> {
|
||||
|
||||
MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2, A3)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2, A3 a3) -> R {
|
||||
return this->Call(a0, a1, a2, a3);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -921,6 +975,14 @@ class MockFunction<R(A0, A1, A2, A3, A4)> {
|
||||
|
||||
MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2, A3, A4)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) -> R {
|
||||
return this->Call(a0, a1, a2, a3, a4);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -933,6 +995,14 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
|
||||
|
||||
MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2, A3, A4, A5)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) -> R {
|
||||
return this->Call(a0, a1, a2, a3, a4, a5);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -945,6 +1015,14 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
|
||||
|
||||
MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2, A3, A4, A5, A6)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) -> R {
|
||||
return this->Call(a0, a1, a2, a3, a4, a5, a6);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -957,6 +1035,14 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
|
||||
|
||||
MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2, A3, A4, A5, A6, A7)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) -> R {
|
||||
return this->Call(a0, a1, a2, a3, a4, a5, a6, a7);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -969,6 +1055,15 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
|
||||
|
||||
MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
|
||||
A8 a8) -> R {
|
||||
return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
@@ -982,6 +1077,15 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
|
||||
|
||||
MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> AsStdFunction() {
|
||||
return [this](A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
|
||||
A8 a8, A9 a9) -> R {
|
||||
return this->Call(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
@@ -44,6 +44,10 @@ $var n = 10 $$ The maximum arity we support.
|
||||
#include "gmock/gmock-spec-builders.h"
|
||||
#include "gmock/internal/gmock-internal-utils.h"
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
# include <functional>
|
||||
#endif
|
||||
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
|
||||
@@ -78,7 +82,7 @@ class FunctionMocker<R($As)> : public
|
||||
MockSpec<F>& With($matchers) {
|
||||
|
||||
$if i >= 1 [[
|
||||
this->current_spec().SetMatchers(::std::tr1::make_tuple($ms));
|
||||
this->current_spec().SetMatchers(::testing::make_tuple($ms));
|
||||
|
||||
]]
|
||||
return this->current_spec();
|
||||
@@ -139,7 +143,7 @@ $var matcher_as = [[$for j, \
|
||||
#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \
|
||||
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
|
||||
$arg_as) constness { \
|
||||
GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size< \
|
||||
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
|
||||
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value == $i), \
|
||||
this_method_does_not_take_$i[[]]_argument[[$if i != 1 [[s]]]]); \
|
||||
GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
|
||||
@@ -241,18 +245,40 @@ $for i [[
|
||||
// point "2", and nothing should happen between the two check
|
||||
// points. The explicit check points make it easy to tell which
|
||||
// Bar("a") is called by which call to Foo().
|
||||
//
|
||||
// MockFunction<F> can also be used to exercise code that accepts
|
||||
// std::function<F> callbacks. To do so, use AsStdFunction() method
|
||||
// to create std::function proxy forwarding to original object's Call.
|
||||
// Example:
|
||||
//
|
||||
// TEST(FooTest, RunsCallbackWithBarArgument) {
|
||||
// MockFunction<int(string)> callback;
|
||||
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
|
||||
// Foo(callback.AsStdFunction());
|
||||
// }
|
||||
template <typename F>
|
||||
class MockFunction;
|
||||
|
||||
|
||||
$for i [[
|
||||
$range j 0..i-1
|
||||
$var ArgTypes = [[$for j, [[A$j]]]]
|
||||
$var ArgNames = [[$for j, [[a$j]]]]
|
||||
$var ArgDecls = [[$for j, [[A$j a$j]]]]
|
||||
template <typename R$for j [[, typename A$j]]>
|
||||
class MockFunction<R($for j, [[A$j]])> {
|
||||
class MockFunction<R($ArgTypes)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD$i[[]]_T(Call, R($for j, [[A$j]]));
|
||||
MOCK_METHOD$i[[]]_T(Call, R($ArgTypes));
|
||||
|
||||
#if GTEST_HAS_STD_FUNCTION_
|
||||
std::function<R($ArgTypes)> AsStdFunction() {
|
||||
return [this]($ArgDecls) -> R {
|
||||
return this->Call($ArgNames);
|
||||
};
|
||||
}
|
||||
#endif // GTEST_HAS_STD_FUNCTION_
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace internal {
|
||||
|
||||
// The type of the i-th (0-based) field of Tuple.
|
||||
#define GMOCK_FIELD_TYPE_(Tuple, i) \
|
||||
typename ::std::tr1::tuple_element<i, Tuple>::type
|
||||
typename ::testing::tuple_element<i, Tuple>::type
|
||||
|
||||
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
|
||||
// tuple of type Tuple. It has two members:
|
||||
@@ -72,14 +72,13 @@ template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
|
||||
int k7, int k8, int k9>
|
||||
class TupleFields {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k9)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
|
||||
get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
|
||||
}
|
||||
@@ -90,9 +89,8 @@ class TupleFields {
|
||||
template <class Tuple>
|
||||
class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<> type;
|
||||
typedef ::testing::tuple<> type;
|
||||
static type GetSelectedFields(const Tuple& /* t */) {
|
||||
using ::std::tr1::get;
|
||||
return type();
|
||||
}
|
||||
};
|
||||
@@ -100,9 +98,8 @@ class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
|
||||
template <class Tuple, int k0>
|
||||
class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t));
|
||||
}
|
||||
};
|
||||
@@ -110,10 +107,9 @@ class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
|
||||
template <class Tuple, int k0, int k1>
|
||||
class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t));
|
||||
}
|
||||
};
|
||||
@@ -121,10 +117,9 @@ class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
|
||||
template <class Tuple, int k0, int k1, int k2>
|
||||
class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t));
|
||||
}
|
||||
};
|
||||
@@ -132,11 +127,10 @@ class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
|
||||
template <class Tuple, int k0, int k1, int k2, int k3>
|
||||
class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k3)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
|
||||
}
|
||||
};
|
||||
@@ -144,11 +138,10 @@ class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
|
||||
template <class Tuple, int k0, int k1, int k2, int k3, int k4>
|
||||
class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
|
||||
}
|
||||
};
|
||||
@@ -156,12 +149,11 @@ class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
|
||||
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
|
||||
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k5)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
|
||||
get<k5>(t));
|
||||
}
|
||||
@@ -170,12 +162,11 @@ class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
|
||||
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
|
||||
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
|
||||
get<k5>(t), get<k6>(t));
|
||||
}
|
||||
@@ -185,13 +176,12 @@ template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
|
||||
int k7>
|
||||
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k7)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
|
||||
get<k5>(t), get<k6>(t), get<k7>(t));
|
||||
}
|
||||
@@ -201,13 +191,12 @@ template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
|
||||
int k7, int k8>
|
||||
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
|
||||
GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
|
||||
get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
|
||||
}
|
||||
@@ -577,29 +566,29 @@ Args(const InnerMatcher& matcher) {
|
||||
// undefined (e.g. hash_map).
|
||||
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<> >
|
||||
::testing::tuple<> >
|
||||
ElementsAre() {
|
||||
typedef std::tr1::tuple<> Args;
|
||||
typedef ::testing::tuple<> Args;
|
||||
return internal::ElementsAreMatcher<Args>(Args());
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type> >
|
||||
ElementsAre(const T1& e1) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type> Args;
|
||||
return internal::ElementsAreMatcher<Args>(Args(e1));
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type> Args;
|
||||
return internal::ElementsAreMatcher<Args>(Args(e1, e2));
|
||||
@@ -607,12 +596,12 @@ ElementsAre(const T1& e1, const T2& e2) {
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type> Args;
|
||||
@@ -621,13 +610,13 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3) {
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
typename internal::DecayArray<T4>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -637,7 +626,7 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -645,7 +634,7 @@ inline internal::ElementsAreMatcher<
|
||||
typename internal::DecayArray<T5>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -657,7 +646,7 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -666,7 +655,7 @@ inline internal::ElementsAreMatcher<
|
||||
typename internal::DecayArray<T6>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -679,7 +668,7 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -689,7 +678,7 @@ inline internal::ElementsAreMatcher<
|
||||
typename internal::DecayArray<T7>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -703,7 +692,7 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -714,7 +703,7 @@ inline internal::ElementsAreMatcher<
|
||||
typename internal::DecayArray<T8>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -730,7 +719,7 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8, typename T9>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -742,7 +731,7 @@ inline internal::ElementsAreMatcher<
|
||||
typename internal::DecayArray<T9>::type> >
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -759,7 +748,7 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8, typename T9, typename T10>
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -773,7 +762,7 @@ inline internal::ElementsAreMatcher<
|
||||
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
|
||||
const T10& e10) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -792,29 +781,29 @@ ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
// that matches n elements in any order. We support up to n=10 arguments.
|
||||
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<> >
|
||||
::testing::tuple<> >
|
||||
UnorderedElementsAre() {
|
||||
typedef std::tr1::tuple<> Args;
|
||||
typedef ::testing::tuple<> Args;
|
||||
return internal::UnorderedElementsAreMatcher<Args>(Args());
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type> >
|
||||
UnorderedElementsAre(const T1& e1) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type> Args;
|
||||
return internal::UnorderedElementsAreMatcher<Args>(Args(e1));
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type> Args;
|
||||
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2));
|
||||
@@ -822,12 +811,12 @@ UnorderedElementsAre(const T1& e1, const T2& e2) {
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type> Args;
|
||||
@@ -836,13 +825,13 @@ UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
typename internal::DecayArray<T4>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -852,7 +841,7 @@ UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -860,7 +849,7 @@ inline internal::UnorderedElementsAreMatcher<
|
||||
typename internal::DecayArray<T5>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -872,7 +861,7 @@ UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -881,7 +870,7 @@ inline internal::UnorderedElementsAreMatcher<
|
||||
typename internal::DecayArray<T6>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -895,7 +884,7 @@ UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -905,7 +894,7 @@ inline internal::UnorderedElementsAreMatcher<
|
||||
typename internal::DecayArray<T7>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -920,7 +909,7 @@ UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -931,7 +920,7 @@ inline internal::UnorderedElementsAreMatcher<
|
||||
typename internal::DecayArray<T8>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -947,7 +936,7 @@ UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8, typename T9>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -959,7 +948,7 @@ inline internal::UnorderedElementsAreMatcher<
|
||||
typename internal::DecayArray<T9>::type> >
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -976,7 +965,7 @@ UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
typename T6, typename T7, typename T8, typename T9, typename T10>
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -990,7 +979,7 @@ inline internal::UnorderedElementsAreMatcher<
|
||||
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
|
||||
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
|
||||
const T10& e10) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
typename internal::DecayArray<T1>::type,
|
||||
typename internal::DecayArray<T2>::type,
|
||||
typename internal::DecayArray<T3>::type,
|
||||
@@ -1413,7 +1402,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<>()));\
|
||||
::testing::tuple<>()));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
@@ -1462,7 +1451,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type>(p0)));\
|
||||
::testing::tuple<p0##_type>(p0)));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
@@ -1471,7 +1460,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::Matcher<arg_type>(\
|
||||
new gmock_Impl<arg_type>(p0));\
|
||||
}\
|
||||
name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
|
||||
explicit name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
|
||||
}\
|
||||
p0##_type p0;\
|
||||
private:\
|
||||
@@ -1515,7 +1504,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
|
||||
::testing::tuple<p0##_type, p1##_type>(p0, p1)));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
@@ -1573,7 +1562,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
|
||||
p2)));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
@@ -1636,7 +1625,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type, \
|
||||
p3##_type>(p0, p1, p2, p3)));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
@@ -1707,7 +1696,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
p4##_type>(p0, p1, p2, p3, p4)));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
@@ -1781,7 +1770,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
@@ -1859,7 +1848,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
|
||||
p6)));\
|
||||
}\
|
||||
@@ -1944,7 +1933,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
|
||||
p3, p4, p5, p6, p7)));\
|
||||
}\
|
||||
@@ -2035,7 +2024,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
p4##_type, p5##_type, p6##_type, p7##_type, \
|
||||
p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
|
||||
}\
|
||||
@@ -2131,7 +2120,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
|
||||
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
|
||||
p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
|
||||
}\
|
||||
|
||||
@@ -53,7 +53,7 @@ $range i 0..n-1
|
||||
|
||||
// The type of the i-th (0-based) field of Tuple.
|
||||
#define GMOCK_FIELD_TYPE_(Tuple, i) \
|
||||
typename ::std::tr1::tuple_element<i, Tuple>::type
|
||||
typename ::testing::tuple_element<i, Tuple>::type
|
||||
|
||||
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
|
||||
// tuple of type Tuple. It has two members:
|
||||
@@ -73,9 +73,8 @@ class TupleFields;
|
||||
template <class Tuple$for i [[, int k$i]]>
|
||||
class TupleFields {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<$for i, [[GMOCK_FIELD_TYPE_(Tuple, k$i)]]> type;
|
||||
typedef ::testing::tuple<$for i, [[GMOCK_FIELD_TYPE_(Tuple, k$i)]]> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
using ::std::tr1::get;
|
||||
return type($for i, [[get<k$i>(t)]]);
|
||||
}
|
||||
};
|
||||
@@ -90,9 +89,8 @@ $range k 0..n-1
|
||||
template <class Tuple$for j [[, int k$j]]>
|
||||
class TupleFields<Tuple, $for k, [[$if k < i [[k$k]] $else [[-1]]]]> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
|
||||
typedef ::testing::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
|
||||
static type GetSelectedFields(const Tuple& $if i==0 [[/* t */]] $else [[t]]) {
|
||||
using ::std::tr1::get;
|
||||
return type($for j, [[get<k$j>(t)]]);
|
||||
}
|
||||
};
|
||||
@@ -289,12 +287,12 @@ template <$for j, [[typename T$j]]>
|
||||
]]
|
||||
|
||||
inline internal::ElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
$for j, [[
|
||||
|
||||
typename internal::DecayArray<T$j[[]]>::type]]> >
|
||||
ElementsAre($for j, [[const T$j& e$j]]) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
$for j, [[
|
||||
|
||||
typename internal::DecayArray<T$j[[]]>::type]]> Args;
|
||||
@@ -317,12 +315,12 @@ template <$for j, [[typename T$j]]>
|
||||
]]
|
||||
|
||||
inline internal::UnorderedElementsAreMatcher<
|
||||
std::tr1::tuple<
|
||||
::testing::tuple<
|
||||
$for j, [[
|
||||
|
||||
typename internal::DecayArray<T$j[[]]>::type]]> >
|
||||
UnorderedElementsAre($for j, [[const T$j& e$j]]) {
|
||||
typedef std::tr1::tuple<
|
||||
typedef ::testing::tuple<
|
||||
$for j, [[
|
||||
|
||||
typename internal::DecayArray<T$j[[]]>::type]]> Args;
|
||||
@@ -646,7 +644,7 @@ $var param_field_decls2 = [[$for j
|
||||
return ::testing::internal::FormatMatcherDescription(\
|
||||
negation, #name, \
|
||||
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
||||
::std::tr1::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
|
||||
::testing::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
|
||||
}\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
@@ -655,7 +653,7 @@ $var param_field_decls2 = [[$for j
|
||||
return ::testing::Matcher<arg_type>(\
|
||||
new gmock_Impl<arg_type>($params));\
|
||||
}\
|
||||
$class_name($ctor_param_list)$inits {\
|
||||
[[$if i==1 [[explicit ]]]]$class_name($ctor_param_list)$inits {\
|
||||
}\$param_field_decls2
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_($class_name);\
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -72,7 +72,7 @@ template <class Class, typename MethodPtr>
|
||||
class InvokeMethodAction {
|
||||
public:
|
||||
InvokeMethodAction(Class* obj_ptr, MethodPtr method_ptr)
|
||||
: obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
|
||||
: method_ptr_(method_ptr), obj_ptr_(obj_ptr) {}
|
||||
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
Result Perform(const ArgumentTuple& args) const {
|
||||
@@ -81,12 +81,29 @@ class InvokeMethodAction {
|
||||
}
|
||||
|
||||
private:
|
||||
Class* const obj_ptr_;
|
||||
// The order of these members matters. Reversing the order can trigger
|
||||
// warning C4121 in MSVC (see
|
||||
// http://computer-programming-forum.com/7-vc.net/6fbc30265f860ad1.htm ).
|
||||
const MethodPtr method_ptr_;
|
||||
Class* const obj_ptr_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);
|
||||
};
|
||||
|
||||
// An internal replacement for std::copy which mimics its behavior. This is
|
||||
// necessary because Visual Studio deprecates ::std::copy, issuing warning 4996.
|
||||
// However Visual Studio 2010 and later do not honor #pragmas which disable that
|
||||
// warning.
|
||||
template<typename InputIterator, typename OutputIterator>
|
||||
inline OutputIterator CopyElements(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator output) {
|
||||
for (; first != last; ++first, ++output) {
|
||||
*output = *first;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Various overloads for Invoke().
|
||||
@@ -144,7 +161,7 @@ WithArg(const InnerAction& action) {
|
||||
ACTION_TEMPLATE(ReturnArg,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_0_VALUE_PARAMS()) {
|
||||
return std::tr1::get<k>(args);
|
||||
return ::testing::get<k>(args);
|
||||
}
|
||||
|
||||
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
|
||||
@@ -152,7 +169,7 @@ ACTION_TEMPLATE(ReturnArg,
|
||||
ACTION_TEMPLATE(SaveArg,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_1_VALUE_PARAMS(pointer)) {
|
||||
*pointer = ::std::tr1::get<k>(args);
|
||||
*pointer = ::testing::get<k>(args);
|
||||
}
|
||||
|
||||
// Action SaveArgPointee<k>(pointer) saves the value pointed to
|
||||
@@ -160,7 +177,7 @@ ACTION_TEMPLATE(SaveArg,
|
||||
ACTION_TEMPLATE(SaveArgPointee,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_1_VALUE_PARAMS(pointer)) {
|
||||
*pointer = *::std::tr1::get<k>(args);
|
||||
*pointer = *::testing::get<k>(args);
|
||||
}
|
||||
|
||||
// Action SetArgReferee<k>(value) assigns 'value' to the variable
|
||||
@@ -168,13 +185,13 @@ ACTION_TEMPLATE(SaveArgPointee,
|
||||
ACTION_TEMPLATE(SetArgReferee,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_1_VALUE_PARAMS(value)) {
|
||||
typedef typename ::std::tr1::tuple_element<k, args_type>::type argk_type;
|
||||
typedef typename ::testing::tuple_element<k, args_type>::type argk_type;
|
||||
// Ensures that argument #k is a reference. If you get a compiler
|
||||
// error on the next line, you are using SetArgReferee<k>(value) in
|
||||
// a mock function whose k-th (0-based) argument is not a reference.
|
||||
GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
|
||||
SetArgReferee_must_be_used_with_a_reference_argument);
|
||||
::std::tr1::get<k>(args) = value;
|
||||
::testing::get<k>(args) = value;
|
||||
}
|
||||
|
||||
// Action SetArrayArgument<k>(first, last) copies the elements in
|
||||
@@ -185,15 +202,11 @@ ACTION_TEMPLATE(SetArgReferee,
|
||||
ACTION_TEMPLATE(SetArrayArgument,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_2_VALUE_PARAMS(first, last)) {
|
||||
// Microsoft compiler deprecates ::std::copy, so we want to suppress warning
|
||||
// 4996 (Function call with parameters that may be unsafe) there.
|
||||
// Visual Studio deprecates ::std::copy, so we use our own copy in that case.
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push) // Saves the current warning state.
|
||||
# pragma warning(disable:4996) // Temporarily disables warning 4996.
|
||||
#endif
|
||||
::std::copy(first, last, ::std::tr1::get<k>(args));
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop) // Restores the warning state.
|
||||
internal::CopyElements(first, last, ::testing::get<k>(args));
|
||||
#else
|
||||
::std::copy(first, last, ::testing::get<k>(args));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -202,7 +215,7 @@ ACTION_TEMPLATE(SetArrayArgument,
|
||||
ACTION_TEMPLATE(DeleteArg,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
AND_0_VALUE_PARAMS()) {
|
||||
delete ::std::tr1::get<k>(args);
|
||||
delete ::testing::get<k>(args);
|
||||
}
|
||||
|
||||
// This action returns the value pointed to by 'pointer'.
|
||||
|
||||
@@ -211,7 +211,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
|
||||
// arguments. This function can be safely called from multiple
|
||||
// threads concurrently. The caller is responsible for deleting the
|
||||
// result.
|
||||
const UntypedActionResultHolderBase* UntypedInvokeWith(
|
||||
UntypedActionResultHolderBase* UntypedInvokeWith(
|
||||
const void* untyped_args)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
|
||||
|
||||
@@ -1289,6 +1289,57 @@ class MockSpec {
|
||||
GTEST_DISALLOW_ASSIGN_(MockSpec);
|
||||
}; // class MockSpec
|
||||
|
||||
// Wrapper type for generically holding an ordinary value or lvalue reference.
|
||||
// If T is not a reference type, it must be copyable or movable.
|
||||
// ReferenceOrValueWrapper<T> is movable, and will also be copyable unless
|
||||
// T is a move-only value type (which means that it will always be copyable
|
||||
// if the current platform does not support move semantics).
|
||||
//
|
||||
// The primary template defines handling for values, but function header
|
||||
// comments describe the contract for the whole template (including
|
||||
// specializations).
|
||||
template <typename T>
|
||||
class ReferenceOrValueWrapper {
|
||||
public:
|
||||
// Constructs a wrapper from the given value/reference.
|
||||
explicit ReferenceOrValueWrapper(T value)
|
||||
: value_(::testing::internal::move(value)) {
|
||||
}
|
||||
|
||||
// Unwraps and returns the underlying value/reference, exactly as
|
||||
// originally passed. The behavior of calling this more than once on
|
||||
// the same object is unspecified.
|
||||
T Unwrap() { return ::testing::internal::move(value_); }
|
||||
|
||||
// Provides nondestructive access to the underlying value/reference.
|
||||
// Always returns a const reference (more precisely,
|
||||
// const RemoveReference<T>&). The behavior of calling this after
|
||||
// calling Unwrap on the same object is unspecified.
|
||||
const T& Peek() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
T value_;
|
||||
};
|
||||
|
||||
// Specialization for lvalue reference types. See primary template
|
||||
// for documentation.
|
||||
template <typename T>
|
||||
class ReferenceOrValueWrapper<T&> {
|
||||
public:
|
||||
// Workaround for debatable pass-by-reference lint warning (c-library-team
|
||||
// policy precludes NOLINT in this context)
|
||||
typedef T& reference;
|
||||
explicit ReferenceOrValueWrapper(reference ref)
|
||||
: value_ptr_(&ref) {}
|
||||
T& Unwrap() { return *value_ptr_; }
|
||||
const T& Peek() const { return *value_ptr_; }
|
||||
|
||||
private:
|
||||
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
|
||||
@@ -1320,23 +1371,16 @@ class UntypedActionResultHolderBase {
|
||||
template <typename T>
|
||||
class ActionResultHolder : public UntypedActionResultHolderBase {
|
||||
public:
|
||||
explicit ActionResultHolder(T a_value) : value_(a_value) {}
|
||||
|
||||
// The compiler-generated copy constructor and assignment operator
|
||||
// are exactly what we need, so we don't need to define them.
|
||||
|
||||
// Returns the held value and deletes this object.
|
||||
T GetValueAndDelete() const {
|
||||
T retval(value_);
|
||||
delete this;
|
||||
return retval;
|
||||
// Returns the held value. Must not be called more than once.
|
||||
T Unwrap() {
|
||||
return result_.Unwrap();
|
||||
}
|
||||
|
||||
// Prints the held value as an action's result to os.
|
||||
virtual void PrintAsActionResult(::std::ostream* os) const {
|
||||
*os << "\n Returns: ";
|
||||
// T may be a reference type, so we don't use UniversalPrint().
|
||||
UniversalPrinter<T>::Print(value_, os);
|
||||
UniversalPrinter<T>::Print(result_.Peek(), os);
|
||||
}
|
||||
|
||||
// Performs the given mock function's default action and returns the
|
||||
@@ -1346,8 +1390,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
|
||||
const FunctionMockerBase<F>* func_mocker,
|
||||
const typename Function<F>::ArgumentTuple& args,
|
||||
const string& call_description) {
|
||||
return new ActionResultHolder(
|
||||
func_mocker->PerformDefaultAction(args, call_description));
|
||||
return new ActionResultHolder(Wrapper(
|
||||
func_mocker->PerformDefaultAction(args, call_description)));
|
||||
}
|
||||
|
||||
// Performs the given action and returns the result in a new-ed
|
||||
@@ -1356,42 +1400,53 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
|
||||
static ActionResultHolder*
|
||||
PerformAction(const Action<F>& action,
|
||||
const typename Function<F>::ArgumentTuple& args) {
|
||||
return new ActionResultHolder(action.Perform(args));
|
||||
return new ActionResultHolder(Wrapper(action.Perform(args)));
|
||||
}
|
||||
|
||||
private:
|
||||
T value_;
|
||||
typedef ReferenceOrValueWrapper<T> Wrapper;
|
||||
|
||||
// T could be a reference type, so = isn't supported.
|
||||
GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
|
||||
explicit ActionResultHolder(Wrapper result)
|
||||
: result_(::testing::internal::move(result)) {
|
||||
}
|
||||
|
||||
Wrapper result_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);
|
||||
};
|
||||
|
||||
// Specialization for T = void.
|
||||
template <>
|
||||
class ActionResultHolder<void> : public UntypedActionResultHolderBase {
|
||||
public:
|
||||
void GetValueAndDelete() const { delete this; }
|
||||
void Unwrap() { }
|
||||
|
||||
virtual void PrintAsActionResult(::std::ostream* /* os */) const {}
|
||||
|
||||
// Performs the given mock function's default action and returns NULL;
|
||||
// Performs the given mock function's default action and returns ownership
|
||||
// of an empty ActionResultHolder*.
|
||||
template <typename F>
|
||||
static ActionResultHolder* PerformDefaultAction(
|
||||
const FunctionMockerBase<F>* func_mocker,
|
||||
const typename Function<F>::ArgumentTuple& args,
|
||||
const string& call_description) {
|
||||
func_mocker->PerformDefaultAction(args, call_description);
|
||||
return NULL;
|
||||
return new ActionResultHolder;
|
||||
}
|
||||
|
||||
// Performs the given action and returns NULL.
|
||||
// Performs the given action and returns ownership of an empty
|
||||
// ActionResultHolder*.
|
||||
template <typename F>
|
||||
static ActionResultHolder* PerformAction(
|
||||
const Action<F>& action,
|
||||
const typename Function<F>::ArgumentTuple& args) {
|
||||
action.Perform(args);
|
||||
return NULL;
|
||||
return new ActionResultHolder;
|
||||
}
|
||||
|
||||
private:
|
||||
ActionResultHolder() {}
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);
|
||||
};
|
||||
|
||||
// The base of the function mocker class for the given function type.
|
||||
@@ -1526,8 +1581,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
// threads concurrently.
|
||||
Result InvokeWith(const ArgumentTuple& args)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
|
||||
return static_cast<const ResultHolder*>(
|
||||
this->UntypedInvokeWith(&args))->GetValueAndDelete();
|
||||
scoped_ptr<ResultHolder> holder(
|
||||
DownCast_<ResultHolder*>(this->UntypedInvokeWith(&args)));
|
||||
return holder->Unwrap();
|
||||
}
|
||||
|
||||
// Adds and returns a default action spec for this mock function.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// This file was GENERATED by command:
|
||||
// pump.py gmock-generated-actions.h.pump
|
||||
// DO NOT EDIT BY HAND!!!
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
@@ -0,0 +1,10 @@
|
||||
$$ -*- mode: c++; -*-
|
||||
$$ This is a Pump source file (http://go/pump). Please use Pump to convert
|
||||
$$ it to callback-actions.h.
|
||||
$$
|
||||
$var max_callback_arity = 5
|
||||
$$}} This meta comment fixes auto-indentation in editors.
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
39
gmock/include/gmock/internal/custom/gmock-matchers.h
Normal file
39
gmock/include/gmock/internal/custom/gmock-matchers.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright 2015, Google Inc.
|
||||
// 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.
|
||||
//
|
||||
// ============================================================
|
||||
// An installation-specific extension point for gmock-matchers.h.
|
||||
// ============================================================
|
||||
//
|
||||
// Adds google3 callback support to CallableTraits.
|
||||
//
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_MATCHERS_H_
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_MATCHERS_H_
|
||||
46
gmock/include/gmock/internal/custom/gmock-port.h
Normal file
46
gmock/include/gmock/internal/custom/gmock-port.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2015, Google Inc.
|
||||
// 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.
|
||||
//
|
||||
// Injection point for custom user configurations.
|
||||
// The following macros can be defined:
|
||||
//
|
||||
// Flag related macros:
|
||||
// GMOCK_DECLARE_bool_(name)
|
||||
// GMOCK_DECLARE_int32_(name)
|
||||
// GMOCK_DECLARE_string_(name)
|
||||
// GMOCK_DEFINE_bool_(name, default_val, doc)
|
||||
// GMOCK_DEFINE_int32_(name, default_val, doc)
|
||||
// GMOCK_DEFINE_string_(name, default_val, doc)
|
||||
//
|
||||
// ** Custom implementation starts here **
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
||||
@@ -69,70 +69,70 @@ template <typename Tuple>
|
||||
struct MatcherTuple;
|
||||
|
||||
template <>
|
||||
struct MatcherTuple< ::std::tr1::tuple<> > {
|
||||
typedef ::std::tr1::tuple< > type;
|
||||
struct MatcherTuple< ::testing::tuple<> > {
|
||||
typedef ::testing::tuple< > type;
|
||||
};
|
||||
|
||||
template <typename A1>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1> > type;
|
||||
struct MatcherTuple< ::testing::tuple<A1> > {
|
||||
typedef ::testing::tuple<Matcher<A1> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
|
||||
Matcher<A4> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8, typename A9>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
|
||||
};
|
||||
|
||||
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||
typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
A10> > {
|
||||
typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
|
||||
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
|
||||
Matcher<A10> > type;
|
||||
};
|
||||
@@ -156,7 +156,7 @@ struct Function;
|
||||
template <typename R>
|
||||
struct Function<R()> {
|
||||
typedef R Result;
|
||||
typedef ::std::tr1::tuple<> ArgumentTuple;
|
||||
typedef ::testing::tuple<> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid();
|
||||
typedef IgnoredValue MakeResultIgnoredValue();
|
||||
@@ -166,7 +166,7 @@ template <typename R, typename A1>
|
||||
struct Function<R(A1)>
|
||||
: Function<R()> {
|
||||
typedef A1 Argument1;
|
||||
typedef ::std::tr1::tuple<A1> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1);
|
||||
@@ -176,7 +176,7 @@ template <typename R, typename A1, typename A2>
|
||||
struct Function<R(A1, A2)>
|
||||
: Function<R(A1)> {
|
||||
typedef A2 Argument2;
|
||||
typedef ::std::tr1::tuple<A1, A2> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
|
||||
@@ -186,7 +186,7 @@ template <typename R, typename A1, typename A2, typename A3>
|
||||
struct Function<R(A1, A2, A3)>
|
||||
: Function<R(A1, A2)> {
|
||||
typedef A3 Argument3;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
|
||||
@@ -196,7 +196,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4>
|
||||
struct Function<R(A1, A2, A3, A4)>
|
||||
: Function<R(A1, A2, A3)> {
|
||||
typedef A4 Argument4;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3, A4> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
|
||||
@@ -207,7 +207,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
struct Function<R(A1, A2, A3, A4, A5)>
|
||||
: Function<R(A1, A2, A3, A4)> {
|
||||
typedef A5 Argument5;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
|
||||
@@ -218,7 +218,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6)>
|
||||
: Function<R(A1, A2, A3, A4, A5)> {
|
||||
typedef A6 Argument6;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
|
||||
@@ -229,7 +229,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
|
||||
: Function<R(A1, A2, A3, A4, A5, A6)> {
|
||||
typedef A7 Argument7;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
|
||||
@@ -240,7 +240,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
|
||||
: Function<R(A1, A2, A3, A4, A5, A6, A7)> {
|
||||
typedef A8 Argument8;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
|
||||
@@ -251,7 +251,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
|
||||
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
|
||||
typedef A9 Argument9;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
|
||||
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
|
||||
@@ -264,7 +264,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
|
||||
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
|
||||
typedef A10 Argument10;
|
||||
typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
A10> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
|
||||
|
||||
@@ -77,8 +77,8 @@ $var typename_As = [[$for j, [[typename A$j]]]]
|
||||
$var As = [[$for j, [[A$j]]]]
|
||||
$var matcher_As = [[$for j, [[Matcher<A$j>]]]]
|
||||
template <$typename_As>
|
||||
struct MatcherTuple< ::std::tr1::tuple<$As> > {
|
||||
typedef ::std::tr1::tuple<$matcher_As > type;
|
||||
struct MatcherTuple< ::testing::tuple<$As> > {
|
||||
typedef ::testing::tuple<$matcher_As > type;
|
||||
};
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ struct Function;
|
||||
template <typename R>
|
||||
struct Function<R()> {
|
||||
typedef R Result;
|
||||
typedef ::std::tr1::tuple<> ArgumentTuple;
|
||||
typedef ::testing::tuple<> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid();
|
||||
typedef IgnoredValue MakeResultIgnoredValue();
|
||||
@@ -121,7 +121,7 @@ template <typename R$typename_As>
|
||||
struct Function<R($As)>
|
||||
: Function<R($prev_As)> {
|
||||
typedef A$i Argument$i;
|
||||
typedef ::std::tr1::tuple<$As> ArgumentTuple;
|
||||
typedef ::testing::tuple<$As> ArgumentTuple;
|
||||
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
|
||||
typedef void MakeResultVoid($As);
|
||||
typedef IgnoredValue MakeResultIgnoredValue($As);
|
||||
|
||||
@@ -361,17 +361,30 @@ template <typename T> struct DecayArray<T[]> {
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
// Invalid<T>() returns an invalid value of type T. This is useful
|
||||
// Disable MSVC warnings for infinite recursion, since in this case the
|
||||
// the recursion is unreachable.
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4717)
|
||||
#endif
|
||||
|
||||
// Invalid<T>() is usable as an expression of type T, but will terminate
|
||||
// the program with an assertion failure if actually run. This is useful
|
||||
// when a value of type T is needed for compilation, but the statement
|
||||
// will not really be executed (or we don't care if the statement
|
||||
// crashes).
|
||||
template <typename T>
|
||||
inline T Invalid() {
|
||||
return const_cast<typename remove_reference<T>::type&>(
|
||||
*static_cast<volatile typename remove_reference<T>::type*>(NULL));
|
||||
Assert(false, "", -1, "Internal error: attempt to return invalid value");
|
||||
// This statement is unreachable, and would never terminate even if it
|
||||
// could be reached. It is provided only to placate compiler warnings
|
||||
// about missing return statements.
|
||||
return Invalid<T>();
|
||||
}
|
||||
template <>
|
||||
inline void Invalid<void>() {}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// Given a raw type (i.e. having no top-level reference or const
|
||||
// modifier) RawContainer that's either an STL-style container or a
|
||||
@@ -434,16 +447,17 @@ class StlContainerView<Element[N]> {
|
||||
// ConstReference(const char * (&)[4])')
|
||||
// (and though the N parameter type is mismatched in the above explicit
|
||||
// conversion of it doesn't help - only the conversion of the array).
|
||||
return type(const_cast<Element*>(&array[0]), N, kReference);
|
||||
return type(const_cast<Element*>(&array[0]), N,
|
||||
RelationToSourceReference());
|
||||
#else
|
||||
return type(array, N, kReference);
|
||||
return type(array, N, RelationToSourceReference());
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
}
|
||||
static type Copy(const Element (&array)[N]) {
|
||||
#if GTEST_OS_SYMBIAN
|
||||
return type(const_cast<Element*>(&array[0]), N, kCopy);
|
||||
return type(const_cast<Element*>(&array[0]), N, RelationToSourceCopy());
|
||||
#else
|
||||
return type(array, N, kCopy);
|
||||
return type(array, N, RelationToSourceCopy());
|
||||
#endif // GTEST_OS_SYMBIAN
|
||||
}
|
||||
};
|
||||
@@ -451,7 +465,7 @@ class StlContainerView<Element[N]> {
|
||||
// This specialization is used when RawContainer is a native array
|
||||
// represented as a (pointer, size) tuple.
|
||||
template <typename ElementPointer, typename Size>
|
||||
class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {
|
||||
class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
|
||||
public:
|
||||
typedef GTEST_REMOVE_CONST_(
|
||||
typename internal::PointeeOf<ElementPointer>::type) RawElement;
|
||||
@@ -459,13 +473,11 @@ class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {
|
||||
typedef const type const_reference;
|
||||
|
||||
static const_reference ConstReference(
|
||||
const ::std::tr1::tuple<ElementPointer, Size>& array) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<0>(array), get<1>(array), kReference);
|
||||
const ::testing::tuple<ElementPointer, Size>& array) {
|
||||
return type(get<0>(array), get<1>(array), RelationToSourceReference());
|
||||
}
|
||||
static type Copy(const ::std::tr1::tuple<ElementPointer, Size>& array) {
|
||||
using ::std::tr1::get;
|
||||
return type(get<0>(array), get<1>(array), kCopy);
|
||||
static type Copy(const ::testing::tuple<ElementPointer, Size>& array) {
|
||||
return type(get<0>(array), get<1>(array), RelationToSourceCopy());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -496,3 +508,4 @@ struct BooleanConstant {};
|
||||
} // namespace testing
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
||||
|
||||
|
||||
@@ -30,8 +30,11 @@
|
||||
// Author: vadimb@google.com (Vadim Berman)
|
||||
//
|
||||
// Low-level types and utilities for porting Google Mock to various
|
||||
// platforms. They are subject to change without notice. DO NOT USE
|
||||
// THEM IN USER CODE.
|
||||
// platforms. All macros ending with _ and symbols defined in an
|
||||
// internal namespace are subject to change without notice. Code
|
||||
// outside Google Mock MUST NOT USE THEM DIRECTLY. Macros that don't
|
||||
// end with _ are part of Google Mock's public API and can be used by
|
||||
// code outside Google Mock.
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
||||
@@ -40,10 +43,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
// Most of the types needed for porting Google Mock are also required
|
||||
// for Google Test and are defined in gtest-port.h.
|
||||
// Most of the utilities needed for porting Google Mock are also
|
||||
// required for Google Test and are defined in gtest-port.h.
|
||||
//
|
||||
// Note to maintainers: to reduce code duplication, prefer adding
|
||||
// portability utilities to Google Test's gtest-port.h instead of
|
||||
// here, as Google Mock depends on Google Test. Only add a utility
|
||||
// here if it's truly specific to Google Mock.
|
||||
#include "gtest/internal/gtest-linked_ptr.h"
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
#include "gmock/internal/custom/gmock-port.h"
|
||||
|
||||
// To avoid conditional compilation everywhere, we make it
|
||||
// gmock-port.h's responsibility to #include the header implementing
|
||||
@@ -60,6 +69,8 @@
|
||||
// use this syntax to reference Google Mock flags.
|
||||
#define GMOCK_FLAG(name) FLAGS_gmock_##name
|
||||
|
||||
#if !defined(GMOCK_DECLARE_bool_)
|
||||
|
||||
// Macros for declaring flags.
|
||||
#define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
|
||||
#define GMOCK_DECLARE_int32_(name) \
|
||||
@@ -75,4 +86,6 @@
|
||||
#define GMOCK_DEFINE_string_(name, default_val, doc) \
|
||||
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
|
||||
|
||||
#endif // !defined(GMOCK_DECLARE_bool_)
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
||||
|
||||
Reference in New Issue
Block a user