gmock-actions.h   gmock-actions.h 
skipping to change at line 41 skipping to change at line 41
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements some commonly used actions. // This file implements some commonly used actions.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#ifndef _WIN32_WCE
#include <errno.h> #include <errno.h>
#endif
#include <gmock/internal/gmock-internal-utils.h> #include <gmock/internal/gmock-internal-utils.h>
#include <gmock/internal/gmock-port.h> #include <gmock/internal/gmock-port.h>
namespace testing { namespace testing {
// To implement an action Foo, define: // To implement an action Foo, define:
// 1. a class FooAction that implements the ActionInterface interface, an d // 1. a class FooAction that implements the ActionInterface interface, an d
// 2. a factory function that creates an Action object from a // 2. a factory function that creates an Action object from a
// const FooAction*. // const FooAction*.
// //
skipping to change at line 72 skipping to change at line 76
class ActionAdaptor; class ActionAdaptor;
// BuiltInDefaultValue<T>::Get() returns the "built-in" default // BuiltInDefaultValue<T>::Get() returns the "built-in" default
// value for type T, which is NULL when T is a pointer type, 0 when T // 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 // 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 // std::string. For any other type T, this value is undefined and the
// function will abort the process. // function will abort the process.
template <typename T> template <typename T>
class BuiltInDefaultValue { class BuiltInDefaultValue {
public: public:
// This function returns true iff type T has a built-in default value.
static bool Exists() { return false; }
static T Get() { static T Get() {
Assert(false, __FILE__, __LINE__, Assert(false, __FILE__, __LINE__,
"Default action undefined for the function return type."); "Default action undefined for the function return type.");
return internal::Invalid<T>(); return internal::Invalid<T>();
// The above statement will never be reached, but is required in // The above statement will never be reached, but is required in
// order for this function to compile. // order for this function to compile.
} }
}; };
// This partial specialization says that we use the same built-in // This partial specialization says that we use the same built-in
// default value for T and const T. // default value for T and const T.
template <typename T> template <typename T>
class BuiltInDefaultValue<const T> { class BuiltInDefaultValue<const T> {
public: public:
static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }
static T Get() { return BuiltInDefaultValue<T>::Get(); } static T Get() { return BuiltInDefaultValue<T>::Get(); }
}; };
// This partial specialization defines the default values for pointer // This partial specialization defines the default values for pointer
// types. // types.
template <typename T> template <typename T>
class BuiltInDefaultValue<T*> { class BuiltInDefaultValue<T*> {
public: public:
static bool Exists() { return true; }
static T* Get() { return NULL; } static T* Get() { return NULL; }
}; };
// The following specializations define the default values for // The following specializations define the default values for
// specific types we care about. // specific types we care about.
#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(type, value) \ #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
template <> \ template <> \
class BuiltInDefaultValue<type> { \ class BuiltInDefaultValue<type> { \
public: \ public: \
static bool Exists() { return true; } \
static type Get() { return value; } \ static type Get() { return value; } \
} }
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(void, ); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT
#if GTEST_HAS_GLOBAL_STRING #if GTEST_HAS_GLOBAL_STRING
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(::string, ""); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, "");
#endif // GTEST_HAS_GLOBAL_STRING #endif // GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_STD_STRING #if GTEST_HAS_STD_STRING
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(::std::string, ""); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, "");
#endif // GTEST_HAS_STD_STRING #endif // GTEST_HAS_STD_STRING
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(bool, false); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(unsigned char, '\0'); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0');
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(signed char, '\0'); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0');
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(char, '\0'); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\0');
// signed wchar_t and unsigned wchar_t are NOT in the C++ standard. // signed wchar_t and unsigned wchar_t are NOT in the C++ standard.
// Using them is a bad practice and not portable. So don't use them. // Using them is a bad practice and not portable. So don't use them.
// //
// Still, Google Mock is designed to work even if the user uses signed // Still, Google Mock is designed to work even if the user uses signed
// wchar_t or unsigned wchar_t (obviously, assuming the compiler // wchar_t or unsigned wchar_t (obviously, assuming the compiler
// supports them). // supports them).
// //
// To gcc, // To gcc,
// //
skipping to change at line 144 skipping to change at line 153
// Therefore we provide a default action for wchar_t when compiled // Therefore we provide a default action for wchar_t when compiled
// with gcc or _NATIVE_WCHAR_T_DEFINED is defined. // with gcc or _NATIVE_WCHAR_T_DEFINED is defined.
// //
// There's no need for a default action for signed wchar_t, as that // There's no need for a default action for signed wchar_t, as that
// type is the same as wchar_t for gcc, and invalid for MSVC. // type is the same as wchar_t for gcc, and invalid for MSVC.
// //
// There's also no need for a default action for unsigned wchar_t, as // There's also no need for a default action for unsigned wchar_t, as
// that type is the same as unsigned int for gcc, and invalid for // that type is the same as unsigned int for gcc, and invalid for
// MSVC. // MSVC.
#if defined(__GNUC__) || defined(_NATIVE_WCHAR_T_DEFINED) #if defined(__GNUC__) || defined(_NATIVE_WCHAR_T_DEFINED)
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(wchar_t, 0U); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U); // NOLINT
#endif #endif
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(unsigned short, 0U); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLIN
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(signed short, 0); // NOLINT T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(unsigned int, 0U); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLIN
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(signed int, 0); T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(unsigned long, 0UL); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(signed long, 0L); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(UInt64, 0); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLIN
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(Int64, 0); T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(float, 0); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLIN
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE(double, 0); T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE #undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
} // namespace internal } // namespace internal
// When an unexpected function call is encountered, Google Mock will // When an unexpected function call is encountered, Google Mock will
// let it return a default value if the user has specified one for its // let it return a default value if the user has specified one for its
// return type, or if the return type has a built-in default value; // return type, or if the return type has a built-in default value;
// otherwise Google Mock won't know what value to return and will have // otherwise Google Mock won't know what value to return and will have
// to abort the process. // to abort the process.
// //
// The DefaultValue<T> class allows a user to specify the // The DefaultValue<T> class allows a user to specify the
skipping to change at line 194 skipping to change at line 203
// Unsets the default value for type T. // Unsets the default value for type T.
static void Clear() { static void Clear() {
delete value_; delete value_;
value_ = NULL; value_ = NULL;
} }
// Returns true iff the user has set the default value for type T. // Returns true iff the user has set the default value for type T.
static bool IsSet() { return value_ != NULL; } static bool IsSet() { return value_ != NULL; }
// Returns true if T has a default return value set by the user or there
// exists a built-in default value.
static bool Exists() {
return IsSet() || internal::BuiltInDefaultValue<T>::Exists();
}
// Returns the default value for type T if the user has set one; // 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 returns the built-in default value if there is one;
// otherwise aborts the process. // otherwise aborts the process.
static T Get() { static T Get() {
return value_ == NULL ? return value_ == NULL ?
internal::BuiltInDefaultValue<T>::Get() : *value_; internal::BuiltInDefaultValue<T>::Get() : *value_;
} }
private: private:
static const T* value_; static const T* value_;
}; };
skipping to change at line 223 skipping to change at line 238
} }
// Unsets the default value for type T&. // Unsets the default value for type T&.
static void Clear() { static void Clear() {
address_ = NULL; address_ = NULL;
} }
// Returns true iff the user has set the default value for type T&. // Returns true iff the user has set the default value for type T&.
static bool IsSet() { return address_ != NULL; } static bool IsSet() { return address_ != NULL; }
// Returns true if T has a default return value set by the user or there
// exists a built-in default value.
static bool Exists() {
return IsSet() || internal::BuiltInDefaultValue<T&>::Exists();
}
// Returns the default value for type T& if the user has set one; // 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 returns the built-in default value if there is one;
// otherwise aborts the process. // otherwise aborts the process.
static T& Get() { static T& Get() {
return address_ == NULL ? return address_ == NULL ?
internal::BuiltInDefaultValue<T&>::Get() : *address_; internal::BuiltInDefaultValue<T&>::Get() : *address_;
} }
private: private:
static T* address_; static T* address_;
}; };
// This specialization allows DefaultValue<void>::Get() to // This specialization allows DefaultValue<void>::Get() to
// compile. // compile.
template <> template <>
class DefaultValue<void> { class DefaultValue<void> {
public: public:
static bool Exists() { return true; }
static void Get() {} static void Get() {}
}; };
// Points to the user-set default value for type T. // Points to the user-set default value for type T.
template <typename T> template <typename T>
const T* DefaultValue<T>::value_ = NULL; const T* DefaultValue<T>::value_ = NULL;
// Points to the user-set default value for type T&. // Points to the user-set default value for type T&.
template <typename T> template <typename T>
T* DefaultValue<T&>::address_ = NULL; T* DefaultValue<T&>::address_ = NULL;
skipping to change at line 445 skipping to change at line 467
operator Action<F>() const { operator Action<F>() const {
// Assert statement belongs here because this is the best place to veri fy // Assert statement belongs here because this is the best place to veri fy
// conditions on F. It produces the clearest error messages // conditions on F. It produces the clearest error messages
// in most compilers. // in most compilers.
// Impl really belongs in this scope as a local class but can't // Impl really belongs in this scope as a local class but can't
// because MSVC produces duplicate symbols in different translation uni ts // because MSVC produces duplicate symbols in different translation uni ts
// in this case. Until MS fixes that bug we put Impl into the class sco pe // in this case. Until MS fixes that bug we put Impl into the class sco pe
// and put the typedef both here (for use in assert statement) and // and put the typedef both here (for use in assert statement) and
// in the Impl class. But both definitions must be the same. // in the Impl class. But both definitions must be the same.
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
GMOCK_COMPILE_ASSERT(!internal::is_reference<Result>::value, GMOCK_COMPILE_ASSERT_(
use_ReturnRef_instead_of_Return_to_return_a_refere !internal::is_reference<Result>::value,
nce); use_ReturnRef_instead_of_Return_to_return_a_reference);
return Action<F>(new Impl<F>(value_)); return Action<F>(new Impl<F>(value_));
} }
private: private:
// Implements the Return(x) action for a particular function type F. // Implements the Return(x) action for a particular function type F.
template <typename F> template <typename F>
class Impl : public ActionInterface<F> { class Impl : public ActionInterface<F> {
public: public:
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
typedef typename Function<F>::ArgumentTuple ArgumentTuple; typedef typename Function<F>::ArgumentTuple ArgumentTuple;
skipping to change at line 474 skipping to change at line 497
R value_; R value_;
}; };
// Implements the ReturnNull() action. // Implements the ReturnNull() action.
class ReturnNullAction { class ReturnNullAction {
public: public:
// Allows ReturnNull() to be used in any pointer-returning function. // Allows ReturnNull() to be used in any pointer-returning function.
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
static Result Perform(const ArgumentTuple&) { static Result Perform(const ArgumentTuple&) {
GMOCK_COMPILE_ASSERT(internal::is_pointer<Result>::value, GMOCK_COMPILE_ASSERT_(internal::is_pointer<Result>::value,
ReturnNull_can_be_used_to_return_a_pointer_only); ReturnNull_can_be_used_to_return_a_pointer_only);
return NULL; return NULL;
} }
}; };
// Implements the Return() action. // Implements the Return() action.
class ReturnVoidAction { class ReturnVoidAction {
public: public:
// Allows Return() to be used in any void-returning function. // Allows Return() to be used in any void-returning function.
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
static void Perform(const ArgumentTuple&) { static void Perform(const ArgumentTuple&) {
skipping to change at line 507 skipping to change at line 530
explicit ReturnRefAction(T& ref) : ref_(ref) {} // NOLINT explicit ReturnRefAction(T& ref) : ref_(ref) {} // NOLINT
// This template type conversion operator allows ReturnRef(x) to be // This template type conversion operator allows ReturnRef(x) to be
// used in ANY function that returns a reference to x's type. // used in ANY function that returns a reference to x's type.
template <typename F> template <typename F>
operator Action<F>() const { operator Action<F>() const {
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
// Asserts that the function return type is a reference. This // Asserts that the function return type is a reference. This
// catches the user error of using ReturnRef(x) when Return(x) // catches the user error of using ReturnRef(x) when Return(x)
// should be used, and generates some helpful error message. // should be used, and generates some helpful error message.
GMOCK_COMPILE_ASSERT(internal::is_reference<Result>::value, GMOCK_COMPILE_ASSERT_(internal::is_reference<Result>::value,
use_Return_instead_of_ReturnRef_to_return_a_value); use_Return_instead_of_ReturnRef_to_return_a_value
);
return Action<F>(new Impl<F>(ref_)); return Action<F>(new Impl<F>(ref_));
} }
private: private:
// Implements the ReturnRef(x) action for a particular function type F. // Implements the ReturnRef(x) action for a particular function type F.
template <typename F> template <typename F>
class Impl : public ActionInterface<F> { class Impl : public ActionInterface<F> {
public: public:
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
typedef typename Function<F>::ArgumentTuple ArgumentTuple; typedef typename Function<F>::ArgumentTuple ArgumentTuple;
skipping to change at line 585 skipping to change at line 608
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
void Perform(const ArgumentTuple &args) const { void Perform(const ArgumentTuple &args) const {
*ptr_ = value_; *ptr_ = value_;
} }
private: private:
T1* const ptr_; T1* const ptr_;
const T2 value_; const T2 value_;
}; };
#ifndef _WIN32_WCE
// Implements the SetErrnoAndReturn action to simulate return from // Implements the SetErrnoAndReturn action to simulate return from
// various system calls and libc functions. // various system calls and libc functions.
template <typename T> template <typename T>
class SetErrnoAndReturnAction { class SetErrnoAndReturnAction {
public: public:
SetErrnoAndReturnAction(int errno_value, T result) SetErrnoAndReturnAction(int errno_value, T result)
: errno_(errno_value), : errno_(errno_value),
result_(result) {} result_(result) {}
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple &args) const { Result Perform(const ArgumentTuple &args) const {
errno = errno_; errno = errno_;
return result_; return result_;
} }
private: private:
const int errno_; const int errno_;
const T result_; const T result_;
}; };
#endif // _WIN32_WCE
// Implements the SetArgumentPointee<N>(x) action for any function // Implements the SetArgumentPointee<N>(x) action for any function
// whose N-th argument (0-based) is a pointer to x's type. The // whose N-th argument (0-based) is a pointer to x's type. The
// template parameter kIsProto is true iff type A is ProtocolMessage, // template parameter kIsProto is true iff type A is ProtocolMessage,
// proto2::Message, or a sub-class of those. // proto2::Message, or a sub-class of those.
template <size_t N, typename A, bool kIsProto> template <size_t N, typename A, bool kIsProto>
class SetArgumentPointeeAction { class SetArgumentPointeeAction {
public: public:
// Constructs an action that sets the variable pointed to by the // Constructs an action that sets the variable pointed to by the
// N-th function argument to 'value'. // N-th function argument to 'value'.
explicit SetArgumentPointeeAction(const A& value) : value_(value) {} explicit SetArgumentPointeeAction(const A& value) : value_(value) {}
skipping to change at line 662 skipping to change at line 689
explicit SetArrayArgumentAction(InputIterator first, InputIterator last) explicit SetArrayArgumentAction(InputIterator first, InputIterator last)
: first_(first), last_(last) { : first_(first), last_(last) {
} }
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
void Perform(const ArgumentTuple& args) const { void Perform(const ArgumentTuple& args) const {
CompileAssertTypesEqual<void, Result>(); CompileAssertTypesEqual<void, Result>();
// Microsoft compiler deprecates ::std::copy, so we want to suppress wa rning // Microsoft compiler deprecates ::std::copy, so we want to suppress wa rning
// 4996 (Function call with parameters that may be unsafe) there. // 4996 (Function call with parameters that may be unsafe) there.
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996. #pragma warning(disable:4996) // Temporarily disables warning 4996.
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
::std::copy(first_, last_, ::std::tr1::get<N>(args)); ::std::copy(first_, last_, ::std::tr1::get<N>(args));
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
} }
private: private:
const InputIterator first_; const InputIterator first_;
const InputIterator last_; const InputIterator last_;
}; };
// Implements the InvokeWithoutArgs(f) action. The template argument // Implements the InvokeWithoutArgs(f) action. The template argument
skipping to change at line 862 skipping to change at line 889
return MakePolymorphicAction(internal::SetArrayArgumentAction< return MakePolymorphicAction(internal::SetArrayArgumentAction<
N, InputIterator>(first, last)); N, InputIterator>(first, last));
} }
// Creates an action that sets a pointer referent to a given value. // Creates an action that sets a pointer referent to a given value.
template <typename T1, typename T2> template <typename T1, typename T2>
PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) { PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val)); return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
} }
#ifndef _WIN32_WCE
// Creates an action that sets errno and returns the appropriate error. // Creates an action that sets errno and returns the appropriate error.
template <typename T> template <typename T>
PolymorphicAction<internal::SetErrnoAndReturnAction<T> > PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
SetErrnoAndReturn(int errval, T result) { SetErrnoAndReturn(int errval, T result) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::SetErrnoAndReturnAction<T>(errval, result)); internal::SetErrnoAndReturnAction<T>(errval, result));
} }
#endif // _WIN32_WCE
// Various overloads for InvokeWithoutArgs(). // Various overloads for InvokeWithoutArgs().
// Creates an action that invokes 'function_impl' with no argument. // Creates an action that invokes 'function_impl' with no argument.
template <typename FunctionImpl> template <typename FunctionImpl>
PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> > PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
InvokeWithoutArgs(FunctionImpl function_impl) { InvokeWithoutArgs(FunctionImpl function_impl) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl)); internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl));
} }
 End of changes. 26 change blocks. 
29 lines changed or deleted 64 lines changed or added


 gmock-generated-actions.h   gmock-generated-actions.h 
skipping to change at line 705 skipping to change at line 705
const A5 arg5_; const A5 arg5_;
const A6 arg6_; const A6 arg6_;
const A7 arg7_; const A7 arg7_;
const A8 arg8_; const A8 arg8_;
const A9 arg9_; const A9 arg9_;
const A10 arg10_; const A10 arg10_;
}; };
// An INTERNAL macro for extracting the type of a tuple field. It's // An INTERNAL macro for extracting the type of a tuple field. It's
// subject to change without notice - DO NOT USE IN USER CODE! // subject to change without notice - DO NOT USE IN USER CODE!
#define GMOCK_FIELD(Tuple, N) \ #define GMOCK_FIELD_(Tuple, N) \
typename ::std::tr1::tuple_element<N, Tuple>::type typename ::std::tr1::tuple_element<N, Tuple>::type
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the // 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 // 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 // k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
// type, and whose return type is Result. For example, // type, and whose return type is Result. For example,
// SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::ty pe // SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::ty pe
// is int(bool, long). // is int(bool, long).
// //
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args) // SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
skipping to change at line 730 skipping to change at line 730
// returns ::std::tr1::tuple (2.5, true). // returns ::std::tr1::tuple (2.5, true).
// //
// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be // 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 // in the range [0, 10]. Duplicates are allowed and they don't have
// to be in an ascending or descending order. // to be in an ascending or descending order.
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
int k4, int k5, int k6, int k7, int k8, int k9, int k10> int k4, int k5, int k6, int k7, int k8, int k9, int k10>
class SelectArgs { class SelectArgs {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
GMOCK_FIELD(ArgumentTuple, k4), GMOCK_FIELD(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
GMOCK_FIELD(ArgumentTuple, k6), GMOCK_FIELD(ArgumentTuple, k7), GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
GMOCK_FIELD(ArgumentTuple, k8), GMOCK_FIELD(ArgumentTuple, k9), GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
GMOCK_FIELD(ArgumentTuple, k10)); GMOCK_FIELD_(ArgumentTuple, k10));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
get<k8>(args), get<k9>(args), get<k10>(args)); get<k8>(args), get<k9>(args), get<k10>(args));
} }
}; };
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
skipping to change at line 761 skipping to change at line 761
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(); return SelectedArgs();
} }
}; };
template <typename Result, typename ArgumentTuple, int k1> template <typename Result, typename ArgumentTuple, int k1>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1)); typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args)); return SelectedArgs(get<k1>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2> template <typename Result, typename ArgumentTuple, int k1, int k2>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> { k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2)); GMOCK_FIELD_(ArgumentTuple, k2));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args)); return SelectedArgs(get<k1>(args), get<k2>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3> template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> { k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3)); GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args)); return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
int k4> int k4>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> { k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
GMOCK_FIELD(ArgumentTuple, k4)); GMOCK_FIELD_(ArgumentTuple, k4));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args)); get<k4>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
int k4, int k5> int k4, int k5>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> { k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
GMOCK_FIELD(ArgumentTuple, k4), GMOCK_FIELD(ArgumentTuple, k5)); GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args)); get<k4>(args), get<k5>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
int k4, int k5, int k6> int k4, int k5, int k6>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> { k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
GMOCK_FIELD(ArgumentTuple, k4), GMOCK_FIELD(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
GMOCK_FIELD(ArgumentTuple, k6)); GMOCK_FIELD_(ArgumentTuple, k6));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args)); get<k4>(args), get<k5>(args), get<k6>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
int k4, int k5, int k6, int k7> int k4, int k5, int k6, int k7>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> { k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
GMOCK_FIELD(ArgumentTuple, k4), GMOCK_FIELD(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
GMOCK_FIELD(ArgumentTuple, k6), GMOCK_FIELD(ArgumentTuple, k7)); GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args)); get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
int k4, int k5, int k6, int k7, int k8> int k4, int k5, int k6, int k7, int k8>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> { k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
GMOCK_FIELD(ArgumentTuple, k4), GMOCK_FIELD(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
GMOCK_FIELD(ArgumentTuple, k6), GMOCK_FIELD(ArgumentTuple, k7), GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
GMOCK_FIELD(ArgumentTuple, k8)); GMOCK_FIELD_(ArgumentTuple, k8));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
get<k8>(args)); get<k8>(args));
} }
}; };
template <typename Result, typename ArgumentTuple, int k1, int k2, int k3, template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
int k4, int k5, int k6, int k7, int k8, int k9> int k4, int k5, int k6, int k7, int k8, int k9>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> { k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {
public: public:
typedef Result type(GMOCK_FIELD(ArgumentTuple, k1), typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
GMOCK_FIELD(ArgumentTuple, k2), GMOCK_FIELD(ArgumentTuple, k3), GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
GMOCK_FIELD(ArgumentTuple, k4), GMOCK_FIELD(ArgumentTuple, k5), GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
GMOCK_FIELD(ArgumentTuple, k6), GMOCK_FIELD(ArgumentTuple, k7), GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
GMOCK_FIELD(ArgumentTuple, k8), GMOCK_FIELD(ArgumentTuple, k9)); GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
typedef typename Function<type>::ArgumentTuple SelectedArgs; typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) { static SelectedArgs Select(const ArgumentTuple& args) {
using ::std::tr1::get; using ::std::tr1::get;
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args), return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args), get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
get<k8>(args), get<k9>(args)); get<k8>(args), get<k9>(args));
} }
}; };
#undef GMOCK_FIELD #undef GMOCK_FIELD_
// Implements the WithArgs action. // Implements the WithArgs action.
template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1, template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
int k9 = -1, int k10 = -1> int k9 = -1, int k10 = -1>
class WithArgsAction { class WithArgsAction {
public: public:
explicit WithArgsAction(const InnerAction& action) : action_(action) {} explicit WithArgsAction(const InnerAction& action) : action_(action) {}
template <typename F> template <typename F>
operator Action<F>() const { operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
private:
template <typename F>
class Impl : public ActionInterface<F> {
public:
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
typedef typename Function<F>::ArgumentTuple ArgumentTuple; typedef typename Function<F>::ArgumentTuple ArgumentTuple;
typedef typename SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type
InnerFunctionType;
class Impl : public ActionInterface<F> { explicit Impl(const InnerAction& action) : action_(action) {}
public:
explicit Impl(const InnerAction& action) : action_(action) {}
virtual Result Perform(const ArgumentTuple& args) { virtual Result Perform(const ArgumentTuple& args) {
return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3 return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3,
, k4,
k4, k5, k6, k7, k8, k9, k10>::Select(args)); k5, k6, k7, k8, k9, k10>::Select(args));
} }
private:
Action<InnerFunctionType> action_; private:
}; typedef typename SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
Action<InnerFunctionType> action_;
};
return MakeAction(new Impl(action_));
}
private:
const InnerAction action_; const InnerAction action_;
}; };
// Does two actions sequentially. Used for implementing the DoAll(a1, // Does two actions sequentially. Used for implementing the DoAll(a1,
// a2, ...) action. // a2, ...) action.
template <typename Action1, typename Action2> template <typename Action1, typename Action2>
class DoBothAction { class DoBothAction {
public: public:
DoBothAction(Action1 action1, Action2 action2) DoBothAction(Action1 action1, Action2 action2)
: action1_(action1), action2_(action2) {} : action1_(action1), action2_(action2) {}
// This template type conversion operator allows DoAll(a1, ..., a_n) // This template type conversion operator allows DoAll(a1, ..., a_n)
// to be used in ANY function of compatible type. // to be used in ANY function of compatible type.
template <typename F> template <typename F>
operator Action<F>() const { operator Action<F>() const {
return Action<F>(new Impl<F>(action1_, action2_));
}
private:
// Implements the DoAll(...) action for a particular function type F.
template <typename F>
class Impl : public ActionInterface<F> {
public:
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
typedef typename Function<F>::ArgumentTuple ArgumentTuple; typedef typename Function<F>::ArgumentTuple ArgumentTuple;
typedef typename Function<F>::MakeResultVoid VoidResult; typedef typename Function<F>::MakeResultVoid VoidResult;
// Implements the DoAll(...) action for a particular function type F. Impl(const Action<VoidResult>& action1, const Action<F>& action2)
class Impl : public ActionInterface<F> { : action1_(action1), action2_(action2) {}
public:
Impl(const Action<VoidResult>& action1, const Action<F>& action2)
: action1_(action1), action2_(action2) {}
virtual Result Perform(const ArgumentTuple& args) { virtual Result Perform(const ArgumentTuple& args) {
action1_.Perform(args); action1_.Perform(args);
return action2_.Perform(args); return action2_.Perform(args);
} }
private:
const Action<VoidResult> action1_; private:
const Action<F> action2_; const Action<VoidResult> action1_;
}; const Action<F> action2_;
};
return Action<F>(new Impl(action1_, action2_));
}
private:
Action1 action1_; Action1 action1_;
Action2 action2_; Action2 action2_;
}; };
// A macro from the ACTION* family (defined later in this file)
// defines an action that can be used in a mock function. Typically,
// these actions only care about a subset of the arguments of the mock
// function. For example, if such an action only uses the second
// argument, it can be used in any mock function that takes >= 2
// arguments where the type of the second argument is compatible.
//
// Therefore, the action implementation must be prepared to take more
// arguments than it needs. The ExcessiveArg type is used to
// represent those excessive arguments. In order to keep the compiler
// error messages tractable, we define it in the testing namespace
// instead of testing::internal. However, this is an INTERNAL TYPE
// and subject to change without notice, so a user MUST NOT USE THIS
// TYPE DIRECTLY.
struct ExcessiveArg {};
// A helper class needed for implementing the ACTION* macros.
template <typename Result, class Impl>
class ActionHelper {
public:
static Result Perform(Impl* impl, const ::std::tr1::tuple<>& args) {
using ::std::tr1::get;
return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0>
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0>& args) {
using ::std::tr1::get;
return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0, typename A1>
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1>& args)
{
using ::std::tr1::get;
return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2>
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2>& ar
gs) {
using ::std::tr1::get;
return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3>
static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2,
A3>& args) {
using ::std::tr1::get;
return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(ar
gs),
get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4
>
static Result Perform(Impl* impl, const ::std::tr1::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(),
ExcessiveArg());
}
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,
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(),
ExcessiveArg());
}
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,
A5, A6>& args) {
using ::std::tr1::get;
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(arg
s,
get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args
),
get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4
,
typename A5, typename A6, typename A7>
static Result Perform(Impl* impl, const ::std::tr1::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), ExcessiveAr
g(),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4
,
typename A5, typename A6, typename A7, typename A8>
static Result Perform(Impl* impl, const ::std::tr1::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
),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4
,
typename A5, typename A6, typename A7, typename A8, typename A9>
static Result Perform(Impl* impl, const ::std::tr1::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
),
get<9>(args));
}
};
} // namespace internal } // namespace internal
// Various overloads for Invoke(). // Various overloads for Invoke().
// Creates an action that invokes 'function_impl' with the mock // Creates an action that invokes 'function_impl' with the mock
// function's arguments. // function's arguments.
template <typename FunctionImpl> template <typename FunctionImpl>
PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke( PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
FunctionImpl function_impl) { FunctionImpl function_impl) {
return MakePolymorphicAction( return MakePolymorphicAction(
skipping to change at line 1328 skipping to change at line 1463
internal::DoBothAction<Action5, internal::DoBothAction<Action6, internal::DoBothAction<Action5, internal::DoBothAction<Action6,
internal::DoBothAction<Action7, internal::DoBothAction<Action8, internal::DoBothAction<Action7, internal::DoBothAction<Action8,
internal::DoBothAction<Action9, Action10> > > > > > > > > internal::DoBothAction<Action9, Action10> > > > > > > > >
DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a 6, DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a 6,
Action7 a7, Action8 a8, Action9 a9, Action10 a10) { Action7 a7, Action8 a8, Action9 a9, Action10 a10) {
return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10)); return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
} }
} // namespace testing } // namespace testing
// The ACTION* family of macros can be used in a namespace scope to
// define custom actions easily. The syntax:
//
// ACTION(name) { statements; }
//
// will define an action with the given name that executes the
// statements. The value returned by the statements will be used as
// the return value of the action. Inside the statements, you can
// refer to the K-th (0-based) argument of the mock function by
// 'argK', and refer to its type by 'argK_type'. For example:
//
// ACTION(IncrementArg1) {
// arg1_type temp = arg1;
// return ++(*temp);
// }
//
// allows you to write
//
// ...WillOnce(IncrementArg1());
//
// You can also refer to the entire argument tuple and its type by
// 'args' and 'args_type', and refer to the mock function type and its
// return type by 'function_type' and 'return_type'.
//
// Note that you don't need to specify the types of the mock function
// arguments. However rest assured that your code is still type-safe:
// you'll get a compiler error if *arg1 doesn't support the ++
// operator, or if the type of ++(*arg1) isn't compatible with the
// mock function's return type, for example.
//
// Sometimes you'll want to parameterize the action. For that you can use
// another macro:
//
// ACTION_P(name, param_name) { statements; }
//
// For example:
//
// ACTION_P(Add, n) { return arg0 + n; }
//
// will allow you to write:
//
// ...WillOnce(Add(5));
//
// Note that you don't need to provide the type of the parameter
// either. If you need to reference the type of a parameter named
// 'foo', you can write 'foo_type'. For example, in the body of
// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
// of 'n'.
//
// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support
// multi-parameter actions.
//
// For the purpose of typing, you can view
//
// ACTION_Pk(Foo, p1, ..., pk) { ... }
//
// as shorthand for
//
// template <typename p1_type, ..., typename pk_type>
// FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) {
... }
//
// In particular, you can provide the template type arguments
// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
// although usually you can rely on the compiler to infer the types
// for you automatically. You can assign the result of expression
// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
// pk_type>. This can be useful when composing actions.
//
// You can also overload actions with different numbers of parameters:
//
// ACTION_P(Plus, a) { ... }
// ACTION_P2(Plus, a, b) { ... }
//
// While it's tempting to always use the ACTION* macros when defining
// a new action, you should also consider implementing ActionInterface
// or using MakePolymorphicAction() instead, especially if you need to
// use the action a lot. While these approaches require more work,
// they give you more control on the types of the mock function
// arguments and the action parameters, which in general leads to
// better compiler error messages that pay off in the long run. They
// also allow overloading actions based on parameter types (as opposed
// to just based on the number of parameters).
//
// CAVEAT:
//
// ACTION*() can only be used in a namespace scope. The reason is
// that C++ doesn't yet allow function-local types to be used to
// instantiate templates. The up-coming C++0x standard will fix this.
// Once that's done, we'll consider supporting using ACTION*() inside
// a function.
//
// MORE INFORMATION:
//
// To learn more about using these macros, please search for 'ACTION'
// on http://code.google.com/p/googlemock/wiki/CookBook.
#define ACTION(name)\
class name##Action {\
public:\
name##Action() {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl() {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>());\
}\
};\
inline name##Action name() {\
return name##Action();\
}\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##Action::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P(name, p0)\
template <typename p0##_type>\
class name##ActionP {\
public:\
name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0));\
}\
p0##_type p0;\
};\
template <typename p0##_type>\
inline name##ActionP<p0##_type> name(p0##_type p0) {\
return name##ActionP<p0##_type>(p0);\
}\
template <typename p0##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP<p0##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P2(name, p0, p1)\
template <typename p0##_type, typename p1##_type>\
class name##ActionP2 {\
public:\
name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0),
\
p1(gmock_p1) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
p1(gmock_p1) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
}\
p0##_type p0;\
p1##_type p1;\
};\
template <typename p0##_type, typename p1##_type>\
inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
p1##_type p1) {\
return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
}\
template <typename p0##_type, typename p1##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP2<p0##_type, p1##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P3(name, p0, p1, p2)\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
class name##ActionP3 {\
public:\
name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}
\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0,
\
p1##_type p1, p2##_type p2) {\
return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP3<p0##_type, p1##_type, p2##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P4(name, p0, p1, p2, p3)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
class name##ActionP4 {\
public:\
name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1
), \
p2(gmock_p2), p3(gmock_p3) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
inline name##ActionP4<p0##_type, p1##_type, p2##_type, \
p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
p3##_type p3) {\
return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p
1, \
p2, p3);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P5(name, p0, p1, p2, p3, p4)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
class name##ActionP5 {\
public:\
name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, \
p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \
p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \
p4##_type p4) {\
return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type>(p0, p1, p2, p3, p4);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type>
::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
class name##ActionP6 {\
public:\
name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5)
);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2,
\
p3##_type p3, p4##_type p4, p5##_type p5) {\
return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type,
\
p5##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\
class name##ActionP7 {\
public:\
name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1
), \
p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
p6(gmock_p6) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\
p6));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\
inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
p6##_type p6) {\
return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type,
\
p5##_type, p6##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\
class name##ActionP8 {\
public:\
name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, \
p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
p7(gmock_p7) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \
p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \
p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\
p6, p7));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\
inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5,
\
p6##_type p6, p7##_type p7) {\
return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5,
\
p6, p7);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type,
\
p5##_type, p6##_type, p7##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\
class name##ActionP9 {\
public:\
name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7
), \
p8(gmock_p8) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, \
p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
p7(gmock_p7), p8(gmock_p8) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\
p6, p7, p8));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\
inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, \
p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \
p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
p8##_type p8) {\
return name##ActionP9<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);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type,
\
p5##_type, p6##_type, p7##_type, p8##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
#define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\
class name##ActionP10 {\
public:\
name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1
), \
p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6
), \
p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\
typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type
;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\
args_type;\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
virtual return_type Perform(const args_type& args) {\
return ::testing::internal::ActionHelper<return_type, gmock_Impl>::
\
Perform(this, args);\
}\
template <typename arg0_type, typename arg1_type, typename arg2_type,
\
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
p9##_type p9;\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\
p6, p7, p8, p9));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
p9##_type p9;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\
inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \
p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8,
\
p9##_type p9) {\
return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p
0, \
p1, p2, p3, p4, p5, p6, p7, p8, p9);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\
template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\
typename ::testing::internal::Function<F>::Result\
name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
, \
p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>::\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg
3, \
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg
7, \
arg8_type arg8, arg9_type arg9) const
// TODO(wan@google.com): move the following to a different .h file
// such that we don't have to run 'pump' every time the code is
// updated.
namespace testing {
namespace internal {
// Saves argument #0 to where the pointer points.
ACTION_P(SaveArg0, pointer) { *pointer = arg0; }
// Assigns 'value' to the variable referenced by argument #0.
ACTION_P(SetArg0Referee, value) {
// Ensures that argument #0 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.
GMOCK_COMPILE_ASSERT_(internal::is_reference<arg0_type>::value,
SetArgReferee_must_be_used_with_a_reference_argumen
t);
arg0 = value;
}
} // namespace internal
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
// mock function to *pointer.
template <int k, typename Pointer>
inline internal::WithArgsAction<internal::SaveArg0ActionP<Pointer>, k>
SaveArg(const Pointer& pointer) {
return WithArg<k>(internal::SaveArg0(pointer));
}
// Action SetArgReferee<k>(value) assigns 'value' to the variable
// referenced by the k-th (0-based) argument of the mock function.
template <int k, typename Value>
inline internal::WithArgsAction<internal::SetArg0RefereeActionP<Value>, k>
SetArgReferee(const Value& value) {
return WithArg<k>(internal::SetArg0Referee(value));
}
// Action Throw(exception) can be used in a mock function of any type
// to throw the given exception. Any copyable value can be thrown.
#if GTEST_HAS_EXCEPTIONS
ACTION_P(Throw, exception) { throw exception; }
#endif // GTEST_HAS_EXCEPTIONS
} // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
 End of changes. 23 change blocks. 
71 lines changed or deleted 1230 lines changed or added


 gmock-generated-function-mockers.h   gmock-generated-function-mockers.h 
skipping to change at line 288 skipping to change at line 288
// The style guide prohibits "using" statements in a namespace scope // The style guide prohibits "using" statements in a namespace scope
// inside a header file. However, the FunctionMocker class template // inside a header file. However, the FunctionMocker class template
// is meant to be defined in the ::testing namespace. The following // is meant to be defined in the ::testing namespace. The following
// line is just a trick for working around a bug in MSVC 8.0, which // line is just a trick for working around a bug in MSVC 8.0, which
// cannot handle it if we define FunctionMocker in ::testing. // cannot handle it if we define FunctionMocker in ::testing.
using internal::FunctionMocker; using internal::FunctionMocker;
// The result type of function type F. // The result type of function type F.
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_RESULT(tn, F) tn ::testing::internal::Function<F>::Result #define GMOCK_RESULT_(tn, F) tn ::testing::internal::Function<F>::Result
// The type of argument N of function type F. // The type of argument N of function type F.
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_ARG(tn, F, N) tn ::testing::internal::Function<F>::Argument## N #define GMOCK_ARG_(tn, F, N) tn ::testing::internal::Function<F>::Argument# #N
// The matcher type for argument N of function type F. // The matcher type for argument N of function type F.
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_MATCHER(tn, F, N) const ::testing::Matcher<GMOCK_ARG(tn, F, N )>& #define GMOCK_MATCHER_(tn, F, N) const ::testing::Matcher<GMOCK_ARG_(tn, F, N)>&
// The variable for mocking the given method. // The variable for mocking the given method.
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_MOCKER(Method) GMOCK_CONCAT_TOKEN(gmock_##Method##_, __LINE__ ) #define GMOCK_MOCKER_(Method) GMOCK_CONCAT_TOKEN_(gmock_##Method##_, __LINE __)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD0(tn, constness, ct, Method, F) \ #define GMOCK_METHOD0_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method() constness { \ GMOCK_RESULT_(tn, F) ct Method() constness { \
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 0, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 0, \
this_method_does_not_take_0_arguments); \ this_method_does_not_take_0_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(); \ return GMOCK_MOCKER_(Method).Invoke(); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method() constness { \ gmock_##Method() constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(); \ return GMOCK_MOCKER_(Method).RegisterOwner(this).With(); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD1(tn, constness, ct, Method, F) \ #define GMOCK_METHOD1_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1) constness { \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 1, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 1, \
this_method_does_not_take_1_argument); \ this_method_does_not_take_1_argument); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1); \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1) constness { \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1); \ return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD2(tn, constness, ct, Method, F) \ #define GMOCK_METHOD2_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2) constness { \ GMOCK_ARG_(tn, F, 2) gmock_a2) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 2, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 2, \
this_method_does_not_take_2_arguments); \ this_method_does_not_take_2_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2); \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2) constness { \ GMOCK_MATCHER_(tn, F, 2) gmock_a2) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
); \ 2); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD3(tn, constness, ct, Method, F) \ #define GMOCK_METHOD3_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3) constness { \ GMOCK_ARG_(tn, F, 3) gmock_a3) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 3, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 3, \
this_method_does_not_take_3_arguments); \ this_method_does_not_take_3_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3); \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3) constness { \ GMOCK_MATCHER_(tn, F, 3) gmock_a3) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3); \ gmock_a3); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD4(tn, constness, ct, Method, F) \ #define GMOCK_METHOD4_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3, \ GMOCK_ARG_(tn, F, 3) gmock_a3, \
GMOCK_ARG(tn, F, 4) gmock_a4) constness { \ GMOCK_ARG_(tn, F, 4) gmock_a4) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 4, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 4, \
this_method_does_not_take_4_arguments); \ this_method_does_not_take_4_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \
gmock_a4); \ gmock_a4); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3, \ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
GMOCK_MATCHER(tn, F, 4) gmock_a4) constness { \ GMOCK_MATCHER_(tn, F, 4) gmock_a4) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3, gmock_a4); \ gmock_a3, gmock_a4); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD5(tn, constness, ct, Method, F) \ #define GMOCK_METHOD5_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3, \ GMOCK_ARG_(tn, F, 3) gmock_a3, \
GMOCK_ARG(tn, F, 4) gmock_a4, \ GMOCK_ARG_(tn, F, 4) gmock_a4, \
GMOCK_ARG(tn, F, 5) gmock_a5) constness { \ GMOCK_ARG_(tn, F, 5) gmock_a5) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 5, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 5, \
this_method_does_not_take_5_arguments); \ this_method_does_not_take_5_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \
gmock_a4, gmock_a5); \ gmock_a4, gmock_a5); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3, \ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
GMOCK_MATCHER(tn, F, 4) gmock_a4, \ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
GMOCK_MATCHER(tn, F, 5) gmock_a5) constness { \ GMOCK_MATCHER_(tn, F, 5) gmock_a5) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3, gmock_a4, gmock_a5); \ gmock_a3, gmock_a4, gmock_a5); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD6(tn, constness, ct, Method, F) \ #define GMOCK_METHOD6_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3, \ GMOCK_ARG_(tn, F, 3) gmock_a3, \
GMOCK_ARG(tn, F, 4) gmock_a4, \ GMOCK_ARG_(tn, F, 4) gmock_a4, \
GMOCK_ARG(tn, F, 5) gmock_a5, \ GMOCK_ARG_(tn, F, 5) gmock_a5, \
GMOCK_ARG(tn, F, 6) gmock_a6) constness { \ GMOCK_ARG_(tn, F, 6) gmock_a6) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 6, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 6, \
this_method_does_not_take_6_arguments); \ this_method_does_not_take_6_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \
gmock_a4, gmock_a5, gmock_a6); \ gmock_a4, gmock_a5, gmock_a6); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3, \ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
GMOCK_MATCHER(tn, F, 4) gmock_a4, \ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
GMOCK_MATCHER(tn, F, 5) gmock_a5, \ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
GMOCK_MATCHER(tn, F, 6) gmock_a6) constness { \ GMOCK_MATCHER_(tn, F, 6) gmock_a6) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6); \ gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD7(tn, constness, ct, Method, F) \ #define GMOCK_METHOD7_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3, \ GMOCK_ARG_(tn, F, 3) gmock_a3, \
GMOCK_ARG(tn, F, 4) gmock_a4, \ GMOCK_ARG_(tn, F, 4) gmock_a4, \
GMOCK_ARG(tn, F, 5) gmock_a5, \ GMOCK_ARG_(tn, F, 5) gmock_a5, \
GMOCK_ARG(tn, F, 6) gmock_a6, \ GMOCK_ARG_(tn, F, 6) gmock_a6, \
GMOCK_ARG(tn, F, 7) gmock_a7) constness { \ GMOCK_ARG_(tn, F, 7) gmock_a7) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 7, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 7, \
this_method_does_not_take_7_arguments); \ this_method_does_not_take_7_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \
gmock_a4, gmock_a5, gmock_a6, gmock_a7); \ gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3, \ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
GMOCK_MATCHER(tn, F, 4) gmock_a4, \ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
GMOCK_MATCHER(tn, F, 5) gmock_a5, \ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
GMOCK_MATCHER(tn, F, 6) gmock_a6, \ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
GMOCK_MATCHER(tn, F, 7) gmock_a7) constness { \ GMOCK_MATCHER_(tn, F, 7) gmock_a7) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD8(tn, constness, ct, Method, F) \ #define GMOCK_METHOD8_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3, \ GMOCK_ARG_(tn, F, 3) gmock_a3, \
GMOCK_ARG(tn, F, 4) gmock_a4, \ GMOCK_ARG_(tn, F, 4) gmock_a4, \
GMOCK_ARG(tn, F, 5) gmock_a5, \ GMOCK_ARG_(tn, F, 5) gmock_a5, \
GMOCK_ARG(tn, F, 6) gmock_a6, \ GMOCK_ARG_(tn, F, 6) gmock_a6, \
GMOCK_ARG(tn, F, 7) gmock_a7, \ GMOCK_ARG_(tn, F, 7) gmock_a7, \
GMOCK_ARG(tn, F, 8) gmock_a8) constness { \ GMOCK_ARG_(tn, F, 8) gmock_a8) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 8, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 8, \
this_method_does_not_take_8_arguments); \ this_method_does_not_take_8_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \
gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \ gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3, \ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
GMOCK_MATCHER(tn, F, 4) gmock_a4, \ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
GMOCK_MATCHER(tn, F, 5) gmock_a5, \ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
GMOCK_MATCHER(tn, F, 6) gmock_a6, \ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
GMOCK_MATCHER(tn, F, 7) gmock_a7, \ GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
GMOCK_MATCHER(tn, F, 8) gmock_a8) constness { \ GMOCK_MATCHER_(tn, F, 8) gmock_a8) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD9(tn, constness, ct, Method, F) \ #define GMOCK_METHOD9_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3, \ GMOCK_ARG_(tn, F, 3) gmock_a3, \
GMOCK_ARG(tn, F, 4) gmock_a4, \ GMOCK_ARG_(tn, F, 4) gmock_a4, \
GMOCK_ARG(tn, F, 5) gmock_a5, \ GMOCK_ARG_(tn, F, 5) gmock_a5, \
GMOCK_ARG(tn, F, 6) gmock_a6, \ GMOCK_ARG_(tn, F, 6) gmock_a6, \
GMOCK_ARG(tn, F, 7) gmock_a7, \ GMOCK_ARG_(tn, F, 7) gmock_a7, \
GMOCK_ARG(tn, F, 8) gmock_a8, \ GMOCK_ARG_(tn, F, 8) gmock_a8, \
GMOCK_ARG(tn, F, 9) gmock_a9) constness { \ GMOCK_ARG_(tn, F, 9) gmock_a9) constness {
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ \
GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 9, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 9, \
this_method_does_not_take_9_arguments); \ this_method_does_not_take_9_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \
gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9); \ gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3, \ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
GMOCK_MATCHER(tn, F, 4) gmock_a4, \ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
GMOCK_MATCHER(tn, F, 5) gmock_a5, \ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
GMOCK_MATCHER(tn, F, 6) gmock_a6, \ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
GMOCK_MATCHER(tn, F, 7) gmock_a7, \ GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
GMOCK_MATCHER(tn, F, 8) gmock_a8, \ GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
GMOCK_MATCHER(tn, F, 9) gmock_a9) constness { \ GMOCK_MATCHER_(tn, F, 9) gmock_a9) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
gmock_a9); \ gmock_a9); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD10(tn, constness, ct, Method, F) \ #define GMOCK_METHOD10_(tn, constness, ct, Method, F) \
GMOCK_RESULT(tn, F) ct Method(GMOCK_ARG(tn, F, 1) gmock_a1, \ GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
GMOCK_ARG(tn, F, 2) gmock_a2, \ GMOCK_ARG_(tn, F, 2) gmock_a2, \
GMOCK_ARG(tn, F, 3) gmock_a3, \ GMOCK_ARG_(tn, F, 3) gmock_a3, \
GMOCK_ARG(tn, F, 4) gmock_a4, \ GMOCK_ARG_(tn, F, 4) gmock_a4, \
GMOCK_ARG(tn, F, 5) gmock_a5, \ GMOCK_ARG_(tn, F, 5) gmock_a5, \
GMOCK_ARG(tn, F, 6) gmock_a6, \ GMOCK_ARG_(tn, F, 6) gmock_a6, \
GMOCK_ARG(tn, F, 7) gmock_a7, \ GMOCK_ARG_(tn, F, 7) gmock_a7, \
GMOCK_ARG(tn, F, 8) gmock_a8, \ GMOCK_ARG_(tn, F, 8) gmock_a8, \
GMOCK_ARG(tn, F, 9) gmock_a9, \ GMOCK_ARG_(tn, F, 9) gmock_a9, \
GMOCK_ARG(tn, F, 10) gmock_a10) constness { GMOCK_ARG_(tn, F, 10) gmock_a10) constness
\ { \
GMOCK_COMPILE_ASSERT(::std::tr1::tuple_size< \ GMOCK_COMPILE_ASSERT_(::std::tr1::tuple_size< \
tn ::testing::internal::Function<F>::ArgumentTuple>::value == 10, \ tn ::testing::internal::Function<F>::ArgumentTuple>::value == 10, \
this_method_does_not_take_10_arguments); \ this_method_does_not_take_10_arguments); \
GMOCK_MOCKER(Method).SetOwnerAndName(this, #Method); \ GMOCK_MOCKER_(Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \
gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \ gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
gmock_a10); \ gmock_a10); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method(GMOCK_MATCHER(tn, F, 1) gmock_a1, \ gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
GMOCK_MATCHER(tn, F, 2) gmock_a2, \ GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
GMOCK_MATCHER(tn, F, 3) gmock_a3, \ GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
GMOCK_MATCHER(tn, F, 4) gmock_a4, \ GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
GMOCK_MATCHER(tn, F, 5) gmock_a5, \ GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
GMOCK_MATCHER(tn, F, 6) gmock_a6, \ GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
GMOCK_MATCHER(tn, F, 7) gmock_a7, \ GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
GMOCK_MATCHER(tn, F, 8) gmock_a8, \ GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
GMOCK_MATCHER(tn, F, 9) gmock_a9, \ GMOCK_MATCHER_(tn, F, 9) gmock_a9, \
GMOCK_MATCHER(tn, F, 10) gmock_a10) constness { \ GMOCK_MATCHER_(tn, F, 10) gmock_a10) constness { \
return GMOCK_MOCKER(Method).RegisterOwner(this).With(gmock_a1, gmock_a2 return GMOCK_MOCKER_(Method).RegisterOwner(this).With(gmock_a1, gmock_a
, \ 2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a 9, \ gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a 9, \
gmock_a10); \ gmock_a10); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method)
#define MOCK_METHOD0(m, F) GMOCK_METHOD0(, , , m, F) #define MOCK_METHOD0(m, F) GMOCK_METHOD0_(, , , m, F)
#define MOCK_METHOD1(m, F) GMOCK_METHOD1(, , , m, F) #define MOCK_METHOD1(m, F) GMOCK_METHOD1_(, , , m, F)
#define MOCK_METHOD2(m, F) GMOCK_METHOD2(, , , m, F) #define MOCK_METHOD2(m, F) GMOCK_METHOD2_(, , , m, F)
#define MOCK_METHOD3(m, F) GMOCK_METHOD3(, , , m, F) #define MOCK_METHOD3(m, F) GMOCK_METHOD3_(, , , m, F)
#define MOCK_METHOD4(m, F) GMOCK_METHOD4(, , , m, F) #define MOCK_METHOD4(m, F) GMOCK_METHOD4_(, , , m, F)
#define MOCK_METHOD5(m, F) GMOCK_METHOD5(, , , m, F) #define MOCK_METHOD5(m, F) GMOCK_METHOD5_(, , , m, F)
#define MOCK_METHOD6(m, F) GMOCK_METHOD6(, , , m, F) #define MOCK_METHOD6(m, F) GMOCK_METHOD6_(, , , m, F)
#define MOCK_METHOD7(m, F) GMOCK_METHOD7(, , , m, F) #define MOCK_METHOD7(m, F) GMOCK_METHOD7_(, , , m, F)
#define MOCK_METHOD8(m, F) GMOCK_METHOD8(, , , m, F) #define MOCK_METHOD8(m, F) GMOCK_METHOD8_(, , , m, F)
#define MOCK_METHOD9(m, F) GMOCK_METHOD9(, , , m, F) #define MOCK_METHOD9(m, F) GMOCK_METHOD9_(, , , m, F)
#define MOCK_METHOD10(m, F) GMOCK_METHOD10(, , , m, F) #define MOCK_METHOD10(m, F) GMOCK_METHOD10_(, , , m, F)
#define MOCK_CONST_METHOD0(m, F) GMOCK_METHOD0(, const, , m, F) #define MOCK_CONST_METHOD0(m, F) GMOCK_METHOD0_(, const, , m, F)
#define MOCK_CONST_METHOD1(m, F) GMOCK_METHOD1(, const, , m, F) #define MOCK_CONST_METHOD1(m, F) GMOCK_METHOD1_(, const, , m, F)
#define MOCK_CONST_METHOD2(m, F) GMOCK_METHOD2(, const, , m, F) #define MOCK_CONST_METHOD2(m, F) GMOCK_METHOD2_(, const, , m, F)
#define MOCK_CONST_METHOD3(m, F) GMOCK_METHOD3(, const, , m, F) #define MOCK_CONST_METHOD3(m, F) GMOCK_METHOD3_(, const, , m, F)
#define MOCK_CONST_METHOD4(m, F) GMOCK_METHOD4(, const, , m, F) #define MOCK_CONST_METHOD4(m, F) GMOCK_METHOD4_(, const, , m, F)
#define MOCK_CONST_METHOD5(m, F) GMOCK_METHOD5(, const, , m, F) #define MOCK_CONST_METHOD5(m, F) GMOCK_METHOD5_(, const, , m, F)
#define MOCK_CONST_METHOD6(m, F) GMOCK_METHOD6(, const, , m, F) #define MOCK_CONST_METHOD6(m, F) GMOCK_METHOD6_(, const, , m, F)
#define MOCK_CONST_METHOD7(m, F) GMOCK_METHOD7(, const, , m, F) #define MOCK_CONST_METHOD7(m, F) GMOCK_METHOD7_(, const, , m, F)
#define MOCK_CONST_METHOD8(m, F) GMOCK_METHOD8(, const, , m, F) #define MOCK_CONST_METHOD8(m, F) GMOCK_METHOD8_(, const, , m, F)
#define MOCK_CONST_METHOD9(m, F) GMOCK_METHOD9(, const, , m, F) #define MOCK_CONST_METHOD9(m, F) GMOCK_METHOD9_(, const, , m, F)
#define MOCK_CONST_METHOD10(m, F) GMOCK_METHOD10(, const, , m, F) #define MOCK_CONST_METHOD10(m, F) GMOCK_METHOD10_(, const, , m, F)
#define MOCK_METHOD0_T(m, F) GMOCK_METHOD0(typename, , , m, F) #define MOCK_METHOD0_T(m, F) GMOCK_METHOD0_(typename, , , m, F)
#define MOCK_METHOD1_T(m, F) GMOCK_METHOD1(typename, , , m, F) #define MOCK_METHOD1_T(m, F) GMOCK_METHOD1_(typename, , , m, F)
#define MOCK_METHOD2_T(m, F) GMOCK_METHOD2(typename, , , m, F) #define MOCK_METHOD2_T(m, F) GMOCK_METHOD2_(typename, , , m, F)
#define MOCK_METHOD3_T(m, F) GMOCK_METHOD3(typename, , , m, F) #define MOCK_METHOD3_T(m, F) GMOCK_METHOD3_(typename, , , m, F)
#define MOCK_METHOD4_T(m, F) GMOCK_METHOD4(typename, , , m, F) #define MOCK_METHOD4_T(m, F) GMOCK_METHOD4_(typename, , , m, F)
#define MOCK_METHOD5_T(m, F) GMOCK_METHOD5(typename, , , m, F) #define MOCK_METHOD5_T(m, F) GMOCK_METHOD5_(typename, , , m, F)
#define MOCK_METHOD6_T(m, F) GMOCK_METHOD6(typename, , , m, F) #define MOCK_METHOD6_T(m, F) GMOCK_METHOD6_(typename, , , m, F)
#define MOCK_METHOD7_T(m, F) GMOCK_METHOD7(typename, , , m, F) #define MOCK_METHOD7_T(m, F) GMOCK_METHOD7_(typename, , , m, F)
#define MOCK_METHOD8_T(m, F) GMOCK_METHOD8(typename, , , m, F) #define MOCK_METHOD8_T(m, F) GMOCK_METHOD8_(typename, , , m, F)
#define MOCK_METHOD9_T(m, F) GMOCK_METHOD9(typename, , , m, F) #define MOCK_METHOD9_T(m, F) GMOCK_METHOD9_(typename, , , m, F)
#define MOCK_METHOD10_T(m, F) GMOCK_METHOD10(typename, , , m, F) #define MOCK_METHOD10_T(m, F) GMOCK_METHOD10_(typename, , , m, F)
#define MOCK_CONST_METHOD0_T(m, F) GMOCK_METHOD0(typename, const, , m, F) #define MOCK_CONST_METHOD0_T(m, F) GMOCK_METHOD0_(typename, const, , m, F)
#define MOCK_CONST_METHOD1_T(m, F) GMOCK_METHOD1(typename, const, , m, F) #define MOCK_CONST_METHOD1_T(m, F) GMOCK_METHOD1_(typename, const, , m, F)
#define MOCK_CONST_METHOD2_T(m, F) GMOCK_METHOD2(typename, const, , m, F) #define MOCK_CONST_METHOD2_T(m, F) GMOCK_METHOD2_(typename, const, , m, F)
#define MOCK_CONST_METHOD3_T(m, F) GMOCK_METHOD3(typename, const, , m, F) #define MOCK_CONST_METHOD3_T(m, F) GMOCK_METHOD3_(typename, const, , m, F)
#define MOCK_CONST_METHOD4_T(m, F) GMOCK_METHOD4(typename, const, , m, F) #define MOCK_CONST_METHOD4_T(m, F) GMOCK_METHOD4_(typename, const, , m, F)
#define MOCK_CONST_METHOD5_T(m, F) GMOCK_METHOD5(typename, const, , m, F) #define MOCK_CONST_METHOD5_T(m, F) GMOCK_METHOD5_(typename, const, , m, F)
#define MOCK_CONST_METHOD6_T(m, F) GMOCK_METHOD6(typename, const, , m, F) #define MOCK_CONST_METHOD6_T(m, F) GMOCK_METHOD6_(typename, const, , m, F)
#define MOCK_CONST_METHOD7_T(m, F) GMOCK_METHOD7(typename, const, , m, F) #define MOCK_CONST_METHOD7_T(m, F) GMOCK_METHOD7_(typename, const, , m, F)
#define MOCK_CONST_METHOD8_T(m, F) GMOCK_METHOD8(typename, const, , m, F) #define MOCK_CONST_METHOD8_T(m, F) GMOCK_METHOD8_(typename, const, , m, F)
#define MOCK_CONST_METHOD9_T(m, F) GMOCK_METHOD9(typename, const, , m, F) #define MOCK_CONST_METHOD9_T(m, F) GMOCK_METHOD9_(typename, const, , m, F)
#define MOCK_CONST_METHOD10_T(m, F) GMOCK_METHOD10(typename, const, , m, F) #define MOCK_CONST_METHOD10_T(m, F) GMOCK_METHOD10_(typename, const, , m, F
)
#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD0(, , ct, m, F) #define MOCK_METHOD0_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD0_(, , ct, m, F)
#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD1(, , ct, m, F) #define MOCK_METHOD1_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD1_(, , ct, m, F)
#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD2(, , ct, m, F) #define MOCK_METHOD2_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD2_(, , ct, m, F)
#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD3(, , ct, m, F) #define MOCK_METHOD3_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD3_(, , ct, m, F)
#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD4(, , ct, m, F) #define MOCK_METHOD4_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD4_(, , ct, m, F)
#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD5(, , ct, m, F) #define MOCK_METHOD5_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD5_(, , ct, m, F)
#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD6(, , ct, m, F) #define MOCK_METHOD6_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD6_(, , ct, m, F)
#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD7(, , ct, m, F) #define MOCK_METHOD7_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD7_(, , ct, m, F)
#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD8(, , ct, m, F) #define MOCK_METHOD8_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD8_(, , ct, m, F)
#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD9(, , ct, m, F) #define MOCK_METHOD9_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD9_(, , ct, m, F)
#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD10(, , ct, m, F) #define MOCK_METHOD10_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD10_(, , ct, m, F)
#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD0(, const, ct, m, F) GMOCK_METHOD0_(, const, ct, m, F)
#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD1(, const, ct, m, F) GMOCK_METHOD1_(, const, ct, m, F)
#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD2(, const, ct, m, F) GMOCK_METHOD2_(, const, ct, m, F)
#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD3(, const, ct, m, F) GMOCK_METHOD3_(, const, ct, m, F)
#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD4(, const, ct, m, F) GMOCK_METHOD4_(, const, ct, m, F)
#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD5(, const, ct, m, F) GMOCK_METHOD5_(, const, ct, m, F)
#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD6(, const, ct, m, F) GMOCK_METHOD6_(, const, ct, m, F)
#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD7(, const, ct, m, F) GMOCK_METHOD7_(, const, ct, m, F)
#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD8(, const, ct, m, F) GMOCK_METHOD8_(, const, ct, m, F)
#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD9(, const, ct, m, F) GMOCK_METHOD9_(, const, ct, m, F)
#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD10(, const, ct, m, F) GMOCK_METHOD10_(, const, ct, m, F)
#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD0(typename, , ct, m, F) GMOCK_METHOD0_(typename, , ct, m, F)
#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD1(typename, , ct, m, F) GMOCK_METHOD1_(typename, , ct, m, F)
#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD2(typename, , ct, m, F) GMOCK_METHOD2_(typename, , ct, m, F)
#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD3(typename, , ct, m, F) GMOCK_METHOD3_(typename, , ct, m, F)
#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD4(typename, , ct, m, F) GMOCK_METHOD4_(typename, , ct, m, F)
#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD5(typename, , ct, m, F) GMOCK_METHOD5_(typename, , ct, m, F)
#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD6(typename, , ct, m, F) GMOCK_METHOD6_(typename, , ct, m, F)
#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD7(typename, , ct, m, F) GMOCK_METHOD7_(typename, , ct, m, F)
#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD8(typename, , ct, m, F) GMOCK_METHOD8_(typename, , ct, m, F)
#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD9(typename, , ct, m, F) GMOCK_METHOD9_(typename, , ct, m, F)
#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD10(typename, , ct, m, F) GMOCK_METHOD10_(typename, , ct, m, F)
#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD0(typename, const, ct, m, F) GMOCK_METHOD0_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD1(typename, const, ct, m, F) GMOCK_METHOD1_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD2(typename, const, ct, m, F) GMOCK_METHOD2_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD3(typename, const, ct, m, F) GMOCK_METHOD3_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD4(typename, const, ct, m, F) GMOCK_METHOD4_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD5(typename, const, ct, m, F) GMOCK_METHOD5_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD6(typename, const, ct, m, F) GMOCK_METHOD6_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD7(typename, const, ct, m, F) GMOCK_METHOD7_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD8(typename, const, ct, m, F) GMOCK_METHOD8_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD9(typename, const, ct, m, F) GMOCK_METHOD9_(typename, const, ct, m, F)
#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, F) \ #define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
GMOCK_METHOD10(typename, const, ct, m, F) GMOCK_METHOD10_(typename, const, ct, m, F)
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
 End of changes. 86 change blocks. 
279 lines changed or deleted 289 lines changed or added


 gmock-generated-matchers.h   gmock-generated-matchers.h 
skipping to change at line 43 skipping to change at line 43
// //
// This file implements some commonly used variadic matchers. // This file implements some commonly used variadic matchers.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <gmock/gmock-matchers.h> #include <gmock/gmock-matchers.h>
#include <gmock/gmock-printers.h>
namespace testing { namespace testing {
namespace internal { namespace internal {
// Implements ElementsAre() and ElementsAreArray(). // Implements ElementsAre() and ElementsAreArray().
template <typename Container> template <typename Container>
class ElementsAreMatcherImpl : public MatcherInterface<Container> { class ElementsAreMatcherImpl : public MatcherInterface<Container> {
public: public:
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContaine r; typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai ner;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
// Constructs the matcher from a sequence of element values or // Constructs the matcher from a sequence of element values or
// element matchers. // element matchers.
template <typename InputIter> template <typename InputIter>
ElementsAreMatcherImpl(InputIter first, size_t count) { ElementsAreMatcherImpl(InputIter first, size_t count) {
matchers_.reserve(count); matchers_.reserve(count);
InputIter it = first; InputIter it = first;
for (size_t i = 0; i != count; ++i, ++it) { for (size_t i = 0; i != count; ++i, ++it) {
matchers_.push_back(MatcherCast<const Element&>(*it)); matchers_.push_back(MatcherCast<const Element&>(*it));
skipping to change at line 190 skipping to change at line 191
}; };
// Implements ElementsAre() of 0-10 arguments. // Implements ElementsAre() of 0-10 arguments.
class ElementsAreMatcher0 { class ElementsAreMatcher0 {
public: public:
ElementsAreMatcher0() {} ElementsAreMatcher0() {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&>* const matchers = NULL; const Matcher<const Element&>* const matchers = NULL;
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 0)); return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 0));
} }
}; };
template <typename T1> template <typename T1>
class ElementsAreMatcher1 { class ElementsAreMatcher1 {
public: public:
explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {} explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
}; };
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 1)); return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 1));
} }
private: private:
const T1& e1_; const T1& e1_;
}; };
template <typename T1, typename T2> template <typename T1, typename T2>
class ElementsAreMatcher2 { class ElementsAreMatcher2 {
public: public:
ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {} ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
}; };
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2)); return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2));
} }
skipping to change at line 250 skipping to change at line 254
}; };
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
class ElementsAreMatcher3 { class ElementsAreMatcher3 {
public: public:
ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1), ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
e2_(e2), e3_(e3) {} e2_(e2), e3_(e3) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
}; };
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3)); return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3));
} }
skipping to change at line 276 skipping to change at line 281
}; };
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
class ElementsAreMatcher4 { class ElementsAreMatcher4 {
public: public:
ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3, ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {} const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
MatcherCast<const Element&>(e4_), MatcherCast<const Element&>(e4_),
}; };
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4)); return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4));
skipping to change at line 304 skipping to change at line 310
}; };
template <typename T1, typename T2, typename T3, typename T4, typename T5> template <typename T1, typename T2, typename T3, typename T4, typename T5>
class ElementsAreMatcher5 { class ElementsAreMatcher5 {
public: public:
ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e 4, ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e 4,
const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {} const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
MatcherCast<const Element&>(e4_), MatcherCast<const Element&>(e4_),
MatcherCast<const Element&>(e5_), MatcherCast<const Element&>(e5_),
}; };
skipping to change at line 336 skipping to change at line 343
template <typename T1, typename T2, typename T3, typename T4, typename T5, template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6> typename T6>
class ElementsAreMatcher6 { class ElementsAreMatcher6 {
public: public:
ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e 4, ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e 4,
const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4),
e5_(e5), e6_(e6) {} e5_(e5), e6_(e6) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
MatcherCast<const Element&>(e4_), MatcherCast<const Element&>(e4_),
MatcherCast<const Element&>(e5_), MatcherCast<const Element&>(e5_),
MatcherCast<const Element&>(e6_), MatcherCast<const Element&>(e6_),
}; };
skipping to change at line 370 skipping to change at line 378
template <typename T1, typename T2, typename T3, typename T4, typename T5, template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7> typename T6, typename T7>
class ElementsAreMatcher7 { class ElementsAreMatcher7 {
public: public:
ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e 4, ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e 4,
const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3) , const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3) ,
e4_(e4), e5_(e5), e6_(e6), e7_(e7) {} e4_(e4), e5_(e5), e6_(e6), e7_(e7) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
MatcherCast<const Element&>(e4_), MatcherCast<const Element&>(e4_),
MatcherCast<const Element&>(e5_), MatcherCast<const Element&>(e5_),
MatcherCast<const Element&>(e6_), MatcherCast<const Element&>(e6_),
MatcherCast<const Element&>(e7_), MatcherCast<const Element&>(e7_),
skipping to change at line 406 skipping to change at line 415
template <typename T1, typename T2, typename T3, typename T4, typename T5, template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8> typename T6, typename T7, typename T8>
class ElementsAreMatcher8 { class ElementsAreMatcher8 {
public: public:
ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e 4, ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e 4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1), const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1),
e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {} e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
MatcherCast<const Element&>(e4_), MatcherCast<const Element&>(e4_),
MatcherCast<const Element&>(e5_), MatcherCast<const Element&>(e5_),
MatcherCast<const Element&>(e6_), MatcherCast<const Element&>(e6_),
MatcherCast<const Element&>(e7_), MatcherCast<const Element&>(e7_),
skipping to change at line 445 skipping to change at line 455
typename T6, typename T7, typename T8, typename T9> typename T6, typename T7, typename T8, typename T9>
class ElementsAreMatcher9 { class ElementsAreMatcher9 {
public: public:
ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e 4, ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e 4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T5& e5, const T6& e6, const T7& e7, const T8& e8,
const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
e7_(e7), e8_(e8), e9_(e9) {} e7_(e7), e8_(e8), e9_(e9) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
MatcherCast<const Element&>(e4_), MatcherCast<const Element&>(e4_),
MatcherCast<const Element&>(e5_), MatcherCast<const Element&>(e5_),
MatcherCast<const Element&>(e6_), MatcherCast<const Element&>(e6_),
MatcherCast<const Element&>(e7_), MatcherCast<const Element&>(e7_),
skipping to change at line 486 skipping to change at line 497
typename T6, typename T7, typename T8, typename T9, typename T10> typename T6, typename T7, typename T8, typename T9, typename T10>
class ElementsAreMatcher10 { class ElementsAreMatcher10 {
public: public:
ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4, ElementsAreMatcher10(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 T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6 ), const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6 ),
e7_(e7), e8_(e8), e9_(e9), e10_(e10) {} e7_(e7), e8_(e8), e9_(e9), e10_(e10) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
const Matcher<const Element&> matchers[] = { const Matcher<const Element&> matchers[] = {
MatcherCast<const Element&>(e1_), MatcherCast<const Element&>(e1_),
MatcherCast<const Element&>(e2_), MatcherCast<const Element&>(e2_),
MatcherCast<const Element&>(e3_), MatcherCast<const Element&>(e3_),
MatcherCast<const Element&>(e4_), MatcherCast<const Element&>(e4_),
MatcherCast<const Element&>(e5_), MatcherCast<const Element&>(e5_),
MatcherCast<const Element&>(e6_), MatcherCast<const Element&>(e6_),
MatcherCast<const Element&>(e7_), MatcherCast<const Element&>(e7_),
skipping to change at line 527 skipping to change at line 539
// Implements ElementsAreArray(). // Implements ElementsAreArray().
template <typename T> template <typename T>
class ElementsAreArrayMatcher { class ElementsAreArrayMatcher {
public: public:
ElementsAreArrayMatcher(const T* first, size_t count) : ElementsAreArrayMatcher(const T* first, size_t count) :
first_(first), count_(count) {} first_(first), count_(count) {}
template <typename Container> template <typename Container>
operator Matcher<Container>() const { operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST(GMOCK_REMOVE_REFERENCE(Container)) RawContai typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
ner; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename RawContainer::value_type Element;
return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_ )); return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_ ));
} }
private: private:
const T* const first_; const T* const first_;
const size_t count_; const size_t count_;
}; };
skipping to change at line 650 skipping to change at line 663
} }
template <typename T, size_t N> template <typename T, size_t N>
inline internal::ElementsAreArrayMatcher<T> inline internal::ElementsAreArrayMatcher<T>
ElementsAreArray(const T (&array)[N]) { ElementsAreArray(const T (&array)[N]) {
return internal::ElementsAreArrayMatcher<T>(array, N); return internal::ElementsAreArrayMatcher<T>(array, N);
} }
} // namespace testing } // namespace testing
// The MATCHER* family of macros can be used in a namespace scope to
// define custom matchers easily. The syntax:
//
// MATCHER(name, description_string) { statements; }
//
// will define a matcher with the given name that executes the
// statements, which must return a bool to indicate if the match
// succeeds. Inside the statements, you can refer to the value being
// matched by 'arg', and refer to its type by 'arg_type'.
//
// The description string documents what the matcher does, and is used
// to generate the failure message when the match fails. Since a
// MATCHER() is usually defined in a header file shared by multiple
// C++ source files, we require the description to be a C-string
// literal to avoid possible side effects. It can be empty, in which
// case we'll use the sequence of words in the matcher name as the
// description.
//
// For example:
//
// MATCHER(IsEven, "") { return (arg % 2) == 0; }
//
// allows you to write
//
// // Expects mock_foo.Bar(n) to be called where n is even.
// EXPECT_CALL(mock_foo, Bar(IsEven()));
//
// or,
//
// // Verifies that the value of some_expression is even.
// EXPECT_THAT(some_expression, IsEven());
//
// If the above assertion fails, it will print something like:
//
// Value of: some_expression
// Expected: is even
// Actual: 7
//
// where the description "is even" is automatically calculated from the
// matcher name IsEven.
//
// Note that the type of the value being matched (arg_type) is
// determined by the context in which you use the matcher and is
// supplied to you by the compiler, so you don't need to worry about
// declaring it (nor can you). This allows the matcher to be
// polymorphic. For example, IsEven() can be used to match any type
// where the value of "(arg % 2) == 0" can be implicitly converted to
// a bool. In the "Bar(IsEven())" example above, if method Bar()
// takes an int, 'arg_type' will be int; if it takes an unsigned long,
// 'arg_type' will be unsigned long; and so on.
//
// Sometimes you'll want to parameterize the matcher. For that you
// can use another macro:
//
// MATCHER_P(name, param_name, description_string) { statements; }
//
// For example:
//
// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
//
// will allow you to write:
//
// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
//
// which may lead to this message (assuming n is 10):
//
// Value of: Blah("a")
// Expected: has absolute value 10
// Actual: -9
//
// Note that both the matcher description and its parameter are
// printed, making the message human-friendly.
//
// In the matcher definition body, you can write 'foo_type' to
// reference the type of a parameter named 'foo'. For example, in the
// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
// 'value_type' to refer to the type of 'value'.
//
// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
// support multi-parameter matchers.
//
// When defining a parameterized matcher, you can use Python-style
// interpolations in the description string to refer to the parameter
// values. We support the following syntax currently:
//
// %% a single '%' character
// %(*)s all parameters of the matcher printed as a tuple
// %(foo)s value of the matcher parameter named 'foo'
//
// For example,
//
// MATCHER_P2(InClosedRange, low, hi, "is in range [%(low)s, %(hi)s]") {
// return low <= arg && arg <= hi;
// }
// ...
// EXPECT_THAT(3, InClosedRange(4, 6));
//
// would generate a failure that contains the message:
//
// Expected: is in range [4, 6]
//
// If you specify "" as the description, the failure message will
// contain the sequence of words in the matcher name followed by the
// parameter values printed as a tuple. For example,
//
// MATCHER_P2(InClosedRange, low, hi, "") { ... }
// ...
// EXPECT_THAT(3, InClosedRange(4, 6));
//
// would generate a failure that contains the text:
//
// Expected: in closed range (4, 6)
//
// For the purpose of typing, you can view
//
// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
//
// as shorthand for
//
// template <typename p1_type, ..., typename pk_type>
// FooMatcherPk<p1_type, ..., pk_type>
// Foo(p1_type p1, ..., pk_type pk) { ... }
//
// When you write Foo(v1, ..., vk), the compiler infers the types of
// the parameters v1, ..., and vk for you. If you are not happy with
// the result of the type inference, you can specify the types by
// explicitly instantiating the template, as in Foo<long, bool>(5,
// false). As said earlier, you don't get to (or need to) specify
// 'arg_type' as that's determined by the context in which the matcher
// is used. You can assign the result of expression Foo(p1, ..., pk)
// to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This
// can be useful when composing matchers.
//
// While you can instantiate a matcher template with reference types,
// passing the parameters by pointer usually makes your code more
// readable. If, however, you still want to pass a parameter by
// reference, be aware that in the failure message generated by the
// matcher you will see the value of the referenced object but not its
// address.
//
// You can overload matchers with different numbers of parameters:
//
// MATCHER_P(Blah, a, description_string1) { ... }
// MATCHER_P2(Blah, a, b, description_string2) { ... }
//
// While it's tempting to always use the MATCHER* macros when defining
// a new matcher, you should also consider implementing
// MatcherInterface or using MakePolymorphicMatcher() instead,
// especially if you need to use the matcher a lot. While these
// approaches require more work, they give you more control on the
// types of the value being matched and the matcher parameters, which
// in general leads to better compiler error messages that pay off in
// the long run. They also allow overloading matchers based on
// parameter types (as opposed to just based on the number of
// parameters).
//
// CAVEAT:
//
// MATCHER*() can only be used in a namespace scope. The reason is
// that C++ doesn't yet allow function-local types to be used to
// instantiate templates. The up-coming C++0x standard will fix this.
// Once that's done, we'll consider supporting using MATCHER*() inside
// a function.
//
// MORE INFORMATION:
//
// To learn more about using these macros, please search for 'MATCHER'
// on http://code.google.com/p/googlemock/wiki/CookBook.
namespace testing {
namespace internal {
// Constants denoting interpolations in a matcher description string.
const int kTupleInterpolation = -1; // "%(*)s"
const int kPercentInterpolation = -2; // "%%"
const int kInvalidInterpolation = -3; // "%" followed by invalid text
// Records the location and content of an interpolation.
struct Interpolation {
Interpolation(const char* start, const char* end, int param)
: start_pos(start), end_pos(end), param_index(param) {}
// Points to the start of the interpolation (the '%' character).
const char* start_pos;
// Points to the first character after the interpolation.
const char* end_pos;
// 0-based index of the interpolated matcher parameter;
// kTupleInterpolation for "%(*)s"; kPercentInterpolation for "%%".
int param_index;
};
typedef ::std::vector<Interpolation> Interpolations;
// Parses a matcher description string and returns a vector of
// interpolations that appear in the string; generates non-fatal
// failures iff 'description' is an invalid matcher description.
// 'param_names' is a NULL-terminated array of parameter names in the
// order they appear in the MATCHER_P*() parameter list.
Interpolations ValidateMatcherDescription(
const char* param_names[], const char* description);
// Returns the actual matcher description, given the matcher name,
// user-supplied description template string, interpolations in the
// string, and the printed values of the matcher parameters.
string FormatMatcherDescription(
const char* matcher_name, const char* description,
const Interpolations& interp, const Strings& param_values);
} // namespace internal
} // namespace testing
#define MATCHER(name, description)\
class name##Matcher {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\
: gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<>());\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(gmock_interp_));\
}\
name##Matcher() {\
const char* gmock_param_names[] = { NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
::testing::internal::Interpolations gmock_interp_;\
};\
inline name##Matcher name() {\
return name##Matcher();\
}\
template <typename arg_type>\
bool name##Matcher::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P(name, p0, description)\
template <typename p0##_type>\
class name##MatcherP {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
explicit gmock_Impl(p0##_type gmock_p0, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type>(p0));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, gmock_interp_));\
}\
name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
const char* gmock_param_names[] = { #p0, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type>\
inline name##MatcherP<p0##_type> name(p0##_type p0) {\
return name##MatcherP<p0##_type>(p0);\
}\
template <typename p0##_type>\
template <typename arg_type>\
bool name##MatcherP<p0##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P2(name, p0, p1, description)\
template <typename p0##_type, typename p1##_type>\
class name##MatcherP2 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type>(p0, p1));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, gmock_interp_));\
}\
name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0),
\
p1(gmock_p1) {\
const char* gmock_param_names[] = { #p0, #p1, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type>\
inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
p1##_type p1) {\
return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
}\
template <typename p0##_type, typename p1##_type>\
template <typename arg_type>\
bool name##MatcherP2<p0##_type, p1##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P3(name, p0, p1, p2, description)\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
class name##MatcherP3 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1,
\
p2));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, gmock_interp_));\
}\
name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0
, \
p1##_type p1, p2##_type p2) {\
return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
template <typename arg_type>\
bool name##MatcherP3<p0##_type, p1##_type, p2##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P4(name, p0, p1, p2, p3, description)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
class name##MatcherP4 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
p3##_type>(p0, p1, p2, p3));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, p3, gmock_interp_));\
}\
name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1
), \
p2(gmock_p2), p3(gmock_p3) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
p3##_type p3) {\
return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0,
\
p1, p2, p3);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
template <typename arg_type>\
bool name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
class name##MatcherP5 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
p4(gmock_p4), gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \
p4##_type>(p0, p1, p2, p3, p4));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, gmock_interp_));\
}\
name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, \
p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \
p4##_type p4) {\
return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type>(p0, p1, p2, p3, p4);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
template <typename arg_type>\
bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
class name##MatcherP6 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
p4(gmock_p4), p5(gmock_p5), gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, gmock_interp_));
\
}\
name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, NUL
L };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2,
\
p3##_type p3, p4##_type p4, p5##_type p5) {\
return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
template <typename arg_type>\
bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \
p5##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\
class name##MatcherP7 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5
, \
p6));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, gmock_interp
_));\
}\
name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1
), \
p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
p6(gmock_p6) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6
, \
NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\
inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
p6##_type p6) {\
return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\
template <typename arg_type>\
bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \
p5##_type, p6##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\
class name##MatcherP8 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2,
\
p3, p4, p5, p6, p7));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, \
gmock_interp_));\
}\
name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, \
p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
p7(gmock_p7) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6
, \
#p7, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\
inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5,
\
p6##_type p6, p7##_type p7) {\
return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5,
\
p6, p7);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\
template <typename arg_type>\
bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \
p5##_type, p6##_type, p7##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\
class name##MatcherP9 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
p8(gmock_p8), gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \
p4##_type, p5##_type, p6##_type, p7##_type, \
p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, \
gmock_interp_));\
}\
name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7
), \
p8(gmock_p8) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6
, \
#p7, #p8, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\
inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, \
p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \
p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
p8##_type p8) {\
return name##MatcherP9<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);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\
template <typename arg_type>\
bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \
p5##_type, p6##_type, p7##_type, p8##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, descripti
on)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\
class name##MatcherP10 {\
public:\
template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
p9##_type gmock_p9, \
const ::testing::internal::Interpolations& gmock_interp)\
: p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
p8(gmock_p8), p9(gmock_p9), gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\
const ::testing::internal::Strings& gmock_printed_params = \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type,
\
p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
*gmock_os << ::testing::internal::FormatMatcherDescription(\
#name, description, gmock_interp_, gmock_printed_param
s);\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
p9##_type p9;\
const ::testing::internal::Interpolations gmock_interp_;\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9,
\
gmock_interp_));\
}\
name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1
), \
p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6
), \
p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, #p6
, \
#p7, #p8, #p9, NULL };\
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
p9##_type p9;\
::testing::internal::Interpolations gmock_interp_;\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\
inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \
p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8,
\
p9##_type p9) {\
return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p
0, \
p1, p2, p3, p4, p5, p6, p7, p8, p9);\
}\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\
template <typename arg_type>\
bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const
namespace testing {
namespace internal {
// Returns true iff element is in the STL-style container.
template <typename Container, typename Element>
inline bool Contains(const Container& container, const Element& element) {
return ::std::find(container.begin(), container.end(), element) !=
container.end();
}
// Returns true iff element is in the C-style array.
template <typename ArrayElement, size_t N, typename Element>
inline bool Contains(const ArrayElement (&array)[N], const Element& element
) {
return ::std::find(array, array + N, element) != array + N;
}
} // namespace internal
// Matches an STL-style container or a C-style array that contains the give
n
// element.
//
// Examples:
// ::std::set<int> page_ids;
// page_ids.insert(3);
// page_ids.insert(1);
// EXPECT_THAT(page_ids, Contains(1));
// EXPECT_THAT(page_ids, Contains(3.0));
// EXPECT_THAT(page_ids, Not(Contains(4)));
//
// ::std::map<int, size_t> page_lengths;
// page_lengths[1] = 100;
// EXPECT_THAT(map_int, Contains(::std::pair<const int, size_t>(1, 100)))
;
//
// const char* user_ids[] = { "joe", "mike", "tom" };
// EXPECT_THAT(user_ids, Contains(::std::string("tom")));
MATCHER_P(Contains, element, "") {
return internal::Contains(arg, element);
}
} // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
 End of changes. 15 change blocks. 
25 lines changed or deleted 1043 lines changed or added


 gmock-internal-utils.h   gmock-internal-utils.h 
skipping to change at line 51 skipping to change at line 51
#include <stdio.h> #include <stdio.h>
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include <string> #include <string>
#include <gmock/internal/gmock-generated-internal-utils.h> #include <gmock/internal/gmock-generated-internal-utils.h>
#include <gmock/internal/gmock-port.h> #include <gmock/internal/gmock-port.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
// Concatenates two pre-processor symbols; works for concatenating // Concatenates two pre-processor symbols; works for concatenating
// built-in macros like __FILE__ and __LINE__. // built-in macros like __FILE__ and __LINE__.
#define GMOCK_CONCAT_TOKEN_IMPL(foo, bar) foo##bar #define GMOCK_CONCAT_TOKEN_IMPL_(foo, bar) foo##bar
#define GMOCK_CONCAT_TOKEN(foo, bar) GMOCK_CONCAT_TOKEN_IMPL(foo, bar) #define GMOCK_CONCAT_TOKEN_(foo, bar) GMOCK_CONCAT_TOKEN_IMPL_(foo, bar)
#ifdef __GNUC__ #ifdef __GNUC__
#define GMOCK_ATTRIBUTE_UNUSED __attribute__ ((unused)) #define GMOCK_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
#else #else
#define GMOCK_ATTRIBUTE_UNUSED #define GMOCK_ATTRIBUTE_UNUSED_
#endif // __GNUC__ #endif // __GNUC__
class ProtocolMessage; class ProtocolMessage;
namespace proto2 { class Message; } namespace proto2 { class Message; }
namespace testing { namespace testing {
namespace internal { namespace internal {
// Converts an identifier name to a space-separated list of lower-case
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// treated as one word. For example, both "FooBar123" and
// "foo_bar_123" are converted to "foo bar 123".
string ConvertIdentifierNameToWords(const char* id_name);
// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a // Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
// compiler error iff T1 and T2 are different types. // compiler error iff T1 and T2 are different types.
template <typename T1, typename T2> template <typename T1, typename T2>
struct CompileAssertTypesEqual; struct CompileAssertTypesEqual;
template <typename T> template <typename T>
struct CompileAssertTypesEqual<T, T> { struct CompileAssertTypesEqual<T, T> {
}; };
// Removes the reference from a type if it is a reference type, // Removes the reference from a type if it is a reference type,
// otherwise leaves it unchanged. This is the same as // otherwise leaves it unchanged. This is the same as
// tr1::remove_reference, which is not widely available yet. // tr1::remove_reference, which is not widely available yet.
template <typename T> template <typename T>
struct RemoveReference { typedef T type; }; // NOLINT struct RemoveReference { typedef T type; }; // NOLINT
template <typename T> template <typename T>
struct RemoveReference<T&> { typedef T type; }; // NOLINT struct RemoveReference<T&> { typedef T type; }; // NOLINT
// A handy wrapper around RemoveReference that works when the argument // A handy wrapper around RemoveReference that works when the argument
// T depends on template parameters. // T depends on template parameters.
#define GMOCK_REMOVE_REFERENCE(T) \ #define GMOCK_REMOVE_REFERENCE_(T) \
typename ::testing::internal::RemoveReference<T>::type typename ::testing::internal::RemoveReference<T>::type
// Removes const from a type if it is a const type, otherwise leaves // Removes const from a type if it is a const type, otherwise leaves
// it unchanged. This is the same as tr1::remove_const, which is not // it unchanged. This is the same as tr1::remove_const, which is not
// widely available yet. // widely available yet.
template <typename T> template <typename T>
struct RemoveConst { typedef T type; }; // NOLINT struct RemoveConst { typedef T type; }; // NOLINT
template <typename T> template <typename T>
struct RemoveConst<const T> { typedef T type; }; // NOLINT struct RemoveConst<const T> { typedef T type; }; // NOLINT
// A handy wrapper around RemoveConst that works when the argument // A handy wrapper around RemoveConst that works when the argument
// T depends on template parameters. // T depends on template parameters.
#define GMOCK_REMOVE_CONST(T) \ #define GMOCK_REMOVE_CONST_(T) \
typename ::testing::internal::RemoveConst<T>::type typename ::testing::internal::RemoveConst<T>::type
// Adds reference to a type if it is not a reference type, // Adds reference to a type if it is not a reference type,
// otherwise leaves it unchanged. This is the same as // otherwise leaves it unchanged. This is the same as
// tr1::add_reference, which is not widely available yet. // tr1::add_reference, which is not widely available yet.
template <typename T> template <typename T>
struct AddReference { typedef T& type; }; // NOLINT struct AddReference { typedef T& type; }; // NOLINT
template <typename T> template <typename T>
struct AddReference<T&> { typedef T& type; }; // NOLINT struct AddReference<T&> { typedef T& type; }; // NOLINT
// A handy wrapper around AddReference that works when the argument T // A handy wrapper around AddReference that works when the argument T
// depends on template parameters. // depends on template parameters.
#define GMOCK_ADD_REFERENCE(T) \ #define GMOCK_ADD_REFERENCE_(T) \
typename ::testing::internal::AddReference<T>::type typename ::testing::internal::AddReference<T>::type
// Adds a reference to const on top of T as necessary. For example, // Adds a reference to const on top of T as necessary. For example,
// it transforms // it transforms
// //
// char ==> const char& // char ==> const char&
// const char ==> const char& // const char ==> const char&
// char& ==> const char& // char& ==> const char&
// const char& ==> const char& // const char& ==> const char&
// //
// The argument T must depend on some template parameters. // The argument T must depend on some template parameters.
#define GMOCK_REFERENCE_TO_CONST(T) \ #define GMOCK_REFERENCE_TO_CONST_(T) \
GMOCK_ADD_REFERENCE(const GMOCK_REMOVE_REFERENCE(T)) GMOCK_ADD_REFERENCE_(const GMOCK_REMOVE_REFERENCE_(T))
// PointeeOf<Pointer>::type is the type of a value pointed to by a // PointeeOf<Pointer>::type is the type of a value pointed to by a
// Pointer, which can be either a smart pointer or a raw pointer. The // Pointer, which can be either a smart pointer or a raw pointer. The
// following default implementation is for the case where Pointer is a // following default implementation is for the case where Pointer is a
// smart pointer. // smart pointer.
template <typename Pointer> template <typename Pointer>
struct PointeeOf { struct PointeeOf {
// Smart pointer classes define type element_type as the type of // Smart pointer classes define type element_type as the type of
// their pointees. // their pointees.
typedef typename Pointer::element_type type; typedef typename Pointer::element_type type;
 End of changes. 8 change blocks. 
9 lines changed or deleted 15 lines changed or added


 gmock-matchers.h   gmock-matchers.h 
skipping to change at line 41 skipping to change at line 41
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements some commonly used argument matchers. More // This file implements some commonly used argument matchers. More
// matchers can be defined by the user implementing the // matchers can be defined by the user implementing the
// MatcherInterface<T> interface if necessary. // MatcherInterface<T> interface if necessary.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
#include <algorithm>
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <gmock/gmock-printers.h> #include <gmock/gmock-printers.h>
#include <gmock/internal/gmock-internal-utils.h> #include <gmock/internal/gmock-internal-utils.h>
#include <gmock/internal/gmock-port.h> #include <gmock/internal/gmock-port.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
skipping to change at line 379 skipping to change at line 380
// TODO(wan): include in the message the name of the parameter // TODO(wan): include in the message the name of the parameter
// as used in MOCK_METHOD*() when possible. // as used in MOCK_METHOD*() when possible.
*os << " Expected arg #" << N - 1 << ": "; *os << " Expected arg #" << N - 1 << ": ";
get<N - 1>(matchers).DescribeTo(os); get<N - 1>(matchers).DescribeTo(os);
*os << "\n Actual: "; *os << "\n Actual: ";
// We remove the reference in type Value to prevent the // We remove the reference in type Value to prevent the
// universal printer from printing the address of value, which // universal printer from printing the address of value, which
// isn't interesting to the user most of the time. The // isn't interesting to the user most of the time. The
// matcher's ExplainMatchResultTo() method handles the case when // matcher's ExplainMatchResultTo() method handles the case when
// the address is interesting. // the address is interesting.
internal::UniversalPrinter<GMOCK_REMOVE_REFERENCE(Value)>:: internal::UniversalPrinter<GMOCK_REMOVE_REFERENCE_(Value)>::
Print(value, os); Print(value, os);
ExplainMatchResultAsNeededTo<Value>(matcher, value, os); ExplainMatchResultAsNeededTo<Value>(matcher, value, os);
*os << "\n"; *os << "\n";
} }
} }
}; };
// The base case. // The base case.
template <> template <>
class TuplePrefix<0> { class TuplePrefix<0> {
skipping to change at line 414 skipping to change at line 415
// matchers in matcher_tuple match the corresponding fields in // matchers in matcher_tuple match the corresponding fields in
// value_tuple. It is a compiler error if matcher_tuple and // value_tuple. It is a compiler error if matcher_tuple and
// value_tuple have different number of fields or incompatible field // value_tuple have different number of fields or incompatible field
// types. // types.
template <typename MatcherTuple, typename ValueTuple> template <typename MatcherTuple, typename ValueTuple>
bool TupleMatches(const MatcherTuple& matcher_tuple, bool TupleMatches(const MatcherTuple& matcher_tuple,
const ValueTuple& value_tuple) { const ValueTuple& value_tuple) {
using ::std::tr1::tuple_size; using ::std::tr1::tuple_size;
// Makes sure that matcher_tuple and value_tuple have the same // Makes sure that matcher_tuple and value_tuple have the same
// number of fields. // number of fields.
GMOCK_COMPILE_ASSERT(tuple_size<MatcherTuple>::value == GMOCK_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value ==
tuple_size<ValueTuple>::value, tuple_size<ValueTuple>::value,
matcher_and_value_have_different_numbers_of_fields); matcher_and_value_have_different_numbers_of_fields)
;
return TuplePrefix<tuple_size<ValueTuple>::value>:: return TuplePrefix<tuple_size<ValueTuple>::value>::
Matches(matcher_tuple, value_tuple); Matches(matcher_tuple, value_tuple);
} }
// Describes failures in matching matchers against values. If there // Describes failures in matching matchers against values. If there
// is no failure, nothing will be streamed to os. // is no failure, nothing will be streamed to os.
template <typename MatcherTuple, typename ValueTuple> template <typename MatcherTuple, typename ValueTuple>
void DescribeMatchFailureTupleTo(const MatcherTuple& matchers, void DescribeMatchFailureTupleTo(const MatcherTuple& matchers,
const ValueTuple& values, const ValueTuple& values,
::std::ostream* os) { ::std::ostream* os) {
skipping to change at line 530 skipping to change at line 531
// //
// The matcher defined here is polymorphic (for example, Eq(5) can be // The matcher defined here is polymorphic (for example, Eq(5) can be
// used to match an int, a short, a double, etc). Therefore we use // used to match an int, a short, a double, etc). Therefore we use
// a template type conversion operator in the implementation. // a template type conversion operator in the implementation.
// //
// We define this as a macro in order to eliminate duplicated source // We define this as a macro in order to eliminate duplicated source
// code. // code.
// //
// The following template definition assumes that the Rhs parameter is // The following template definition assumes that the Rhs parameter is
// a "bare" type (i.e. neither 'const T' nor 'T&'). // a "bare" type (i.e. neither 'const T' nor 'T&').
#define GMOCK_IMPLEMENT_COMPARISON_MATCHER(name, op, relation) \ #define GMOCK_IMPLEMENT_COMPARISON_MATCHER_(name, op, relation) \
template <typename Rhs> class name##Matcher { \ template <typename Rhs> class name##Matcher { \
public: \ public: \
explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \ explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \
template <typename Lhs> \ template <typename Lhs> \
operator Matcher<Lhs>() const { \ operator Matcher<Lhs>() const { \
return MakeMatcher(new Impl<Lhs>(rhs_)); \ return MakeMatcher(new Impl<Lhs>(rhs_)); \
} \ } \
private: \ private: \
template <typename Lhs> \ template <typename Lhs> \
class Impl : public MatcherInterface<Lhs> { \ class Impl : public MatcherInterface<Lhs> { \
skipping to change at line 560 skipping to change at line 561
UniversalPrinter<Rhs>::Print(rhs_, os); \ UniversalPrinter<Rhs>::Print(rhs_, os); \
} \ } \
private: \ private: \
Rhs rhs_; \ Rhs rhs_; \
}; \ }; \
Rhs rhs_; \ Rhs rhs_; \
} }
// Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v) // Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)
// respectively. // respectively.
GMOCK_IMPLEMENT_COMPARISON_MATCHER(Eq, ==, "equal to"); GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, "equal to");
GMOCK_IMPLEMENT_COMPARISON_MATCHER(Ge, >=, "greater than or equal to"); GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, "greater than or equal to");
GMOCK_IMPLEMENT_COMPARISON_MATCHER(Gt, >, "greater than"); GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, "greater than");
GMOCK_IMPLEMENT_COMPARISON_MATCHER(Le, <=, "less than or equal to"); GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, "less than or equal to");
GMOCK_IMPLEMENT_COMPARISON_MATCHER(Lt, <, "less than"); GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, "less than");
GMOCK_IMPLEMENT_COMPARISON_MATCHER(Ne, !=, "not equal to"); GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "not equal to");
#undef GMOCK_IMPLEMENT_COMPARISON_MATCHER #undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
// Implements the polymorphic NotNull() matcher, which matches any // Implements the polymorphic NotNull() matcher, which matches any
// pointer that is not NULL. // pointer that is not NULL.
class NotNullMatcher { class NotNullMatcher {
public: public:
template <typename T> template <typename T>
bool Matches(T* p) const { return p != NULL; } bool Matches(T* p) const { return p != NULL; }
void DescribeTo(::std::ostream* os) const { *os << "is not NULL"; } void DescribeTo(::std::ostream* os) const { *os << "is not NULL"; }
void DescribeNegationTo(::std::ostream* os) const { void DescribeNegationTo(::std::ostream* os) const {
skipping to change at line 895 skipping to change at line 896
// using one of the ==, <=, <, etc, operators. The two fields being // using one of the ==, <=, <, etc, operators. The two fields being
// compared don't have to have the same type. // compared don't have to have the same type.
// //
// The matcher defined here is polymorphic (for example, Eq() can be // The matcher defined here is polymorphic (for example, Eq() can be
// used to match a tuple<int, short>, a tuple<const long&, double>, // used to match a tuple<int, short>, a tuple<const long&, double>,
// etc). Therefore we use a template type conversion operator in the // etc). Therefore we use a template type conversion operator in the
// implementation. // implementation.
// //
// We define this as a macro in order to eliminate duplicated source // We define this as a macro in order to eliminate duplicated source
// code. // code.
#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER(name, op, relation) \ #define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \
class name##2Matcher { \ class name##2Matcher { \
public: \ public: \
template <typename T1, typename T2> \ template <typename T1, typename T2> \
operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \ operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \
return MakeMatcher(new Impl<T1, T2>); \ return MakeMatcher(new Impl<T1, T2>); \
} \ } \
private: \ private: \
template <typename T1, typename T2> \ template <typename T1, typename T2> \
class Impl : public MatcherInterface<const ::std::tr1::tuple<T1, T2>&> { \ class Impl : public MatcherInterface<const ::std::tr1::tuple<T1, T2>&> { \
public: \ public: \
skipping to change at line 919 skipping to change at line 920
virtual void DescribeTo(::std::ostream* os) const { \ virtual void DescribeTo(::std::ostream* os) const { \
*os << "argument #0 is " relation " argument #1"; \ *os << "argument #0 is " relation " argument #1"; \
} \ } \
virtual void DescribeNegationTo(::std::ostream* os) const { \ virtual void DescribeNegationTo(::std::ostream* os) const { \
*os << "argument #0 is not " relation " argument #1"; \ *os << "argument #0 is not " relation " argument #1"; \
} \ } \
}; \ }; \
} }
// Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively. // Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.
GMOCK_IMPLEMENT_COMPARISON2_MATCHER(Eq, ==, "equal to"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Eq, ==, "equal to");
GMOCK_IMPLEMENT_COMPARISON2_MATCHER(Ge, >=, "greater than or equal to"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ge, >=, "greater than or equal to");
GMOCK_IMPLEMENT_COMPARISON2_MATCHER(Gt, >, "greater than"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Gt, >, "greater than");
GMOCK_IMPLEMENT_COMPARISON2_MATCHER(Le, <=, "less than or equal to"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Le, <=, "less than or equal to");
GMOCK_IMPLEMENT_COMPARISON2_MATCHER(Lt, <, "less than"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Lt, <, "less than");
GMOCK_IMPLEMENT_COMPARISON2_MATCHER(Ne, !=, "not equal to"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, "not equal to");
#undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER #undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
// Implements the Not(m) matcher, which matches a value that doesn't // Implements the Not(m) matcher, which matches a value that doesn't
// match matcher m. // match matcher m.
template <typename InnerMatcher> template <typename InnerMatcher>
class NotMatcher { class NotMatcher {
public: public:
explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {} explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}
// This template type conversion operator allows Not(m) to be used // This template type conversion operator allows Not(m) to be used
// to match any type m can match. // to match any type m can match.
skipping to change at line 1143 skipping to change at line 1144
class TrulyMatcher { class TrulyMatcher {
public: public:
explicit TrulyMatcher(Predicate pred) : predicate_(pred) {} explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}
// This method template allows Truly(pred) to be used as a matcher // This method template allows Truly(pred) to be used as a matcher
// for type T where T is the argument type of predicate 'pred'. The // for type T where T is the argument type of predicate 'pred'. The
// argument is passed by reference as the predicate may be // argument is passed by reference as the predicate may be
// interested in the address of the argument. // interested in the address of the argument.
template <typename T> template <typename T>
bool Matches(T& x) const { bool Matches(T& x) const {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// MSVC warns about converting a value into bool (warning 4800). // MSVC warns about converting a value into bool (warning 4800).
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4800) // Temporarily disables warning 4800. #pragma warning(disable:4800) // Temporarily disables warning 4800.
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
return predicate_(x); return predicate_(x);
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
} }
void DescribeTo(::std::ostream* os) const { void DescribeTo(::std::ostream* os) const {
*os << "satisfies the given predicate"; *os << "satisfies the given predicate";
} }
void DescribeNegationTo(::std::ostream* os) const { void DescribeNegationTo(::std::ostream* os) const {
*os << "doesn't satisfy the given predicate"; *os << "doesn't satisfy the given predicate";
skipping to change at line 1366 skipping to change at line 1367
// enough for implementing the DescribeTo() method of Pointee(). // enough for implementing the DescribeTo() method of Pointee().
template <typename Pointer> template <typename Pointer>
operator Matcher<Pointer>() const { operator Matcher<Pointer>() const {
return MakeMatcher(new Impl<Pointer>(matcher_)); return MakeMatcher(new Impl<Pointer>(matcher_));
} }
private: private:
// The monomorphic implementation that works for a particular pointer typ e. // The monomorphic implementation that works for a particular pointer typ e.
template <typename Pointer> template <typename Pointer>
class Impl : public MatcherInterface<Pointer> { class Impl : public MatcherInterface<Pointer> {
public: public:
typedef typename PointeeOf<GMOCK_REMOVE_CONST( // NOLINT typedef typename PointeeOf<GMOCK_REMOVE_CONST_( // NOLINT
GMOCK_REMOVE_REFERENCE(Pointer))>::type Pointee; GMOCK_REMOVE_REFERENCE_(Pointer))>::type Pointee;
explicit Impl(const InnerMatcher& matcher) explicit Impl(const InnerMatcher& matcher)
: matcher_(MatcherCast<const Pointee&>(matcher)) {} : matcher_(MatcherCast<const Pointee&>(matcher)) {}
virtual bool Matches(Pointer p) const { virtual bool Matches(Pointer p) const {
return GetRawPointer(p) != NULL && matcher_.Matches(*p); return GetRawPointer(p) != NULL && matcher_.Matches(*p);
} }
virtual void DescribeTo(::std::ostream* os) const { virtual void DescribeTo(::std::ostream* os) const {
*os << "points to a value that "; *os << "points to a value that ";
skipping to change at line 1476 skipping to change at line 1477
// Implements the Property() matcher for matching a property // Implements the Property() matcher for matching a property
// (i.e. return value of a getter method) of an object. // (i.e. return value of a getter method) of an object.
template <typename Class, typename PropertyType> template <typename Class, typename PropertyType>
class PropertyMatcher { class PropertyMatcher {
public: public:
// The property may have a reference type, so 'const PropertyType&' // The property may have a reference type, so 'const PropertyType&'
// may cause double references and fail to compile. That's why we // may cause double references and fail to compile. That's why we
// need GMOCK_REFERENCE_TO_CONST, which works regardless of // need GMOCK_REFERENCE_TO_CONST, which works regardless of
// PropertyType being a reference or not. // PropertyType being a reference or not.
typedef GMOCK_REFERENCE_TO_CONST(PropertyType) RefToConstProperty; typedef GMOCK_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;
PropertyMatcher(PropertyType (Class::*property)() const, PropertyMatcher(PropertyType (Class::*property)() const,
const Matcher<RefToConstProperty>& matcher) const Matcher<RefToConstProperty>& matcher)
: property_(property), matcher_(matcher) {} : property_(property), matcher_(matcher) {}
// Returns true iff obj.property() matches the inner matcher. // Returns true iff obj.property() matches the inner matcher.
bool Matches(const Class& obj) const { bool Matches(const Class& obj) const {
return matcher_.Matches((obj.*property_)()); return matcher_.Matches((obj.*property_)());
} }
skipping to change at line 1638 skipping to change at line 1639
const Matcher<ResultType> matcher_; const Matcher<ResultType> matcher_;
}; };
// Explains the result of matching a value against a functor matcher. // Explains the result of matching a value against a functor matcher.
template <typename T, typename Callable> template <typename T, typename Callable>
void ExplainMatchResultTo(const ResultOfMatcher<Callable>& matcher, void ExplainMatchResultTo(const ResultOfMatcher<Callable>& matcher,
T obj, ::std::ostream* os) { T obj, ::std::ostream* os) {
matcher.ExplainMatchResultTo(obj, os); matcher.ExplainMatchResultTo(obj, os);
} }
// Implements an equality matcher for any STL-style container whose element
s
// support ==. This matcher is like Eq(), but its failure explanations prov
ide
// more detailed information that is useful when the container is used as a
set.
// The failure message reports elements that are in one of the operands but
not
// the other. The failure messages do not report duplicate or out-of-order
// elements in the containers (which don't properly matter to sets, but can
// occur if the containers are vectors or lists, for example).
//
// Uses the container's const_iterator, value_type, operator ==,
// begin(), and end().
template <typename Container>
class ContainerEqMatcher {
public:
explicit ContainerEqMatcher(const Container& rhs) : rhs_(rhs) {}
bool Matches(const Container& lhs) const { return lhs == rhs_; }
void DescribeTo(::std::ostream* os) const {
*os << "equals ";
UniversalPrinter<Container>::Print(rhs_, os);
}
void DescribeNegationTo(::std::ostream* os) const {
*os << "does not equal ";
UniversalPrinter<Container>::Print(rhs_, os);
}
void ExplainMatchResultTo(const Container& lhs,
::std::ostream* os) const {
// Something is different. Check for missing values first.
bool printed_header = false;
for (typename Container::const_iterator it = lhs.begin();
it != lhs.end(); ++it) {
if (std::find(rhs_.begin(), rhs_.end(), *it) == rhs_.end()) {
if (printed_header) {
*os << ", ";
} else {
*os << "Only in actual: ";
printed_header = true;
}
UniversalPrinter<typename Container::value_type>::Print(*it, os);
}
}
// Now check for extra values.
bool printed_header2 = false;
for (typename Container::const_iterator it = rhs_.begin();
it != rhs_.end(); ++it) {
if (std::find(lhs.begin(), lhs.end(), *it) == lhs.end()) {
if (printed_header2) {
*os << ", ";
} else {
*os << (printed_header ? "; not" : "Not") << " in actual: ";
printed_header2 = true;
}
UniversalPrinter<typename Container::value_type>::Print(*it, os);
}
}
}
private:
const Container rhs_;
};
template <typename Container>
void ExplainMatchResultTo(const ContainerEqMatcher<Container>& matcher,
const Container& lhs,
::std::ostream* os) {
matcher.ExplainMatchResultTo(lhs, os);
}
} // namespace internal } // namespace internal
// Implements MatcherCast(). // Implements MatcherCast().
template <typename T, typename M> template <typename T, typename M>
inline Matcher<T> MatcherCast(M matcher) { inline Matcher<T> MatcherCast(M matcher) {
return internal::MatcherCastImpl<T, M>::Cast(matcher); return internal::MatcherCastImpl<T, M>::Cast(matcher);
} }
// _ is a matcher that matches anything of any type. // _ is a matcher that matches anything of any type.
// //
skipping to change at line 1794 skipping to change at line 1862
// matches 'matcher'. For example, // matches 'matcher'. For example,
// Property(&Foo::str, StartsWith("hi")) // Property(&Foo::str, StartsWith("hi"))
// matches a Foo object x iff x.str() starts with "hi". // matches a Foo object x iff x.str() starts with "hi".
template <typename Class, typename PropertyType, typename PropertyMatcher> template <typename Class, typename PropertyType, typename PropertyMatcher>
inline PolymorphicMatcher< inline PolymorphicMatcher<
internal::PropertyMatcher<Class, PropertyType> > Property( internal::PropertyMatcher<Class, PropertyType> > Property(
PropertyType (Class::*property)() const, const PropertyMatcher& matcher ) { PropertyType (Class::*property)() const, const PropertyMatcher& matcher ) {
return MakePolymorphicMatcher( return MakePolymorphicMatcher(
internal::PropertyMatcher<Class, PropertyType>( internal::PropertyMatcher<Class, PropertyType>(
property, property,
MatcherCast<GMOCK_REFERENCE_TO_CONST(PropertyType)>(matcher))); MatcherCast<GMOCK_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
// The call to MatcherCast() is required for supporting inner // The call to MatcherCast() is required for supporting inner
// matchers of compatible types. For example, it allows // matchers of compatible types. For example, it allows
// Property(&Foo::bar, m) // Property(&Foo::bar, m)
// to compile where bar() returns an int32 and m is a matcher for int64. // to compile where bar() returns an int32 and m is a matcher for int64.
} }
// Creates a matcher that matches an object iff the result of applying // Creates a matcher that matches an object iff the result of applying
// a callable to x matches 'matcher'. // a callable to x matches 'matcher'.
// For example, // For example,
// ResultOf(f, StartsWith("hi")) // ResultOf(f, StartsWith("hi"))
skipping to change at line 2076 skipping to change at line 2144
// Returns a matcher that matches anything that satisfies the given // Returns a matcher that matches anything that satisfies the given
// predicate. The predicate can be any unary function or functor // predicate. The predicate can be any unary function or functor
// whose return type can be implicitly converted to bool. // whose return type can be implicitly converted to bool.
template <typename Predicate> template <typename Predicate>
inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> > inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> >
Truly(Predicate pred) { Truly(Predicate pred) {
return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred)); return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred));
} }
// Returns a matcher that matches an equal container.
// This matcher behaves like Eq(), but in the event of mismatch lists the
// values that are included in one container but not the other. (Duplicate
// values and order differences are not explained.)
template <typename Container>
inline PolymorphicMatcher<internal::ContainerEqMatcher<Container> >
ContainerEq(const Container& rhs) {
return MakePolymorphicMatcher(internal::ContainerEqMatcher<Container>(rhs
));
}
// Returns a predicate that is satisfied by anything that matches the // Returns a predicate that is satisfied by anything that matches the
// given matcher. // given matcher.
template <typename M> template <typename M>
inline internal::MatcherAsPredicate<M> Matches(M matcher) { inline internal::MatcherAsPredicate<M> Matches(M matcher) {
return internal::MatcherAsPredicate<M>(matcher); return internal::MatcherAsPredicate<M>(matcher);
} }
// These macros allow using matchers to check values in Google Test // These macros allow using matchers to check values in Google Test
// tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher) // tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
// succeed iff the value matches the matcher. If the assertion fails, // succeed iff the value matches the matcher. If the assertion fails,
 End of changes. 16 change blocks. 
26 lines changed or deleted 110 lines changed or added


 gmock-port.h   gmock-port.h 
skipping to change at line 61 skipping to change at line 61
#if defined(__GNUC__) #if defined(__GNUC__)
// GCC implements tr1/tuple in the <tr1/tuple> header. This does not // GCC implements tr1/tuple in the <tr1/tuple> header. This does not
// conform to the TR1 spec, which requires the header to be <tuple>. // conform to the TR1 spec, which requires the header to be <tuple>.
#include <tr1/tuple> #include <tr1/tuple>
#else #else
// If the compiler is not GCC, we assume the user is using a // If the compiler is not GCC, we assume the user is using a
// spec-conforming TR1 implementation. // spec-conforming TR1 implementation.
#include <tuple> #include <tuple>
#endif // __GNUC__ #endif // __GNUC__
#ifdef GTEST_OS_LINUX #if GTEST_OS_LINUX
// On some platforms, <regex.h> needs someone to define size_t, and // On some platforms, <regex.h> needs someone to define size_t, and
// won't compile otherwise. We can #include it here as we already // won't compile otherwise. We can #include it here as we already
// included <stdlib.h>, which is guaranteed to define size_t through // included <stdlib.h>, which is guaranteed to define size_t through
// <stddef.h>. // <stddef.h>.
#include <regex.h> // NOLINT #include <regex.h> // NOLINT
// Defines this iff Google Mock uses the enhanced POSIX regular // Defines this iff Google Mock uses the enhanced POSIX regular
// expression syntax. This is public as it affects how a user uses // expression syntax. This is public as it affects how a user uses
// regular expression matchers. // regular expression matchers.
skipping to change at line 88 skipping to change at line 88
// is public as it tells a user whether he can use regular expression // is public as it tells a user whether he can use regular expression
// matchers. // matchers.
#define GMOCK_HAS_REGEX 1 #define GMOCK_HAS_REGEX 1
#endif // defined(GMOCK_USES_PCRE) || defined(GMOCK_USES_POSIX_RE) #endif // defined(GMOCK_USES_PCRE) || defined(GMOCK_USES_POSIX_RE)
namespace testing { namespace testing {
namespace internal { namespace internal {
// For Windows, check the compiler version. At least VS 2005 SP1 is // For Windows, check the compiler version. At least VS 2005 SP1 is
// required to compile Google Mock. // required to compile Google Mock.
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#if _MSC_VER < 1400 #if _MSC_VER < 1400
#error "At least Visual Studio 2005 SP1 is required to compile Google Mock. " #error "At least Visual Studio 2005 SP1 is required to compile Google Mock. "
#elif _MSC_VER == 1400 #elif _MSC_VER == 1400
// Unfortunately there is no unique _MSC_VER number for SP1. So for VS 2005 // Unfortunately there is no unique _MSC_VER number for SP1. So for VS 2005
// we have to check if it has SP1 by checking whether a bug fixed in SP1 // we have to check if it has SP1 by checking whether a bug fixed in SP1
// is present. The bug in question is // is present. The bug in question is
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Fee dbackID=101702 // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Fee dbackID=101702
// where the compiler incorrectly reports sizeof(poiter to an array). // where the compiler incorrectly reports sizeof(poiter to an array).
skipping to change at line 186 skipping to change at line 186
// GMOCK_COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); // GMOCK_COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
// //
// The second argument to the macro is the name of the variable. If // The second argument to the macro is the name of the variable. If
// the expression is false, most compilers will issue a warning/error // the expression is false, most compilers will issue a warning/error
// containing the name of the variable. // containing the name of the variable.
template <bool> template <bool>
struct CompileAssert { struct CompileAssert {
}; };
#define GMOCK_COMPILE_ASSERT(expr, msg) \ #define GMOCK_COMPILE_ASSERT_(expr, msg) \
typedef ::testing::internal::CompileAssert<(bool(expr))> \ typedef ::testing::internal::CompileAssert<(bool(expr))> \
msg[bool(expr) ? 1 : -1] msg[bool(expr) ? 1 : -1]
// Implementation details of GMOCK_COMPILE_ASSERT: // Implementation details of GMOCK_COMPILE_ASSERT_:
// //
// - GMOCK_COMPILE_ASSERT works by defining an array type that has -1 // - GMOCK_COMPILE_ASSERT_ works by defining an array type that has -1
// elements (and thus is invalid) when the expression is false. // elements (and thus is invalid) when the expression is false.
// //
// - The simpler definition // - The simpler definition
// //
// #define GMOCK_COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1] // #define GMOCK_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1]
// //
// does not work, as gcc supports variable-length arrays whose sizes // does not work, as gcc supports variable-length arrays whose sizes
// are determined at run-time (this is gcc's extension and not part // are determined at run-time (this is gcc's extension and not part
// of the C++ standard). As a result, gcc fails to reject the // of the C++ standard). As a result, gcc fails to reject the
// following code with the simple definition: // following code with the simple definition:
// //
// int foo; // int foo;
// GMOCK_COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is // GMOCK_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo i
// // not a compile-time constant. s
// // not a compile-time constant.
// //
// - By using the type CompileAssert<(bool(expr))>, we ensures that // - By using the type CompileAssert<(bool(expr))>, we ensures that
// expr is a compile-time constant. (Template arguments must be // expr is a compile-time constant. (Template arguments must be
// determined at compile-time.) // determined at compile-time.)
// //
// - The outter parentheses in CompileAssert<(bool(expr))> are necessary // - The outter parentheses in CompileAssert<(bool(expr))> are necessary
// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written // to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
// //
// CompileAssert<bool(expr)> // CompileAssert<bool(expr)>
// //
// instead, these compilers will refuse to compile // instead, these compilers will refuse to compile
// //
// GMOCK_COMPILE_ASSERT(5 > 0, some_message); // GMOCK_COMPILE_ASSERT_(5 > 0, some_message);
// //
// (They seem to think the ">" in "5 > 0" marks the end of the // (They seem to think the ">" in "5 > 0" marks the end of the
// template argument list.) // template argument list.)
// //
// - The array size is (bool(expr) ? 1 : -1), instead of simply // - The array size is (bool(expr) ? 1 : -1), instead of simply
// //
// ((expr) ? 1 : -1). // ((expr) ? 1 : -1).
// //
// This is to avoid running into a bug in MS VC 7.1, which // This is to avoid running into a bug in MS VC 7.1, which
// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. // causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
skipping to change at line 296 skipping to change at line 296
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (condition) \ if (condition) \
; \ ; \
else \ else \
::testing::internal::GMockCheckProvider(\ ::testing::internal::GMockCheckProvider(\
#condition, __FILE__, __LINE__).GetStream() #condition, __FILE__, __LINE__).GetStream()
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
// Macro for referencing flags. // Macro for referencing flags. This is public as we want the user to
// use this syntax to reference Google Mock flags.
#define GMOCK_FLAG(name) FLAGS_gmock_##name #define GMOCK_FLAG(name) FLAGS_gmock_##name
// Macros for declaring flags. // Macros for declaring flags.
#define GMOCK_DECLARE_bool(name) extern bool GMOCK_FLAG(name) #define GMOCK_DECLARE_bool_(name) extern bool GMOCK_FLAG(name)
#define GMOCK_DECLARE_int32(name) \ #define GMOCK_DECLARE_int32_(name) \
extern ::testing::internal::Int32 GMOCK_FLAG(name) extern ::testing::internal::Int32 GMOCK_FLAG(name)
#define GMOCK_DECLARE_string(name) \ #define GMOCK_DECLARE_string_(name) \
extern ::testing::internal::String GMOCK_FLAG(name) extern ::testing::internal::String GMOCK_FLAG(name)
// Macros for defining flags. // Macros for defining flags.
#define GMOCK_DEFINE_bool(name, default_val, doc) \ #define GMOCK_DEFINE_bool_(name, default_val, doc) \
bool GMOCK_FLAG(name) = (default_val) bool GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_int32(name, default_val, doc) \ #define GMOCK_DEFINE_int32_(name, default_val, doc) \
::testing::internal::Int32 GMOCK_FLAG(name) = (default_val) ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_string(name, default_val, doc) \ #define GMOCK_DEFINE_string_(name, default_val, doc) \
::testing::internal::String GMOCK_FLAG(name) = (default_val) ::testing::internal::String GMOCK_FLAG(name) = (default_val)
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
 End of changes. 14 change blocks. 
16 lines changed or deleted 18 lines changed or added


 gmock-printers.h   gmock-printers.h 
skipping to change at line 44 skipping to change at line 44
// This file implements a universal value printer that can print a // This file implements a universal value printer that can print a
// value of any type T: // value of any type T:
// //
// void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_pt r); // void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_pt r);
// //
// It uses the << operator when possible, and prints the bytes in the // It uses the << operator when possible, and prints the bytes in the
// object otherwise. A user can override its behavior for a class // object otherwise. A user can override its behavior for a class
// type Foo by defining either operator<<(::std::ostream&, const Foo&) // type Foo by defining either operator<<(::std::ostream&, const Foo&)
// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that // or void PrintTo(const Foo&, ::std::ostream*) in the namespace that
// defines Foo. If both are defined, PrintTo() takes precedence. // defines Foo. If both are defined, PrintTo() takes precedence.
// When T is a reference type, the address of the value is also //
// To aid debugging: when T is a reference type, the address of the
// value is also printed; when T is a (const) char pointer, both the
// pointer value and the NUL-terminated string it points to are
// printed. // printed.
// //
// We also provide a convenient wrapper // We also provide some convenient wrappers:
// //
// string ::testing::internal::UniversalPrinter<T>::PrintAsString(value); // // Prints a value as the given type to a string.
// string ::testing::internal::UniversalPrinter<T>::PrintToString(value);
//
// // Prints a value tersely: for a reference type, the referenced
// // value (but not the address) is printed; for a (const) char
// // pointer, the NUL-terminated string (but not the pointer) is
// // printed.
// void ::testing::internal::UniversalTersePrint(const T& value, ostream*
);
//
// // Prints the fields of a tuple tersely to a string vector, one
// // element for each field.
// std::vector<string> UniversalTersePrintTupleFieldsToStrings(
// const Tuple& value);
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include <sstream>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector>
#include <gmock/internal/gmock-internal-utils.h> #include <gmock/internal/gmock-internal-utils.h>
#include <gmock/internal/gmock-port.h> #include <gmock/internal/gmock-port.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
// Makes sure there is at least one << operator declared in the global // Makes sure there is at least one << operator declared in the global
// namespace. This has no implementation and won't be called // namespace. This has no implementation and won't be called
// anywhere. We just need the declaration such that we can say "using // anywhere. We just need the declaration such that we can say "using
// ::operator <<;" in the definition of PrintTo() below. // ::operator <<;" in the definition of PrintTo() below.
void operator<<(::testing::internal::Unused, int); void operator<<(::testing::internal::Unused, int);
skipping to change at line 119 skipping to change at line 136
// UniversalPrinter<T>::Print() does when it knows nothing about type // UniversalPrinter<T>::Print() does when it knows nothing about type
// T and T has no << operator. // T and T has no << operator.
// //
// A user can override this behavior for a class type Foo by defining // A user can override this behavior for a class type Foo by defining
// a << operator in the namespace where Foo is defined. // a << operator in the namespace where Foo is defined.
// //
// We put this operator in namespace 'internal2' instead of 'internal' // We put this operator in namespace 'internal2' instead of 'internal'
// to simplify the implementation, as much code in 'internal' needs to // to simplify the implementation, as much code in 'internal' needs to
// use << in STL, which would conflict with our own << were it defined // use << in STL, which would conflict with our own << were it defined
// in 'internal'. // in 'internal'.
template <typename T> //
::std::ostream& operator<<(::std::ostream& os, const T& x) { // Note that this operator<< takes a generic std::basic_ostream<Char,
// CharTraits> type instead of the more restricted std::ostream. If
// we define it to take an std::ostream instead, we'll get an
// "ambiguous overloads" compiler error when trying to print a type
// Foo that supports streaming to std::basic_ostream<Char,
// CharTraits>, as the compiler cannot tell whether
// operator<<(std::ostream&, const T&) or
// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
// specific.
template <typename Char, typename CharTraits, typename T>
::std::basic_ostream<Char, CharTraits>& operator<<(
::std::basic_ostream<Char, CharTraits>& os, const T& x) {
TypeWithoutFormatter<T, ::testing::internal::IsAProtocolMessage<T>::value >:: TypeWithoutFormatter<T, ::testing::internal::IsAProtocolMessage<T>::value >::
PrintValue(x, &os); PrintValue(x, &os);
return os; return os;
} }
} // namespace internal2 } // namespace internal2
namespace internal { namespace internal {
// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
skipping to change at line 339 skipping to change at line 367
#if GTEST_HAS_STD_WSTRING #if GTEST_HAS_STD_WSTRING
void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os); void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
PrintWideStringTo(s, os); PrintWideStringTo(s, os);
} }
#endif // GTEST_HAS_STD_WSTRING #endif // GTEST_HAS_STD_WSTRING
// Overload for ::std::tr1::tuple. Needed for printing function // Overload for ::std::tr1::tuple. Needed for printing function
// arguments, which are packed as tuples. // arguments, which are packed as tuples.
// This helper template allows PrintTo() for tuples to be defined by typedef ::std::vector<string> Strings;
// This helper template allows PrintTo() for tuples and
// UniversalTersePrintTupleFieldsToStrings() to be defined by
// induction on the number of tuple fields. The idea is that // induction on the number of tuple fields. The idea is that
// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N // TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N
// fields in tuple t, and can be defined in terms of // fields in tuple t, and can be defined in terms of
// TuplePrefixPrinter<N - 1>. // TuplePrefixPrinter<N - 1>.
// The inductive case.
template <size_t N> template <size_t N>
struct TuplePrefixPrinter { struct TuplePrefixPrinter {
// Prints the first N fields of a tuple.
template <typename Tuple> template <typename Tuple>
static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os); TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
*os << ", "; *os << ", ";
UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type > UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type >
::Print(::std::tr1::get<N - 1>(t), os); ::Print(::std::tr1::get<N - 1>(t), os);
} }
// Tersely prints the first N fields of a tuple to a string vector,
// one element for each field.
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
::std::stringstream ss;
UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
strings->push_back(ss.str());
}
}; };
// Base cases.
template <> template <>
struct TuplePrefixPrinter<0> { struct TuplePrefixPrinter<0> {
template <typename Tuple> template <typename Tuple>
static void PrintPrefixTo(const Tuple&, ::std::ostream*) {} static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
};
template <>
struct TuplePrefixPrinter<1> {
template <typename Tuple> template <typename Tuple>
static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
Print(::std::tr1::get<0>(t), os);
}
}; };
template <>
template <typename Tuple>
void TuplePrefixPrinter<1>::PrintPrefixTo(const Tuple& t, ::std::ostream* o
s) {
UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
Print(::std::tr1::get<0>(t), os);
}
// Helper function for printing a tuple. T must be instantiated with // Helper function for printing a tuple. T must be instantiated with
// a tuple type. // a tuple type.
template <typename T> template <typename T>
void PrintTupleTo(const T& t, ::std::ostream* os) { void PrintTupleTo(const T& t, ::std::ostream* os) {
*os << "("; *os << "(";
TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>:: TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
PrintPrefixTo(t, os); PrintPrefixTo(t, os);
*os << ")"; *os << ")";
} }
skipping to change at line 488 skipping to change at line 535
// Thanks to Koenig look-up, if T is a class and has its own // Thanks to Koenig look-up, if T is a class and has its own
// PrintTo() function defined in its namespace, that function will // PrintTo() function defined in its namespace, that function will
// be visible here. Since it is more specific than the generic ones // be visible here. Since it is more specific than the generic ones
// in ::testing::internal, it will be picked by the compiler in the // in ::testing::internal, it will be picked by the compiler in the
// following statement - exactly what we want. // following statement - exactly what we want.
PrintTo(value, os); PrintTo(value, os);
} }
// A convenient wrapper for Print() that returns the print-out as a // A convenient wrapper for Print() that returns the print-out as a
// string. // string.
static string PrintAsString(const T& value) { static string PrintToString(const T& value) {
::std::stringstream ss; ::std::stringstream ss;
Print(value, &ss); Print(value, &ss);
return ss.str(); return ss.str();
} }
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#endif // _MSC_VER #endif // _MSC_VER
}; };
skipping to change at line 537 skipping to change at line 584
PrintRawArrayTo(a, kChunkSize, os); PrintRawArrayTo(a, kChunkSize, os);
*os << ", ..., "; *os << ", ..., ";
PrintRawArrayTo(a + N - kChunkSize, kChunkSize, os); PrintRawArrayTo(a + N - kChunkSize, kChunkSize, os);
} }
*os << " }"; *os << " }";
} }
} }
// A convenient wrapper for Print() that returns the print-out as a // A convenient wrapper for Print() that returns the print-out as a
// string. // string.
static string PrintAsString(const T (&a)[N]) { static string PrintToString(const T (&a)[N]) {
::std::stringstream ss; ::std::stringstream ss;
Print(a, &ss); Print(a, &ss);
return ss.str(); return ss.str();
} }
}; };
// Implements printing a reference type T&. // Implements printing a reference type T&.
template <typename T> template <typename T>
class UniversalPrinter<T&> { class UniversalPrinter<T&> {
public: public:
skipping to change at line 566 skipping to change at line 613
// Prints the address of the value. We use reinterpret_cast here // Prints the address of the value. We use reinterpret_cast here
// as static_cast doesn't compile when T is a function type. // as static_cast doesn't compile when T is a function type.
*os << "@" << reinterpret_cast<const void*>(&value) << " "; *os << "@" << reinterpret_cast<const void*>(&value) << " ";
// Then prints the value itself. // Then prints the value itself.
UniversalPrinter<T>::Print(value, os); UniversalPrinter<T>::Print(value, os);
} }
// A convenient wrapper for Print() that returns the print-out as a // A convenient wrapper for Print() that returns the print-out as a
// string. // string.
static string PrintAsString(const T& value) { static string PrintToString(const T& value) {
::std::stringstream ss; ::std::stringstream ss;
Print(value, &ss); Print(value, &ss);
return ss.str(); return ss.str();
} }
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#endif // _MSC_VER #endif // _MSC_VER
}; };
// Prints a value tersely: for a reference type, the referenced value
// (but not the address) is printed; for a (const) char pointer, the
// NUL-terminated string (but not the pointer) is printed.
template <typename T>
void UniversalTersePrint(const T& value, ::std::ostream* os) {
UniversalPrinter<T>::Print(value, os);
}
inline void UniversalTersePrint(const char* str, ::std::ostream* os) {
if (str == NULL) {
*os << "NULL";
} else {
UniversalPrinter<string>::Print(string(str), os);
}
}
inline void UniversalTersePrint(char* str, ::std::ostream* os) {
UniversalTersePrint(static_cast<const char*>(str), os);
}
// Prints the fields of a tuple tersely to a string vector, one
// element for each field. See the comment before
// UniversalTersePrint() for how we define "tersely".
template <typename Tuple>
Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
Strings result;
TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
TersePrintPrefixToStrings(value, &result);
return result;
}
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_
 End of changes. 18 change blocks. 
16 lines changed or deleted 94 lines changed or added


 gmock-spec-builders.h   gmock-spec-builders.h 
skipping to change at line 381 skipping to change at line 381
// up mocks in the main thread unless you have a good reason not to do // up mocks in the main thread unless you have a good reason not to do
// so. // so.
class InSequence { class InSequence {
public: public:
InSequence(); InSequence();
~InSequence(); ~InSequence();
private: private:
bool sequence_created_; bool sequence_created_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence); // NOLINT GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence); // NOLINT
} GMOCK_ATTRIBUTE_UNUSED; } GMOCK_ATTRIBUTE_UNUSED_;
namespace internal { namespace internal {
// Points to the implicit sequence introduced by a living InSequence // Points to the implicit sequence introduced by a living InSequence
// object (if any) in the current thread or NULL. // object (if any) in the current thread or NULL.
extern ThreadLocal<Sequence*> g_gmock_implicit_sequence; extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
// Base class for implementing expectations. // Base class for implementing expectations.
// //
// There are two reasons for having a type-agnostic base class for // There are two reasons for having a type-agnostic base class for
skipping to change at line 1064 skipping to change at line 1064
= default_actions_.rbegin(); = default_actions_.rbegin();
it != default_actions_.rend(); ++it) { it != default_actions_.rend(); ++it) {
const DefaultActionSpec<F>& spec = *it; const DefaultActionSpec<F>& spec = *it;
if (spec.Matches(args)) if (spec.Matches(args))
return &spec; return &spec;
} }
return NULL; return NULL;
} }
// Performs the default action of this mock function on the given // Performs the default action of this mock function on the given argumen
// arguments and returns the result. This method doesn't depend on ts
// the mutable state of this object, and thus can be called // and returns the result. Asserts with a helpful call descrption if ther
// concurrently without locking. e is
// no valid return value. This method doesn't depend on the mutable state
of
// this object, and thus can be called concurrently without locking.
// L = * // L = *
Result PerformDefaultAction(const ArgumentTuple& args) const { Result PerformDefaultAction(const ArgumentTuple& args,
const string& call_description) const {
const DefaultActionSpec<F>* const spec = FindDefaultActionSpec(args); const DefaultActionSpec<F>* const spec = FindDefaultActionSpec(args);
return (spec != NULL) ? spec->GetAction().Perform(args) if (spec != NULL) {
: DefaultValue<Result>::Get(); return spec->GetAction().Perform(args);
}
Assert(DefaultValue<Result>::Exists(), "", -1,
call_description + "\n The mock function has no default actio
n "
"set, and its return type has no default value set.");
return DefaultValue<Result>::Get();
} }
// Registers this function mocker and the mock object owning it; // Registers this function mocker and the mock object owning it;
// returns a reference to the function mocker object. This is only // returns a reference to the function mocker object. This is only
// called by the ON_CALL() and EXPECT_CALL() macros. // called by the ON_CALL() and EXPECT_CALL() macros.
FunctionMocker<F>& RegisterOwner(const void* mock_obj) { FunctionMocker<F>& RegisterOwner(const void* mock_obj) {
Mock::Register(mock_obj, this); Mock::Register(mock_obj, this);
return *down_cast<FunctionMocker<F>*>(this); return *down_cast<FunctionMocker<F>*>(this);
} }
skipping to change at line 1410 skipping to change at line 1416
mocker->DescribeUninterestingCall(args, &ss); mocker->DescribeUninterestingCall(args, &ss);
// We must get Google Mock's reaction on uninteresting calls // We must get Google Mock's reaction on uninteresting calls
// made on this mock object BEFORE performing the action, // made on this mock object BEFORE performing the action,
// because the action may DELETE the mock object and make the // because the action may DELETE the mock object and make the
// following expression meaningless. // following expression meaningless.
const CallReaction reaction = const CallReaction reaction =
Mock::GetReactionOnUninterestingCalls(mocker->MockObject()); Mock::GetReactionOnUninterestingCalls(mocker->MockObject());
// Calculates the function result. // Calculates the function result.
Result result = mocker->PerformDefaultAction(args); Result result = mocker->PerformDefaultAction(args, ss.str());
// Prints the function result. // Prints the function result.
ss << "\n Returns: "; ss << "\n Returns: ";
UniversalPrinter<Result>::Print(result, &ss); UniversalPrinter<Result>::Print(result, &ss);
ReportUninterestingCall(reaction, ss.str()); ReportUninterestingCall(reaction, ss.str());
return result; return result;
} }
bool is_excessive = false; bool is_excessive = false;
::std::stringstream ss; ::std::stringstream ss;
::std::stringstream why; ::std::stringstream why;
::std::stringstream loc;
Action<F> action; Action<F> action;
Expectation<F>* exp; Expectation<F>* exp;
// The FindMatchingExpectationAndAction() function acquires and // The FindMatchingExpectationAndAction() function acquires and
// releases g_gmock_mutex. // releases g_gmock_mutex.
const bool found = mocker->FindMatchingExpectationAndAction( const bool found = mocker->FindMatchingExpectationAndAction(
args, &exp, &action, &is_excessive, &ss, &why); args, &exp, &action, &is_excessive, &ss, &why);
ss << " Function call: " << mocker->Name(); ss << " Function call: " << mocker->Name();
UniversalPrinter<ArgumentTuple>::Print(args, &ss); UniversalPrinter<ArgumentTuple>::Print(args, &ss);
Result result = // In case the action deletes a piece of the expectation, we
action.IsDoDefault() ? mocker->PerformDefaultAction(args) // generate the message beforehand.
if (found && !is_excessive) {
exp->DescribeLocationTo(&loc);
}
Result result = action.IsDoDefault() ?
mocker->PerformDefaultAction(args, ss.str())
: action.Perform(args); : action.Perform(args);
ss << "\n Returns: "; ss << "\n Returns: ";
UniversalPrinter<Result>::Print(result, &ss); UniversalPrinter<Result>::Print(result, &ss);
ss << "\n" << why.str(); ss << "\n" << why.str();
if (found) { if (found) {
if (is_excessive) { if (is_excessive) {
// We had an upper-bound violation and the failure message is in ss . // We had an upper-bound violation and the failure message is in ss .
Expect(false, exp->file(), exp->line(), ss.str()); Expect(false, exp->file(), exp->line(), ss.str());
} else { } else {
// We had an expected call and the matching expectation is // We had an expected call and the matching expectation is
// described in ss. // described in ss.
::std::stringstream loc;
exp->DescribeLocationTo(&loc);
Log(INFO, loc.str() + ss.str(), 3); Log(INFO, loc.str() + ss.str(), 3);
} }
} else { } else {
// No expectation matches this call - reports a failure. // No expectation matches this call - reports a failure.
Expect(false, NULL, -1, ss.str()); Expect(false, NULL, -1, ss.str());
} }
return result; return result;
} }
}; // class InvokeWithHelper }; // class InvokeWithHelper
skipping to change at line 1483 skipping to change at line 1493
::std::stringstream ss; ::std::stringstream ss;
mocker->DescribeUninterestingCall(args, &ss); mocker->DescribeUninterestingCall(args, &ss);
// We must get Google Mock's reaction on uninteresting calls // We must get Google Mock's reaction on uninteresting calls
// made on this mock object BEFORE performing the action, // made on this mock object BEFORE performing the action,
// because the action may DELETE the mock object and make the // because the action may DELETE the mock object and make the
// following expression meaningless. // following expression meaningless.
const CallReaction reaction = const CallReaction reaction =
Mock::GetReactionOnUninterestingCalls(mocker->MockObject()); Mock::GetReactionOnUninterestingCalls(mocker->MockObject());
mocker->PerformDefaultAction(args); mocker->PerformDefaultAction(args, ss.str());
ReportUninterestingCall(reaction, ss.str()); ReportUninterestingCall(reaction, ss.str());
return; return;
} }
bool is_excessive = false; bool is_excessive = false;
::std::stringstream ss; ::std::stringstream ss;
::std::stringstream why; ::std::stringstream why;
::std::stringstream loc;
Action<F> action; Action<F> action;
Expectation<F>* exp; Expectation<F>* exp;
// The FindMatchingExpectationAndAction() function acquires and // The FindMatchingExpectationAndAction() function acquires and
// releases g_gmock_mutex. // releases g_gmock_mutex.
const bool found = mocker->FindMatchingExpectationAndAction( const bool found = mocker->FindMatchingExpectationAndAction(
args, &exp, &action, &is_excessive, &ss, &why); args, &exp, &action, &is_excessive, &ss, &why);
ss << " Function call: " << mocker->Name(); ss << " Function call: " << mocker->Name();
UniversalPrinter<ArgumentTuple>::Print(args, &ss); UniversalPrinter<ArgumentTuple>::Print(args, &ss);
ss << "\n" << why.str(); ss << "\n" << why.str();
// In case the action deletes a piece of the expectation, we
// generate the message beforehand.
if (found && !is_excessive) {
exp->DescribeLocationTo(&loc);
}
if (action.IsDoDefault()) { if (action.IsDoDefault()) {
mocker->PerformDefaultAction(args); mocker->PerformDefaultAction(args, ss.str());
} else { } else {
action.Perform(args); action.Perform(args);
} }
if (found) { if (found) {
// A matching expectation and corresponding action were found. // A matching expectation and corresponding action were found.
if (is_excessive) { if (is_excessive) {
// We had an upper-bound violation and the failure message is in ss . // We had an upper-bound violation and the failure message is in ss .
Expect(false, exp->file(), exp->line(), ss.str()); Expect(false, exp->file(), exp->line(), ss.str());
} else { } else {
// We had an expected call and the matching expectation is // We had an expected call and the matching expectation is
// described in ss. // described in ss.
::std::stringstream loc;
exp->DescribeLocationTo(&loc);
Log(INFO, loc.str() + ss.str(), 3); Log(INFO, loc.str() + ss.str(), 3);
} }
} else { } else {
// No matching expectation was found - reports an error. // No matching expectation was found - reports an error.
Expect(false, NULL, -1, ss.str()); Expect(false, NULL, -1, ss.str());
} }
} }
}; // class InvokeWithHelper<void, F> }; // class InvokeWithHelper<void, F>
} // namespace internal } // namespace internal
skipping to change at line 1559 skipping to change at line 1573
// EXPECT_CALL(Const(foo), Bar()); // EXPECT_CALL(Const(foo), Bar());
template <typename T> template <typename T>
inline const T& Const(const T& x) { return x; } inline const T& Const(const T& x) { return x; }
} // namespace testing } // namespace testing
// A separate macro is required to avoid compile errors when the name // A separate macro is required to avoid compile errors when the name
// of the method used in call is a result of macro expansion. // of the method used in call is a result of macro expansion.
// See CompilesWithMethodNameExpandedFromMacro tests in // See CompilesWithMethodNameExpandedFromMacro tests in
// internal/gmock-spec-builders_test.cc for more details. // internal/gmock-spec-builders_test.cc for more details.
#define ON_CALL_IMPL_(obj, call) \ #define GMOCK_ON_CALL_IMPL_(obj, call) \
((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \ ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
#obj, #call) #obj, #call)
#define ON_CALL(obj, call) ON_CALL_IMPL_(obj, call) #define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
#define EXPECT_CALL_IMPL_(obj, call) \ #define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call ) ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call )
#define EXPECT_CALL(obj, call) EXPECT_CALL_IMPL_(obj, call) #define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
 End of changes. 17 change blocks. 
21 lines changed or deleted 39 lines changed or added


 gmock.h   gmock.h 
skipping to change at line 71 skipping to change at line 71
#include <gmock/gmock-generated-function-mockers.h> #include <gmock/gmock-generated-function-mockers.h>
#include <gmock/gmock-generated-matchers.h> #include <gmock/gmock-generated-matchers.h>
#include <gmock/gmock-generated-nice-strict.h> #include <gmock/gmock-generated-nice-strict.h>
#include <gmock/gmock-matchers.h> #include <gmock/gmock-matchers.h>
#include <gmock/gmock-printers.h> #include <gmock/gmock-printers.h>
#include <gmock/internal/gmock-internal-utils.h> #include <gmock/internal/gmock-internal-utils.h>
namespace testing { namespace testing {
// Declares Google Mock flags that we want a user to use programmatically. // Declares Google Mock flags that we want a user to use programmatically.
GMOCK_DECLARE_string(verbose); GMOCK_DECLARE_string_(verbose);
// Initializes Google Mock. This must be called before running the // Initializes Google Mock. This must be called before running the
// tests. In particular, it parses the command line for the flags // tests. In particular, it parses the command line for the flags
// that Google Mock recognizes. Whenever a Google Mock flag is seen, // that Google Mock recognizes. Whenever a Google Mock flag is seen,
// it is removed from argv, and *argc is decremented. // it is removed from argv, and *argc is decremented.
// //
// No value is returned. Instead, the Google Mock flag variables are // No value is returned. Instead, the Google Mock flag variables are
// updated. // updated.
// //
// Since Google Test is needed for Google Mock to work, this function // Since Google Test is needed for Google Mock to work, this function
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gtest-death-test-internal.h   gtest-death-test-internal.h 
skipping to change at line 42 skipping to change at line 42
// The Google C++ Testing Framework (Google Test) // The Google C++ Testing Framework (Google Test)
// //
// This header file defines internal utilities needed for implementing // This header file defines internal utilities needed for implementing
// death tests. They are subject to change without notice. // death tests. They are subject to change without notice.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#if GTEST_HAS_DEATH_TEST && GTEST_OS_WINDOWS
#include <io.h>
#endif // GTEST_HAS_DEATH_TEST && GTEST_OS_WINDOWS
namespace testing { namespace testing {
namespace internal { namespace internal {
GTEST_DECLARE_string_(internal_run_death_test); GTEST_DECLARE_string_(internal_run_death_test);
// Names of the flags (needed for parsing Google Test flags). // Names of the flags (needed for parsing Google Test flags).
const char kDeathTestStyleFlag[] = "death_test_style"; const char kDeathTestStyleFlag[] = "death_test_style";
const char kDeathTestUseFork[] = "death_test_use_fork";
const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
// DeathTest is a class that hides much of the complexity of the // DeathTest is a class that hides much of the complexity of the
// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method // GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
// returns a concrete class that depends on the prevailing death test // returns a concrete class that depends on the prevailing death test
// style, as defined by the --gtest_death_test_style and/or // style, as defined by the --gtest_death_test_style and/or
// --gtest_internal_run_death_test flags. // --gtest_internal_run_death_test flags.
// In describing the results of death tests, these terms are used with // In describing the results of death tests, these terms are used with
// the corresponding definitions: // the corresponding definitions:
// //
skipping to change at line 123 skipping to change at line 128
// be combined. // be combined.
virtual bool Passed(bool exit_status_ok) = 0; virtual bool Passed(bool exit_status_ok) = 0;
// Signals that the death test did not die as expected. // Signals that the death test did not die as expected.
virtual void Abort(AbortReason reason) = 0; virtual void Abort(AbortReason reason) = 0;
// Returns a human-readable outcome message regarding the outcome of // Returns a human-readable outcome message regarding the outcome of
// the last death test. // the last death test.
static const char* LastMessage(); static const char* LastMessage();
static void set_last_death_test_message(const String& message);
private: private:
// A string containing a description of the outcome of the last death tes
t.
static String last_death_test_message_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest); GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
}; };
// Factory interface for death tests. May be mocked out for testing. // Factory interface for death tests. May be mocked out for testing.
class DeathTestFactory { class DeathTestFactory {
public: public:
virtual ~DeathTestFactory() { } virtual ~DeathTestFactory() { }
virtual bool Create(const char* statement, const RE* regex, virtual bool Create(const char* statement, const RE* regex,
const char* file, int line, DeathTest** test) = 0; const char* file, int line, DeathTest** test) = 0;
}; };
skipping to change at line 169 skipping to change at line 179
gtest_dt_ptr(gtest_dt); \ gtest_dt_ptr(gtest_dt); \
switch (gtest_dt->AssumeRole()) { \ switch (gtest_dt->AssumeRole()) { \
case ::testing::internal::DeathTest::OVERSEE_TEST: \ case ::testing::internal::DeathTest::OVERSEE_TEST: \
if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \ if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
} \ } \
break; \ break; \
case ::testing::internal::DeathTest::EXECUTE_TEST: { \ case ::testing::internal::DeathTest::EXECUTE_TEST: { \
::testing::internal::DeathTest::ReturnSentinel \ ::testing::internal::DeathTest::ReturnSentinel \
gtest_sentinel(gtest_dt); \ gtest_sentinel(gtest_dt); \
{ statement; } \ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE) ; \ gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE) ; \
break; \ break; \
} \ } \
} \ } \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
fail(::testing::internal::DeathTest::LastMessage()) fail(::testing::internal::DeathTest::LastMessage())
// The symbol "fail" here expands to something into which a message // The symbol "fail" here expands to something into which a message
// can be streamed. // can be streamed.
// A struct representing the parsed contents of the // A class representing the parsed contents of the
// --gtest_internal_run_death_test flag, as it existed when // --gtest_internal_run_death_test flag, as it existed when
// RUN_ALL_TESTS was called. // RUN_ALL_TESTS was called.
struct InternalRunDeathTestFlag { class InternalRunDeathTestFlag {
String file; public:
int line; InternalRunDeathTestFlag(const String& file,
int index; int line,
int status_fd; int index,
int status_fd)
: file_(file), line_(line), index_(index), status_fd_(status_fd) {}
~InternalRunDeathTestFlag() {
if (status_fd_ >= 0)
// Suppress MSVC complaints about POSIX functions.
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4996)
#endif // _MSC_VER
close(status_fd_);
#ifdef _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER
}
String file() const { return file_; }
int line() const { return line_; }
int index() const { return index_; }
int status_fd() const { return status_fd_; }
private:
String file_;
int line_;
int index_;
int status_fd_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
}; };
// Returns a newly created InternalRunDeathTestFlag object with fields // Returns a newly created InternalRunDeathTestFlag object with fields
// initialized from the GTEST_FLAG(internal_run_death_test) flag if // initialized from the GTEST_FLAG(internal_run_death_test) flag if
// the flag is specified; otherwise returns NULL. // the flag is specified; otherwise returns NULL.
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag(); InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
} // namespace internal } // namespace internal
 End of changes. 8 change blocks. 
8 lines changed or deleted 47 lines changed or added


 gtest-death-test.h   gtest-death-test.h 
skipping to change at line 52 skipping to change at line 52
namespace testing { namespace testing {
// This flag controls the style of death tests. Valid values are "threadsa fe", // This flag controls the style of death tests. Valid values are "threadsa fe",
// meaning that the death test child process will re-execute the test binar y // meaning that the death test child process will re-execute the test binar y
// from the start, running only a single death test, or "fast", // from the start, running only a single death test, or "fast",
// meaning that the child process will execute the test logic immediately // meaning that the child process will execute the test logic immediately
// after forking. // after forking.
GTEST_DECLARE_string_(death_test_style); GTEST_DECLARE_string_(death_test_style);
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
// The following macros are useful for writing death tests. // The following macros are useful for writing death tests.
// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is // Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
// executed: // executed:
// //
// 1. It generates a warning if there is more than one active // 1. It generates a warning if there is more than one active
// thread. This is because it's safe to fork() or clone() only // thread. This is because it's safe to fork() or clone() only
// when there is a single thread. // when there is a single thread.
// //
skipping to change at line 89 skipping to change at line 89
// } // }
// //
// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting") ; // ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting") ;
// //
// bool KilledBySIGHUP(int exit_code) { // bool KilledBySIGHUP(int exit_code) {
// return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP; // return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
// } // }
// //
// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!"); // ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
// //
// On the regular expressions used in death tests:
//
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
// which uses the POSIX extended regex syntax.
//
// On other platforms (e.g. Windows), we only support a simple regex
// syntax implemented as part of Google Test. This limited
// implementation should be enough most of the time when writing
// death tests; though it lacks many features you can find in PCRE
// or POSIX extended regex syntax. For example, we don't support
// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
// repetition count ("x{5,7}"), among others.
//
// Below is the syntax that we do support. We chose it to be a
// subset of both PCRE and POSIX extended regex, so it's easy to
// learn wherever you come from. In the following: 'A' denotes a
// literal character, period (.), or a single \\ escape sequence;
// 'x' and 'y' denote regular expressions; 'm' and 'n' are for
// natural numbers.
//
// c matches any literal character c
// \\d matches any decimal digit
// \\D matches any character that's not a decimal digit
// \\f matches \f
// \\n matches \n
// \\r matches \r
// \\s matches any ASCII whitespace, including \n
// \\S matches any character that's not a whitespace
// \\t matches \t
// \\v matches \v
// \\w matches any letter, _, or decimal digit
// \\W matches any character that \\w doesn't match
// \\c matches any literal character c, which must be a punctuation
// . matches any single character except \n
// A? matches 0 or 1 occurrences of A
// A* matches 0 or many occurrences of A
// A+ matches 1 or many occurrences of A
// ^ matches the beginning of a string (not that of each line)
// $ matches the end of a string (not that of each line)
// xy matches x followed by y
//
// If you accidentally use PCRE or POSIX extended regex features
// not implemented by us, you will get a run-time failure. In that
// case, please try to rewrite your regular expression within the
// above syntax.
//
// This implementation is *not* meant to be as highly tuned or robust
// as a compiled regex library, but should perform well enough for a
// death test, which already incurs significant overhead by launching
// a child process.
//
// Known caveats: // Known caveats:
// //
// A "threadsafe" style death test obtains the path to the test // A "threadsafe" style death test obtains the path to the test
// program from argv[0] and re-executes it in the sub-process. For // program from argv[0] and re-executes it in the sub-process. For
// simplicity, the current implementation doesn't search the PATH // simplicity, the current implementation doesn't search the PATH
// when launching the sub-process. This means that the user must // when launching the sub-process. This means that the user must
// invoke the test program via a path that contains at least one // invoke the test program via a path that contains at least one
// path separator (e.g. path/to/foo_test and // path separator (e.g. path/to/foo_test and
// /absolute/path/to/bar_test are fine, but foo_test is not). This // /absolute/path/to/bar_test are fine, but foo_test is not). This
// is rarely a problem as people usually don't put the test binary // is rarely a problem as people usually don't put the test binary
skipping to change at line 136 skipping to change at line 187
// Tests that an exit code describes a normal exit with a given exit code. // Tests that an exit code describes a normal exit with a given exit code.
class ExitedWithCode { class ExitedWithCode {
public: public:
explicit ExitedWithCode(int exit_code); explicit ExitedWithCode(int exit_code);
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
const int exit_code_; const int exit_code_;
}; };
#if !GTEST_OS_WINDOWS
// Tests that an exit code describes an exit due to termination by a // Tests that an exit code describes an exit due to termination by a
// given signal. // given signal.
class KilledBySignal { class KilledBySignal {
public: public:
explicit KilledBySignal(int signum); explicit KilledBySignal(int signum);
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
const int signum_; const int signum_;
}; };
#endif // !GTEST_OS_WINDOWS
// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode. // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
// The death testing framework causes this to have interesting semantics, // The death testing framework causes this to have interesting semantics,
// since the sideeffects of the call are only visible in opt mode, and not // since the sideeffects of the call are only visible in opt mode, and not
// in debug mode. // in debug mode.
// //
// In practice, this can be used to test functions that utilize the // In practice, this can be used to test functions that utilize the
// LOG(DFATAL) macro using the following style: // LOG(DFATAL) macro using the following style:
// //
// int DieInDebugOr12(int* sideeffect) { // int DieInDebugOr12(int* sideeffect) {
 End of changes. 4 change blocks. 
1 lines changed or deleted 54 lines changed or added


 gtest-filepath.h   gtest-filepath.h 
skipping to change at line 37 skipping to change at line 37
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Author: keith.ray@gmail.com (Keith Ray) // Author: keith.ray@gmail.com (Keith Ray)
// //
// Google Test filepath utilities // Google Test filepath utilities
// //
// This header file declares classes and functions used internally by // This header file declares classes and functions used internally by
// Google Test. They are subject to change without notice. // Google Test. They are subject to change without notice.
// //
// This file is #included in testing/base/internal/gtest-internal.h // This file is #included in <gtest/internal/gtest-internal.h>.
// Do not include this header file separately! // Do not include this header file separately!
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
namespace testing { namespace testing {
namespace internal { namespace internal {
skipping to change at line 96 skipping to change at line 96
// Given directory = "dir", base_name = "test", number = 0, // Given directory = "dir", base_name = "test", number = 0,
// extension = "xml", returns "dir/test.xml". If number is greater // extension = "xml", returns "dir/test.xml". If number is greater
// than zero (e.g., 12), returns "dir/test_12.xml". // than zero (e.g., 12), returns "dir/test_12.xml".
// On Windows platform, uses \ as the separator rather than /. // On Windows platform, uses \ as the separator rather than /.
static FilePath MakeFileName(const FilePath& directory, static FilePath MakeFileName(const FilePath& directory,
const FilePath& base_name, const FilePath& base_name,
int number, int number,
const char* extension); const char* extension);
// Given directory = "dir", relative_path = "test.xml",
// returns "dir/test.xml".
// On Windows, uses \ as the separator rather than /.
static FilePath ConcatPaths(const FilePath& directory,
const FilePath& relative_path);
// Returns a pathname for a file that does not currently exist. The pathn ame // Returns a pathname for a file that does not currently exist. The pathn ame
// will be directory/base_name.extension or // will be directory/base_name.extension or
// directory/base_name_<number>.extension if directory/base_name.extensio n // directory/base_name_<number>.extension if directory/base_name.extensio n
// already exists. The number will be incremented until a pathname is fou nd // already exists. The number will be incremented until a pathname is fou nd
// that does not already exist. // that does not already exist.
// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'. // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
// There could be a race condition if two or more processes are calling t his // There could be a race condition if two or more processes are calling t his
// function at the same time -- they could both pick the same filename. // function at the same time -- they could both pick the same filename.
static FilePath GenerateUniqueFileName(const FilePath& directory, static FilePath GenerateUniqueFileName(const FilePath& directory,
const FilePath& base_name, const FilePath& base_name,
skipping to change at line 167 skipping to change at line 173
// Returns true if FilePath ends with a path separator, which indicates t hat // Returns true if FilePath ends with a path separator, which indicates t hat
// it is intended to represent a directory. Returns false otherwise. // it is intended to represent a directory. Returns false otherwise.
// This does NOT check that a directory (or file) actually exists. // This does NOT check that a directory (or file) actually exists.
bool IsDirectory() const; bool IsDirectory() const;
// Returns true if pathname describes a root directory. (Windows has one // Returns true if pathname describes a root directory. (Windows has one
// root directory per disk drive.) // root directory per disk drive.)
bool IsRootDirectory() const; bool IsRootDirectory() const;
// Returns true if pathname describes an absolute path.
bool IsAbsolutePath() const;
private: private:
// Replaces multiple consecutive separators with a single separator. // Replaces multiple consecutive separators with a single separator.
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// redundancies that might be in a pathname involving "." or "..". // redundancies that might be in a pathname involving "." or "..".
// //
// A pathname with multiple consecutive separators may occur either throu gh // A pathname with multiple consecutive separators may occur either throu gh
// user error or as a result of some scripts or APIs that generate a path name // user error or as a result of some scripts or APIs that generate a path name
// with a trailing separator. On other platforms the same API or script // with a trailing separator. On other platforms the same API or script
// may NOT generate a pathname with a trailing "/". Then elsewhere that // may NOT generate a pathname with a trailing "/". Then elsewhere that
// pathname may have another "/" and pathname components added to it, // pathname may have another "/" and pathname components added to it,
 End of changes. 3 change blocks. 
1 lines changed or deleted 10 lines changed or added


 gtest-internal.h   gtest-internal.h 
skipping to change at line 42 skipping to change at line 42
// The Google C++ Testing Framework (Google Test) // The Google C++ Testing Framework (Google Test)
// //
// This header file declares functions and macros used internally by // This header file declares functions and macros used internally by
// Google Test. They are subject to change without notice. // Google Test. They are subject to change without notice.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#ifdef GTEST_OS_LINUX #if GTEST_OS_LINUX
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#endif // GTEST_OS_LINUX #endif // GTEST_OS_LINUX
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <iomanip> #include <iomanip>
#include <limits> #include <limits>
skipping to change at line 548 skipping to change at line 548
}; };
// This class provides implementation of TeastFactoryBase interface. // This class provides implementation of TeastFactoryBase interface.
// It is used in TEST and TEST_F macros. // It is used in TEST and TEST_F macros.
template <class TestClass> template <class TestClass>
class TestFactoryImpl : public TestFactoryBase { class TestFactoryImpl : public TestFactoryBase {
public: public:
virtual Test* CreateTest() { return new TestClass; } virtual Test* CreateTest() { return new TestClass; }
}; };
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// Predicate-formatters for implementing the HRESULT checking macros // Predicate-formatters for implementing the HRESULT checking macros
// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED} // {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
// We pass a long instead of HRESULT to avoid causing an // We pass a long instead of HRESULT to avoid causing an
// include dependency for the HRESULT type. // include dependency for the HRESULT type.
AssertionResult IsHRESULTSuccess(const char* expr, long hr); // NOLINT AssertionResult IsHRESULTSuccess(const char* expr, long hr); // NOLINT
AssertionResult IsHRESULTFailure(const char* expr, long hr); // NOLINT AssertionResult IsHRESULTFailure(const char* expr, long hr); // NOLINT
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
skipping to change at line 602 skipping to change at line 602
// The newly created TestInfo instance will assume // The newly created TestInfo instance will assume
// ownership of the factory object. // ownership of the factory object.
TestInfo* MakeAndRegisterTestInfo( TestInfo* MakeAndRegisterTestInfo(
const char* test_case_name, const char* name, const char* test_case_name, const char* name,
const char* test_case_comment, const char* comment, const char* test_case_comment, const char* comment,
TypeId fixture_class_id, TypeId fixture_class_id,
SetUpTestCaseFunc set_up_tc, SetUpTestCaseFunc set_up_tc,
TearDownTestCaseFunc tear_down_tc, TearDownTestCaseFunc tear_down_tc,
TestFactoryBase* factory); TestFactoryBase* factory);
#if defined(GTEST_HAS_TYPED_TEST) || defined(GTEST_HAS_TYPED_TEST_P) #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
// State of the definition of a type-parameterized test case. // State of the definition of a type-parameterized test case.
class TypedTestCasePState { class TypedTestCasePState {
public: public:
TypedTestCasePState() : registered_(false) {} TypedTestCasePState() : registered_(false) {}
// Adds the given test name to defined_test_names_ and return true // Adds the given test name to defined_test_names_ and return true
// if the test case hasn't been registered; otherwise aborts the // if the test case hasn't been registered; otherwise aborts the
// program. // program.
bool AddTestName(const char* file, int line, const char* case_name, bool AddTestName(const char* file, int line, const char* case_name,
const char* test_name) { const char* test_name) {
if (registered_) { if (registered_) {
fprintf(stderr, "%s Test %s must be defined before " fprintf(stderr, "%s Test %s must be defined before "
"REGISTER_TYPED_TEST_CASE_P(%s, ...).\n", "REGISTER_TYPED_TEST_CASE_P(%s, ...).\n",
FormatFileLocation(file, line).c_str(), test_name, case_name) ; FormatFileLocation(file, line).c_str(), test_name, case_name) ;
fflush(stderr);
abort(); abort();
} }
defined_test_names_.insert(test_name); defined_test_names_.insert(test_name);
return true; return true;
} }
// Verifies that registered_tests match the test names in // Verifies that registered_tests match the test names in
// defined_test_names_; returns registered_tests if successful, or // defined_test_names_; returns registered_tests if successful, or
// aborts the program otherwise. // aborts the program otherwise.
const char* VerifyRegisteredTestNames( const char* VerifyRegisteredTestNames(
skipping to change at line 750 skipping to change at line 751
// count against the number of frames to be included. // count against the number of frames to be included.
// //
// For example, if Foo() calls Bar(), which in turn calls // For example, if Foo() calls Bar(), which in turn calls
// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count) ; String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count) ;
// Returns the number of failed test parts in the given test result object. // Returns the number of failed test parts in the given test result object.
int GetFailedPartCount(const TestResult* result); int GetFailedPartCount(const TestResult* result);
// A helper for suppressing warnings on unreachable code in some macros.
bool AlwaysTrue();
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#define GTEST_MESSAGE_(message, result_type) \ #define GTEST_MESSAGE_(message, result_type) \
::testing::internal::AssertHelper(result_type, __FILE__, __LINE__, messag e) \ ::testing::internal::AssertHelper(result_type, __FILE__, __LINE__, messag e) \
= ::testing::Message() = ::testing::Message()
#define GTEST_FATAL_FAILURE_(message) \ #define GTEST_FATAL_FAILURE_(message) \
return GTEST_MESSAGE_(message, ::testing::TPRT_FATAL_FAILURE) return GTEST_MESSAGE_(message, ::testing::TPRT_FATAL_FAILURE)
#define GTEST_NONFATAL_FAILURE_(message) \ #define GTEST_NONFATAL_FAILURE_(message) \
GTEST_MESSAGE_(message, ::testing::TPRT_NONFATAL_FAILURE) GTEST_MESSAGE_(message, ::testing::TPRT_NONFATAL_FAILURE)
#define GTEST_SUCCESS_(message) \ #define GTEST_SUCCESS_(message) \
GTEST_MESSAGE_(message, ::testing::TPRT_SUCCESS) GTEST_MESSAGE_(message, ::testing::TPRT_SUCCESS)
// Suppresses MSVC warnings 4072 (unreachable code) for the code following
// statement if it returns or throws (or doesn't return or throw in some
// situations).
#define GTEST_HIDE_UNREACHABLE_CODE_(statement) \
if (::testing::internal::AlwaysTrue()) { statement; }
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \ #define GTEST_TEST_THROW_(statement, expected_exception, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
bool gtest_caught_expected = false; \ bool gtest_caught_expected = false; \
try { \ try { \
statement; \ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
} \ } \
catch (expected_exception const&) { \ catch (expected_exception const&) { \
gtest_caught_expected = true; \ gtest_caught_expected = true; \
} \ } \
catch (...) { \ catch (...) { \
gtest_msg = "Expected: " #statement " throws an exception of type " \ gtest_msg = "Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: it throws a different " \ #expected_exception ".\n Actual: it throws a different " \
"type."; \ "type."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \ } \
skipping to change at line 795 skipping to change at line 805
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(gtest_msg) fail(gtest_msg)
#define GTEST_TEST_NO_THROW_(statement, fail) \ #define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
try { \ try { \
statement; \ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
} \ } \
catch (...) { \ catch (...) { \
gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \ gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws."; \ " Actual: it throws."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
fail(gtest_msg) fail(gtest_msg)
#define GTEST_TEST_ANY_THROW_(statement, fail) \ #define GTEST_TEST_ANY_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
bool gtest_caught_any = false; \ bool gtest_caught_any = false; \
try { \ try { \
statement; \ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
} \ } \
catch (...) { \ catch (...) { \
gtest_caught_any = true; \ gtest_caught_any = true; \
} \ } \
if (!gtest_caught_any) { \ if (!gtest_caught_any) { \
gtest_msg = "Expected: " #statement " throws an exception.\n" \ gtest_msg = "Expected: " #statement " throws an exception.\n" \
" Actual: it doesn't."; \ " Actual: it doesn't."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
} \ } \
} else \ } else \
skipping to change at line 836 skipping to change at line 846
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (boolexpr) \ if (boolexpr) \
; \ ; \
else \ else \
fail("Value of: " booltext "\n Actual: " #actual "\nExpected: " #expec ted) fail("Value of: " booltext "\n Actual: " #actual "\nExpected: " #expec ted)
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_check er; \ ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_check er; \
{ statement; } \ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
gtest_msg = "Expected: " #statement " doesn't generate new fatal " \ gtest_msg = "Expected: " #statement " doesn't generate new fatal " \
"failures in the current thread.\n" \ "failures in the current thread.\n" \
" Actual: it does."; \ " Actual: it does."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
fail(gtest_msg) fail(gtest_msg)
 End of changes. 10 change blocks. 
7 lines changed or deleted 17 lines changed or added


 gtest-message.h   gtest-message.h 
skipping to change at line 105 skipping to change at line 105
Message(const Message& msg) : ss_(new internal::StrStream) { // NOLINT Message(const Message& msg) : ss_(new internal::StrStream) { // NOLINT
*ss_ << msg.GetString(); *ss_ << msg.GetString();
} }
// Constructs a Message from a C-string. // Constructs a Message from a C-string.
explicit Message(const char* str) : ss_(new internal::StrStream) { explicit Message(const char* str) : ss_(new internal::StrStream) {
*ss_ << str; *ss_ << str;
} }
~Message() { delete ss_; } ~Message() { delete ss_; }
#ifdef GTEST_OS_SYMBIAN #if GTEST_OS_SYMBIAN
// Streams a value (either a pointer or not) to this object. // Streams a value (either a pointer or not) to this object.
template <typename T> template <typename T>
inline Message& operator <<(const T& value) { inline Message& operator <<(const T& value) {
StreamHelper(typename internal::is_pointer<T>::type(), value); StreamHelper(typename internal::is_pointer<T>::type(), value);
return *this; return *this;
} }
#else #else
// Streams a non-pointer value to this object. // Streams a non-pointer value to this object.
template <typename T> template <typename T>
inline Message& operator <<(const T& val) { inline Message& operator <<(const T& val) {
skipping to change at line 190 skipping to change at line 190
// Gets the text streamed to this object so far as a String. // Gets the text streamed to this object so far as a String.
// Each '\0' character in the buffer is replaced with "\\0". // Each '\0' character in the buffer is replaced with "\\0".
// //
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
internal::String GetString() const { internal::String GetString() const {
return internal::StrStreamToString(ss_); return internal::StrStreamToString(ss_);
} }
private: private:
#ifdef GTEST_OS_SYMBIAN #if GTEST_OS_SYMBIAN
// These are needed as the Nokia Symbian Compiler cannot decide between // These are needed as the Nokia Symbian Compiler cannot decide between
// const T& and const T* in a function template. The Nokia compiler _can_ // const T& and const T* in a function template. The Nokia compiler _can_
// decide between class template specializations for T and T*, so a // decide between class template specializations for T and T*, so a
// tr1::type_traits-like is_pointer works, and we can overload on that. // tr1::type_traits-like is_pointer works, and we can overload on that.
template <typename T> template <typename T>
inline void StreamHelper(internal::true_type dummy, T* pointer) { inline void StreamHelper(internal::true_type dummy, T* pointer) {
if (pointer == NULL) { if (pointer == NULL) {
*ss_ << "(null)"; *ss_ << "(null)";
} else { } else {
::GTestStreamToHelper(ss_, pointer); ::GTestStreamToHelper(ss_, pointer);
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 gtest-param-test.h   gtest-param-test.h 
skipping to change at line 152 skipping to change at line 152
// In the future, we plan to publish the API for defining new parameter // In the future, we plan to publish the API for defining new parameter
// generators. But for now this interface remains part of the internal // generators. But for now this interface remains part of the internal
// implementation and is subject to change. // implementation and is subject to change.
#endif // 0 #endif // 0
#include <utility> #include <utility>
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-param-util.h> #include <gtest/internal/gtest-param-util.h>
#include <gtest/internal/gtest-param-util-generated.h> #include <gtest/internal/gtest-param-util-generated.h>
namespace testing { namespace testing {
// Functions producing parameter generators. // Functions producing parameter generators.
// //
// Google Test uses these generators to produce parameters for value- // Google Test uses these generators to produce parameters for value-
skipping to change at line 1186 skipping to change at line 1186
// virtual void SetUp() { // virtual void SetUp() {
// external_flag = GetParam(); // external_flag = GetParam();
// } // }
// } // }
// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool()); // INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
// //
inline internal::ParamGenerator<bool> Bool() { inline internal::ParamGenerator<bool> Bool() {
return Values(false, true); return Values(false, true);
} }
#ifdef GTEST_HAS_COMBINE #if GTEST_HAS_COMBINE
// Combine() allows the user to combine two or more sequences to produce // Combine() allows the user to combine two or more sequences to produce
// values of a Cartesian product of those sequences' elements. // values of a Cartesian product of those sequences' elements.
// //
// Synopsis: // Synopsis:
// Combine(gen1, gen2, ..., genN) // Combine(gen1, gen2, ..., genN)
// - returns a generator producing sequences with elements coming from // - returns a generator producing sequences with elements coming from
// the Cartesian product of elements from the sequences generated by // the Cartesian product of elements from the sequences generated by
// gen1, gen2, ..., genN. The sequence elements will have a type of // gen1, gen2, ..., genN. The sequence elements will have a type of
// tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types // tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
// of elements from sequences produces by gen1, gen2, ..., genN. // of elements from sequences produces by gen1, gen2, ..., genN.
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 gtest-param-util-generated.h   gtest-param-util-generated.h 
skipping to change at line 49 skipping to change at line 49
// googletestframework@googlegroups.com if you need more. // googletestframework@googlegroups.com if you need more.
// Please note that the number of arguments to Combine is limited // Please note that the number of arguments to Combine is limited
// by the maximum arity of the implementation of tr1::tuple which is // by the maximum arity of the implementation of tr1::tuple which is
// currently set at 10. // currently set at 10.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
#include <gtest/internal/gtest-param-util.h> #include <gtest/internal/gtest-param-util.h>
namespace testing { namespace testing {
namespace internal { namespace internal {
// Used in the Values() function to provide polymorphic capabilities. // Used in the Values() function to provide polymorphic capabilities.
template <typename T1> template <typename T1>
class ValueArray1 { class ValueArray1 {
public: public:
skipping to change at line 2662 skipping to change at line 2662
const T43 v43_; const T43 v43_;
const T44 v44_; const T44 v44_;
const T45 v45_; const T45 v45_;
const T46 v46_; const T46 v46_;
const T47 v47_; const T47 v47_;
const T48 v48_; const T48 v48_;
const T49 v49_; const T49 v49_;
const T50 v50_; const T50 v50_;
}; };
#ifdef GTEST_HAS_COMBINE #if GTEST_HAS_COMBINE
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// //
// Generates values from the Cartesian product of values produced // Generates values from the Cartesian product of values produced
// by the argument generators. // by the argument generators.
// //
template <typename T1, typename T2> template <typename T1, typename T2>
class CartesianProductGenerator2 class CartesianProductGenerator2
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2> > { : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2> > {
public: public:
typedef ::std::tr1::tuple<T1, T2> ParamType; typedef ::std::tr1::tuple<T1, T2> ParamType;
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 gtest-param-util.h   gtest-param-util.h 
skipping to change at line 43 skipping to change at line 43
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
#include <iterator> #include <iterator>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
#if GTEST_HAS_RTTI #if GTEST_HAS_RTTI
#include <typeinfo> #include <typeinfo>
#endif // GTEST_HAS_RTTI #endif // GTEST_HAS_RTTI
#include <gtest/internal/gtest-linked_ptr.h> #include <gtest/internal/gtest-linked_ptr.h>
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
namespace testing { namespace testing {
namespace internal { namespace internal {
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gtest-port.h   gtest-port.h 
skipping to change at line 66 skipping to change at line 66
// std::string does/doesn't work (Google Test can // std::string does/doesn't work (Google Test can
// be used where std::string is unavailable). // be used where std::string is unavailable).
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that // GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
// std::wstring does/doesn't work (Google Test can // std::wstring does/doesn't work (Google Test can
// be used where std::wstring is unavailable). // be used where std::wstring is unavailable).
// GTEST_HAS_TR1_TUPLE 1 - Define it to 1/0 to indicate tr1::tuple // GTEST_HAS_TR1_TUPLE 1 - Define it to 1/0 to indicate tr1::tuple
// is/isn't available. // is/isn't available.
// This header defines the following utilities: // This header defines the following utilities:
// //
// Macros indicating the name of the Google C++ Testing Framework project: // Macros indicating the current platform (defined to 1 if compiled on
// GTEST_NAME - a string literal of the project name. // the given platform; otherwise undefined):
// GTEST_FLAG_PREFIX - a string literal of the prefix all Google // GTEST_OS_CYGWIN - Cygwin
// Test flag names share. // GTEST_OS_LINUX - Linux
// GTEST_FLAG_PREFIX_UPPER - a string literal of the prefix all Google // GTEST_OS_MAC - Mac OS X
// Test flag names share, in upper case. // GTEST_OS_SOLARIS - Sun Solaris
// // GTEST_OS_SYMBIAN - Symbian
// Macros indicating the current platform: // GTEST_OS_WINDOWS - Windows
// GTEST_OS_CYGWIN - defined iff compiled on Cygwin. // GTEST_OS_ZOS - z/OS
// GTEST_OS_LINUX - defined iff compiled on Linux.
// GTEST_OS_MAC - defined iff compiled on Mac OS X.
// GTEST_OS_SOLARIS - defined iff compiled on Sun Solaris.
// GTEST_OS_SYMBIAN - defined iff compiled for Symbian.
// GTEST_OS_WINDOWS - defined iff compiled on Windows.
// GTEST_OS_ZOS - defined iff compiled on IBM z/OS.
// //
// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the // Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
// most stable support. Since core members of the Google Test project // most stable support. Since core members of the Google Test project
// don't have access to other platforms, support for them may be less // don't have access to other platforms, support for them may be less
// stable. If you notice any problems on your platform, please notify // stable. If you notice any problems on your platform, please notify
// googletestframework@googlegroups.com (patches for fixing them are // googletestframework@googlegroups.com (patches for fixing them are
// even more welcome!). // even more welcome!).
// //
// Note that it is possible that none of the GTEST_OS_ macros are defined. // Note that it is possible that none of the GTEST_OS_* macros are defined.
// //
// Macros indicating available Google Test features: // Macros indicating available Google Test features (defined to 1 if
// GTEST_HAS_COMBINE - defined iff Combine construct is supported // the corresponding feature is supported; otherwise undefined):
// in value-parameterized tests. // GTEST_HAS_COMBINE - the Combine() function (for value-parameteriz
// GTEST_HAS_DEATH_TEST - defined iff death tests are supported. ed
// GTEST_HAS_PARAM_TEST - defined iff value-parameterized tests are // tests)
// supported. // GTEST_HAS_DEATH_TEST - death tests
// GTEST_HAS_TYPED_TEST - defined iff typed tests are supported. // GTEST_HAS_PARAM_TEST - value-parameterized tests
// GTEST_HAS_TYPED_TEST_P - defined iff type-parameterized tests are // GTEST_HAS_TYPED_TEST - typed tests
// supported. // GTEST_HAS_TYPED_TEST_P - type-parameterized tests
// GTEST_USES_POSIX_RE - enhanced POSIX regex is used.
// GTEST_USES_SIMPLE_RE - our own simple regex is used;
// the above two are mutually exclusive.
// //
// Macros for basic C++ coding: // Macros for basic C++ coding:
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning. // GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances don't have to // GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances don't have to
// be used. // be used.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=. // GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be u sed. // GTEST_MUST_USE_RESULT_ - declares that a function's result must be u sed.
// //
// Synchronization: // Synchronization:
// Mutex, MutexLock, ThreadLocal, GetThreadCount() // Mutex, MutexLock, ThreadLocal, GetThreadCount()
skipping to change at line 158 skipping to change at line 154
// Environment variable utilities: // Environment variable utilities:
// GetEnv() - gets the value of an environment variable. // GetEnv() - gets the value of an environment variable.
// BoolFromGTestEnv() - parses a bool environment variable. // BoolFromGTestEnv() - parses a bool environment variable.
// Int32FromGTestEnv() - parses an Int32 environment variable. // Int32FromGTestEnv() - parses an Int32 environment variable.
// StringFromGTestEnv() - parses a string environment variable. // StringFromGTestEnv() - parses a string environment variable.
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <iostream> // Used for GTEST_CHECK_ #include <iostream> // Used for GTEST_CHECK_
#define GTEST_NAME "Google Test" #define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
#define GTEST_FLAG_PREFIX "gtest_" #define GTEST_FLAG_PREFIX_ "gtest_"
#define GTEST_FLAG_PREFIX_UPPER "GTEST_" #define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
#define GTEST_NAME_ "Google Test"
#define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/"
// Determines the version of gcc that is used to compile this. // Determines the version of gcc that is used to compile this.
#ifdef __GNUC__ #ifdef __GNUC__
// 40302 means version 4.3.2. // 40302 means version 4.3.2.
#define GTEST_GCC_VER_ \ #define GTEST_GCC_VER_ \
(__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__) (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
#endif // __GNUC__ #endif // __GNUC__
// Determines the platform on which Google Test is compiled. // Determines the platform on which Google Test is compiled.
#ifdef __CYGWIN__ #ifdef __CYGWIN__
#define GTEST_OS_CYGWIN #define GTEST_OS_CYGWIN 1
#elif __SYMBIAN32__ #elif __SYMBIAN32__
#define GTEST_OS_SYMBIAN #define GTEST_OS_SYMBIAN 1
#elif defined _MSC_VER #elif defined _MSC_VER
// TODO(kenton@google.com): GTEST_OS_WINDOWS is currently used to mean // TODO(kenton@google.com): GTEST_OS_WINDOWS is currently used to mean
// both "The OS is Windows" and "The compiler is MSVC". These // both "The OS is Windows" and "The compiler is MSVC". These
// meanings really should be separated in order to better support // meanings really should be separated in order to better support
// Windows compilers other than MSVC. // Windows compilers other than MSVC.
#define GTEST_OS_WINDOWS #define GTEST_OS_WINDOWS 1
#elif defined __APPLE__ #elif defined __APPLE__
#define GTEST_OS_MAC #define GTEST_OS_MAC 1
#elif defined __linux__ #elif defined __linux__
#define GTEST_OS_LINUX #define GTEST_OS_LINUX 1
#elif defined __MVS__ #elif defined __MVS__
#define GTEST_OS_ZOS #define GTEST_OS_ZOS 1
#elif defined(__sun) && defined(__SVR4) #elif defined(__sun) && defined(__SVR4)
#define GTEST_OS_SOLARIS #define GTEST_OS_SOLARIS 1
#endif // _MSC_VER #endif // _MSC_VER
// Determines whether ::std::string and ::string are available. #if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
#ifndef GTEST_HAS_STD_STRING // On some platforms, <regex.h> needs someone to define size_t, and
// The user didn't tell us whether ::std::string is available, so we // won't compile otherwise. We can #include it here as we already
// need to figure it out. // included <stdlib.h>, which is guaranteed to define size_t through
// <stddef.h>.
#include <regex.h> // NOLINT
#define GTEST_USES_POSIX_RE 1
#ifdef GTEST_OS_WINDOWS #else
// <regex.h> may not be available on this platform. Use our own
// simple regex implementation instead.
#define GTEST_USES_SIMPLE_RE 1
#endif // GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
// Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0
// otherwise.
#ifdef _MSC_VER // Compiled by MSVC?
// Assumes that exceptions are enabled by default. // Assumes that exceptions are enabled by default.
#ifndef _HAS_EXCEPTIONS #ifndef _HAS_EXCEPTIONS // MSVC uses this macro to enable exceptions.
#define _HAS_EXCEPTIONS 1 #define _HAS_EXCEPTIONS 1
#endif // _HAS_EXCEPTIONS #endif // _HAS_EXCEPTIONS
// GTEST_HAS_EXCEPTIONS is non-zero iff exceptions are enabled. It is
// always defined, while _HAS_EXCEPTIONS is defined only on Windows.
#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS #define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
// On Windows, we can use ::std::string if the compiler version is VS #else // The compiler is not MSVC.
// 2005 or above, or if exceptions are enabled. // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled. For
#define GTEST_HAS_STD_STRING ((_MSC_VER >= 1400) || GTEST_HAS_EXCEPTIONS) // other compilers, we assume exceptions are disabled to be
#else // We are on Linux or Mac OS. // conservative.
#if defined(__GNUC__) && __EXCEPTIONS
#define GTEST_HAS_EXCEPTIONS 1
#else
#define GTEST_HAS_EXCEPTIONS 0 #define GTEST_HAS_EXCEPTIONS 0
#define GTEST_HAS_STD_STRING 1 #endif // defined(__GNUC__) && __EXCEPTIONS
#endif // GTEST_OS_WINDOWS #endif // _MSC_VER
// Determines whether ::std::string and ::string are available.
#ifndef GTEST_HAS_STD_STRING
// The user didn't tell us whether ::std::string is available, so we
// need to figure it out. The only environment that we know
// ::std::string is not available is MSVC 7.1 or lower with exceptions
// disabled.
#if defined(_MSC_VER) && (_MSC_VER < 1400) && !GTEST_HAS_EXCEPTIONS
#define GTEST_HAS_STD_STRING 0
#else
#define GTEST_HAS_STD_STRING 1
#endif
#endif // GTEST_HAS_STD_STRING #endif // GTEST_HAS_STD_STRING
#ifndef GTEST_HAS_GLOBAL_STRING #ifndef GTEST_HAS_GLOBAL_STRING
// The user didn't tell us whether ::string is available, so we need // The user didn't tell us whether ::string is available, so we need
// to figure it out. // to figure it out.
#define GTEST_HAS_GLOBAL_STRING 0 #define GTEST_HAS_GLOBAL_STRING 0
#endif // GTEST_HAS_GLOBAL_STRING #endif // GTEST_HAS_GLOBAL_STRING
#ifndef GTEST_HAS_STD_WSTRING #ifndef GTEST_HAS_STD_WSTRING
// The user didn't tell us whether ::std::wstring is available, so we need // The user didn't tell us whether ::std::wstring is available, so we need
// to figure it out. // to figure it out.
// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring // TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
// is available. // is available.
#if defined(GTEST_OS_CYGWIN) || defined(GTEST_OS_SOLARIS) #if GTEST_OS_CYGWIN || GTEST_OS_SOLARIS
// At least some versions of cygwin don't support ::std::wstring. // Cygwin 1.5 and below doesn't support ::std::wstring.
// Cygwin 1.7 might add wstring support; this should be updated when clear.
// Solaris' libc++ doesn't support it either. // Solaris' libc++ doesn't support it either.
#define GTEST_HAS_STD_WSTRING 0 #define GTEST_HAS_STD_WSTRING 0
#else #else
#define GTEST_HAS_STD_WSTRING GTEST_HAS_STD_STRING #define GTEST_HAS_STD_WSTRING GTEST_HAS_STD_STRING
#endif // defined(GTEST_OS_CYGWIN) || defined(GTEST_OS_SOLARIS) #endif // GTEST_OS_CYGWIN || GTEST_OS_SOLARIS
#endif // GTEST_HAS_STD_WSTRING #endif // GTEST_HAS_STD_WSTRING
#ifndef GTEST_HAS_GLOBAL_WSTRING #ifndef GTEST_HAS_GLOBAL_WSTRING
// The user didn't tell us whether ::wstring is available, so we need // The user didn't tell us whether ::wstring is available, so we need
// to figure it out. // to figure it out.
#define GTEST_HAS_GLOBAL_WSTRING GTEST_HAS_GLOBAL_STRING #define GTEST_HAS_GLOBAL_WSTRING \
(GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
#endif // GTEST_HAS_GLOBAL_WSTRING #endif // GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING || \ #if GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING || \
GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
#include <string> // NOLINT #include <string> // NOLINT
#endif // GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING || #endif // GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING ||
// GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_STRING #if GTEST_HAS_STD_STRING
#include <sstream> // NOLINT #include <sstream> // NOLINT
skipping to change at line 295 skipping to change at line 322
// Unknown compiler - assume RTTI is enabled. // Unknown compiler - assume RTTI is enabled.
#define GTEST_HAS_RTTI 1 #define GTEST_HAS_RTTI 1
#endif // _MSC_VER #endif // _MSC_VER
#endif // GTEST_HAS_RTTI #endif // GTEST_HAS_RTTI
// Determines whether <pthread.h> is available. // Determines whether <pthread.h> is available.
#ifndef GTEST_HAS_PTHREAD #ifndef GTEST_HAS_PTHREAD
// The user didn't tell us, so we need to figure it out. // The user didn't tell us, so we need to figure it out.
#define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC)
#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC)
#define GTEST_HAS_PTHREAD 1
#else
#define GTEST_HAS_PTHREAD 0
#endif // GTEST_OS_LINUX || GTEST_OS_MAC
#endif // GTEST_HAS_PTHREAD #endif // GTEST_HAS_PTHREAD
// Determines whether tr1/tuple is available. If you have tr1/tuple // Determines whether tr1/tuple is available. If you have tr1/tuple
// on your platform, define GTEST_HAS_TR1_TUPLE=1 for both the Google // on your platform, define GTEST_HAS_TR1_TUPLE=1 for both the Google
// Test project and your tests. If you would like Google Test to detect // Test project and your tests. If you would like Google Test to detect
// tr1/tuple on your platform automatically, please open an issue // tr1/tuple on your platform automatically, please open an issue
// ticket at http://code.google.com/p/googletest. // ticket at http://code.google.com/p/googletest.
#ifndef GTEST_HAS_TR1_TUPLE #ifndef GTEST_HAS_TR1_TUPLE
// The user didn't tell us, so we need to figure it out. // The user didn't tell us, so we need to figure it out.
skipping to change at line 342 skipping to change at line 363
#endif // __GNUC__ #endif // __GNUC__
#endif // GTEST_HAS_TR1_TUPLE #endif // GTEST_HAS_TR1_TUPLE
// Determines whether clone(2) is supported. // Determines whether clone(2) is supported.
// Usually it will only be available on Linux, excluding // Usually it will only be available on Linux, excluding
// Linux on the Itanium architecture. // Linux on the Itanium architecture.
// Also see http://linux.die.net/man/2/clone. // Also see http://linux.die.net/man/2/clone.
#ifndef GTEST_HAS_CLONE #ifndef GTEST_HAS_CLONE
// The user didn't tell us, so we need to figure it out. // The user didn't tell us, so we need to figure it out.
#if defined(GTEST_OS_LINUX) && !defined(__ia64__) #if GTEST_OS_LINUX && !defined(__ia64__)
#define GTEST_HAS_CLONE 1 #define GTEST_HAS_CLONE 1
#else #else
#define GTEST_HAS_CLONE 0 #define GTEST_HAS_CLONE 0
#endif // defined(GTEST_OS_LINUX) && !defined(__ia64__) #endif // GTEST_OS_LINUX && !defined(__ia64__)
#endif // GTEST_HAS_CLONE #endif // GTEST_HAS_CLONE
// Determines whether to support death tests. // Determines whether to support death tests.
#if GTEST_HAS_STD_STRING && GTEST_HAS_CLONE // Google Test does not support death tests for VC 7.1 and earlier for
#define GTEST_HAS_DEATH_TEST // these reasons:
// On some platforms, <regex.h> needs someone to define size_t, and // 1. std::vector does not build in VC 7.1 when exceptions are disabled.
// won't compile otherwise. We can #include it here as we already // 2. std::string does not build in VC 7.1 when exceptions are disabled
// included <stdlib.h>, which is guaranteed to define size_t through // (this is covered by GTEST_HAS_STD_STRING guard).
// <stddef.h>. // 3. abort() in a VC 7.1 application compiled as GUI in debug config
#include <regex.h> // pops up a dialog window that cannot be suppressed programmatically.
#if GTEST_HAS_STD_STRING && (GTEST_OS_LINUX || \
GTEST_OS_MAC || \
GTEST_OS_CYGWIN || \
(GTEST_OS_WINDOWS && _MSC_VER >= 1400))
#define GTEST_HAS_DEATH_TEST 1
#include <vector> #include <vector>
#include <fcntl.h> #endif
#include <sys/mman.h>
#endif // GTEST_HAS_STD_STRING && GTEST_HAS_CLONE
// Determines whether to support value-parameterized tests. // Determines whether to support value-parameterized tests.
#if defined(__GNUC__) || (_MSC_VER >= 1400) #if defined(__GNUC__) || (_MSC_VER >= 1400)
// TODO(vladl@google.com): get the implementation rid of vector and list // TODO(vladl@google.com): get the implementation rid of vector and list
// to compile on MSVC 7.1. // to compile on MSVC 7.1.
#define GTEST_HAS_PARAM_TEST #define GTEST_HAS_PARAM_TEST 1
#endif // defined(__GNUC__) || (_MSC_VER >= 1400) #endif // defined(__GNUC__) || (_MSC_VER >= 1400)
// Determines whether to support type-driven tests. // Determines whether to support type-driven tests.
// Typed tests need <typeinfo> and variadic macros, which gcc and VC // Typed tests need <typeinfo> and variadic macros, which gcc and VC
// 8.0+ support. // 8.0+ support.
#if defined(__GNUC__) || (_MSC_VER >= 1400) #if defined(__GNUC__) || (_MSC_VER >= 1400)
#define GTEST_HAS_TYPED_TEST #define GTEST_HAS_TYPED_TEST 1
#define GTEST_HAS_TYPED_TEST_P #define GTEST_HAS_TYPED_TEST_P 1
#endif // defined(__GNUC__) || (_MSC_VER >= 1400) #endif // defined(__GNUC__) || (_MSC_VER >= 1400)
// Determines whether to support Combine(). This only makes sense when // Determines whether to support Combine(). This only makes sense when
// value-parameterized tests are enabled. // value-parameterized tests are enabled.
#if defined(GTEST_HAS_PARAM_TEST) && GTEST_HAS_TR1_TUPLE #if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE
#define GTEST_HAS_COMBINE #define GTEST_HAS_COMBINE 1
#endif // defined(GTEST_HAS_PARAM_TEST) && GTEST_HAS_TR1_TUPLE #endif // GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE
// Determines whether the system compiler uses UTF-16 for encoding wide str ings. // Determines whether the system compiler uses UTF-16 for encoding wide str ings.
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_CYGWIN) || \ #define GTEST_WIDE_STRING_USES_UTF16_ \
defined(GTEST_OS_SYMBIAN) (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN)
#define GTEST_WIDE_STRING_USES_UTF16_ 1
#endif
// Defines some utility macros. // Defines some utility macros.
// The GNU compiler emits a warning if nested "if" statements are followed by // The GNU compiler emits a warning if nested "if" statements are followed by
// an "else" statement and braces are not used to explicitly disambiguate t he // an "else" statement and braces are not used to explicitly disambiguate t he
// "else" binding. This leads to problems with code like: // "else" binding. This leads to problems with code like:
// //
// if (gate) // if (gate)
// ASSERT_*(condition) << "Some message"; // ASSERT_*(condition) << "Some message";
// //
skipping to change at line 491 skipping to change at line 513
} }
ptr_ = p; ptr_ = p;
} }
} }
private: private:
T* ptr_; T* ptr_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr); GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
}; };
#ifdef GTEST_HAS_DEATH_TEST
// Defines RE. // Defines RE.
// A simple C++ wrapper for <regex.h>. It uses the POSIX Enxtended // A simple C++ wrapper for <regex.h>. It uses the POSIX Enxtended
// Regular Expression syntax. // Regular Expression syntax.
class RE { class RE {
public: public:
// Constructs an RE from a string. // Constructs an RE from a string.
#if GTEST_HAS_STD_STRING #if GTEST_HAS_STD_STRING
RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
#endif // GTEST_HAS_STD_STRING #endif // GTEST_HAS_STD_STRING
skipping to change at line 550 skipping to change at line 570
static bool PartialMatch(const char* str, const RE& re); static bool PartialMatch(const char* str, const RE& re);
private: private:
void Init(const char* regex); void Init(const char* regex);
// We use a const char* instead of a string, as Google Test may be used // We use a const char* instead of a string, as Google Test may be used
// where string is not available. We also do not use Google Test's own // where string is not available. We also do not use Google Test's own
// String type here, in order to simplify dependencies between the // String type here, in order to simplify dependencies between the
// files. // files.
const char* pattern_; const char* pattern_;
bool is_valid_;
#if GTEST_USES_POSIX_RE
regex_t full_regex_; // For FullMatch(). regex_t full_regex_; // For FullMatch().
regex_t partial_regex_; // For PartialMatch(). regex_t partial_regex_; // For PartialMatch().
bool is_valid_; #else // GTEST_USES_SIMPLE_RE
}; const char* full_pattern_; // For FullMatch();
#endif
#endif // GTEST_HAS_DEATH_TEST GTEST_DISALLOW_COPY_AND_ASSIGN_(RE);
};
// Defines logging utilities: // Defines logging utilities:
// GTEST_LOG_() - logs messages at the specified severity level. // GTEST_LOG_() - logs messages at the specified severity level.
// LogToStderr() - directs all log messages to stderr. // LogToStderr() - directs all log messages to stderr.
// FlushInfoLog() - flushes informational log messages. // FlushInfoLog() - flushes informational log messages.
enum GTestLogSeverity { enum GTestLogSeverity {
GTEST_INFO, GTEST_INFO,
GTEST_WARNING, GTEST_WARNING,
GTEST_ERROR, GTEST_ERROR,
skipping to change at line 584 skipping to change at line 608
::testing::internal::GTEST_##severity, __FILE__, __LINE__, \ ::testing::internal::GTEST_##severity, __FILE__, __LINE__, \
(::testing::Message() << (msg)).GetString().c_str()) (::testing::Message() << (msg)).GetString().c_str())
inline void LogToStderr() {} inline void LogToStderr() {}
inline void FlushInfoLog() { fflush(NULL); } inline void FlushInfoLog() { fflush(NULL); }
// Defines the stderr capturer: // Defines the stderr capturer:
// CaptureStderr - starts capturing stderr. // CaptureStderr - starts capturing stderr.
// GetCapturedStderr - stops capturing stderr and returns the captured st ring. // GetCapturedStderr - stops capturing stderr and returns the captured st ring.
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_STD_STRING
void CaptureStderr();
::std::string GetCapturedStderr();
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_DEATH_TEST
// A copy of all command line arguments. Set by InitGoogleTest(). // A copy of all command line arguments. Set by InitGoogleTest().
extern ::std::vector<String> g_argvs; extern ::std::vector<String> g_argvs;
void CaptureStderr();
// GTEST_HAS_DEATH_TEST implies we have ::std::string. // GTEST_HAS_DEATH_TEST implies we have ::std::string.
::std::string GetCapturedStderr();
const ::std::vector<String>& GetArgvs(); const ::std::vector<String>& GetArgvs();
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
// Defines synchronization primitives. // Defines synchronization primitives.
// A dummy implementation of synchronization primitives (mutex, lock, // A dummy implementation of synchronization primitives (mutex, lock,
// and thread-local variable). Necessary for compiling Google Test where // and thread-local variable). Necessary for compiling Google Test where
// mutex is not supported - using Google Test in multiple threads is not // mutex is not supported - using Google Test in multiple threads is not
// supported on such platforms. // supported on such platforms.
skipping to change at line 675 skipping to change at line 702
typedef bool_constant<false> false_type; typedef bool_constant<false> false_type;
typedef bool_constant<true> true_type; typedef bool_constant<true> true_type;
template <typename T> template <typename T>
struct is_pointer : public false_type {}; struct is_pointer : public false_type {};
template <typename T> template <typename T>
struct is_pointer<T*> : public true_type {}; struct is_pointer<T*> : public true_type {};
#if GTEST_OS_WINDOWS
#define GTEST_PATH_SEP_ "\\"
#else
#define GTEST_PATH_SEP_ "/"
#endif // GTEST_OS_WINDOWS
// Defines BiggestInt as the biggest signed integer type the compiler // Defines BiggestInt as the biggest signed integer type the compiler
// supports. // supports.
#if GTEST_OS_WINDOWS
#ifdef GTEST_OS_WINDOWS
typedef __int64 BiggestInt; typedef __int64 BiggestInt;
#else #else
typedef long long BiggestInt; // NOLINT typedef long long BiggestInt; // NOLINT
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
// The maximum number a BiggestInt can represent. This definition // The maximum number a BiggestInt can represent. This definition
// works no matter BiggestInt is represented in one's complement or // works no matter BiggestInt is represented in one's complement or
// two's complement. // two's complement.
// //
// We cannot rely on numeric_limits in STL, as __int64 and long long // We cannot rely on numeric_limits in STL, as __int64 and long long
skipping to change at line 736 skipping to change at line 768
// As base/basictypes.h doesn't compile on Windows, we cannot use // As base/basictypes.h doesn't compile on Windows, we cannot use
// uint32, uint64, and etc here. // uint32, uint64, and etc here.
typedef int Int; typedef int Int;
typedef unsigned int UInt; typedef unsigned int UInt;
}; };
// The specialization for size 8. // The specialization for size 8.
template <> template <>
class TypeWithSize<8> { class TypeWithSize<8> {
public: public:
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
typedef __int64 Int; typedef __int64 Int;
typedef unsigned __int64 UInt; typedef unsigned __int64 UInt;
#else #else
typedef long long Int; // NOLINT typedef long long Int; // NOLINT
typedef unsigned long long UInt; // NOLINT typedef unsigned long long UInt; // NOLINT
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
}; };
// Integer types of known sizes. // Integer types of known sizes.
typedef TypeWithSize<4>::Int Int32; typedef TypeWithSize<4>::Int Int32;
skipping to change at line 759 skipping to change at line 791
typedef TypeWithSize<8>::UInt UInt64; typedef TypeWithSize<8>::UInt UInt64;
typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseco nds. typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseco nds.
// Utilities for command line flags and environment variables. // Utilities for command line flags and environment variables.
// A wrapper for getenv() that works on Linux, Windows, and Mac OS. // A wrapper for getenv() that works on Linux, Windows, and Mac OS.
inline const char* GetEnv(const char* name) { inline const char* GetEnv(const char* name) {
#ifdef _WIN32_WCE // We are on Windows CE. #ifdef _WIN32_WCE // We are on Windows CE.
// CE has no environment variables. // CE has no environment variables.
return NULL; return NULL;
#elif defined(GTEST_OS_WINDOWS) // We are on Windows proper. #elif GTEST_OS_WINDOWS // We are on Windows proper.
// MSVC 8 deprecates getenv(), so we want to suppress warning 4996 // MSVC 8 deprecates getenv(), so we want to suppress warning 4996
// (deprecated function) there. // (deprecated function) there.
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996. #pragma warning(disable:4996) // Temporarily disables warning 4996.
return getenv(name); return getenv(name);
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#else // We are on Linux or Mac OS. #else // We are on Linux or Mac OS.
return getenv(name); return getenv(name);
#endif #endif
} }
 End of changes. 42 change blocks. 
94 lines changed or deleted 127 lines changed or added


 gtest-string.h   gtest-string.h 
skipping to change at line 38 skipping to change at line 38
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) // Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
// //
// The Google C++ Testing Framework (Google Test) // The Google C++ Testing Framework (Google Test)
// //
// This header file declares the String class and functions used internally by // This header file declares the String class and functions used internally by
// Google Test. They are subject to change without notice. They should not used // Google Test. They are subject to change without notice. They should not used
// by code external to Google Test. // by code external to Google Test.
// //
// This header file is #included by testing/base/internal/gtest-internal.h. // This header file is #included by <gtest/internal/gtest-internal.h>.
// It should not be #included by other files. // It should not be #included by other files.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
#include <string.h> #include <string.h>
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#if GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING #if GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING
#include <string> #include <string>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gtest-type-util.h   gtest-type-util.h 
skipping to change at line 48 skipping to change at line 48
// type-parameterized tests in one type-parameterized test case. // type-parameterized tests in one type-parameterized test case.
// Please contact googletestframework@googlegroups.com if you need // Please contact googletestframework@googlegroups.com if you need
// more. // more.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
#if defined(GTEST_HAS_TYPED_TEST) || defined(GTEST_HAS_TYPED_TEST_P) #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
#ifdef __GNUC__ #ifdef __GNUC__
#include <cxxabi.h> #include <cxxabi.h>
#endif // __GNUC__ #endif // __GNUC__
#include <typeinfo> #include <typeinfo>
namespace testing { namespace testing {
namespace internal { namespace internal {
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 gtest-typed-test.h   gtest-typed-test.h 
skipping to change at line 154 skipping to change at line 154
// directly without Types<...>: // directly without Types<...>:
// INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int); // INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);
#endif // 0 #endif // 0
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#include <gtest/internal/gtest-type-util.h> #include <gtest/internal/gtest-type-util.h>
// Implements typed tests. // Implements typed tests.
#ifdef GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// //
// Expands to the name of the typedef for the type parameters of the // Expands to the name of the typedef for the type parameters of the
// given test case. // given test case.
#define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName## _ #define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName## _
#define TYPED_TEST_CASE(CaseName, Types) \ #define TYPED_TEST_CASE(CaseName, Types) \
typedef ::testing::internal::TypeList<Types>::type \ typedef ::testing::internal::TypeList<Types>::type \
GTEST_TYPE_PARAMS_(CaseName) GTEST_TYPE_PARAMS_(CaseName)
skipping to change at line 189 skipping to change at line 189
GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \ GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
GTEST_TYPE_PARAMS_(CaseName)>::Register(\ GTEST_TYPE_PARAMS_(CaseName)>::Register(\
"", #CaseName, #TestName, 0); \ "", #CaseName, #TestName, 0); \
template <typename gtest_TypeParam_> \ template <typename gtest_TypeParam_> \
void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBo dy() void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBo dy()
#endif // GTEST_HAS_TYPED_TEST #endif // GTEST_HAS_TYPED_TEST
// Implements type-parameterized tests. // Implements type-parameterized tests.
#ifdef GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// //
// Expands to the namespace name that the type-parameterized tests for // Expands to the namespace name that the type-parameterized tests for
// the given type-parameterized test case are defined in. The exact // the given type-parameterized test case are defined in. The exact
// name of the namespace is subject to change without notice. // name of the namespace is subject to change without notice.
#define GTEST_CASE_NAMESPACE_(TestCaseName) \ #define GTEST_CASE_NAMESPACE_(TestCaseName) \
gtest_case_##TestCaseName##_ gtest_case_##TestCaseName##_
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 gtest.h   gtest.h 
skipping to change at line 96 skipping to change at line 96
// //
// If the user's ::std::string and ::string are the same class due to // If the user's ::std::string and ::string are the same class due to
// aliasing, he should define GTEST_HAS_STD_STRING to 1 and // aliasing, he should define GTEST_HAS_STD_STRING to 1 and
// GTEST_HAS_GLOBAL_STRING to 0. // GTEST_HAS_GLOBAL_STRING to 0.
// //
// If the user doesn't define GTEST_HAS_STD_STRING and/or // If the user doesn't define GTEST_HAS_STD_STRING and/or
// GTEST_HAS_GLOBAL_STRING, they are defined heuristically. // GTEST_HAS_GLOBAL_STRING, they are defined heuristically.
namespace testing { namespace testing {
// The upper limit for valid stack trace depths. // Declares the flags.
const int kMaxStackTraceDepth = 100;
// This flag specifies the maximum number of stack frames to be // This flag temporary enables the disabled tests.
// printed in a failure message. GTEST_DECLARE_bool_(also_run_disabled_tests);
GTEST_DECLARE_int32_(stack_trace_depth);
// This flag brings the debugger on an assertion failure.
GTEST_DECLARE_bool_(break_on_failure);
// This flag controls whether Google Test catches all test-thrown exception
s
// and logs them as failures.
GTEST_DECLARE_bool_(catch_exceptions);
// This flag enables using colors in terminal output. Available values are
// "yes" to enable colors, "no" (disable colors), or "auto" (the default)
// to let Google Test decide.
GTEST_DECLARE_string_(color);
// This flag sets up the filter to select by name using a glob pattern
// the tests to run. If the filter is not given all tests are executed.
GTEST_DECLARE_string_(filter);
// This flag causes the Google Test to list tests. None of the tests listed
// are actually run if the flag is provided.
GTEST_DECLARE_bool_(list_tests);
// This flag controls whether Google Test emits a detailed XML report to a
file
// in addition to its normal textual output.
GTEST_DECLARE_string_(output);
// This flags control whether Google Test prints the elapsed time for each
// test.
GTEST_DECLARE_bool_(print_time);
// This flag sets how many times the tests are repeated. The default value
// is 1. If the value is -1 the tests are repeating forever.
GTEST_DECLARE_int32_(repeat);
// This flag controls whether Google Test includes Google Test internal // This flag controls whether Google Test includes Google Test internal
// stack frames in failure stack traces. // stack frames in failure stack traces.
GTEST_DECLARE_bool_(show_internal_stack_frames); GTEST_DECLARE_bool_(show_internal_stack_frames);
// This flag specifies the maximum number of stack frames to be
// printed in a failure message.
GTEST_DECLARE_int32_(stack_trace_depth);
// When this flag is specified, a failed assertion will throw an
// exception if exceptions are enabled, or exit the program with a
// non-zero code otherwise.
GTEST_DECLARE_bool_(throw_on_failure);
// The upper limit for valid stack trace depths.
const int kMaxStackTraceDepth = 100;
namespace internal { namespace internal {
class GTestFlagSaver; class GTestFlagSaver;
// Converts a streamable value to a String. A NULL pointer is // Converts a streamable value to a String. A NULL pointer is
// converted to "(null)". When the input value is a ::string, // converted to "(null)". When the input value is a ::string,
// ::std::string, ::wstring, or ::std::wstring object, each NUL // ::std::string, ::wstring, or ::std::wstring object, each NUL
// character in it is replaced with "\\0". // character in it is replaced with "\\0".
// Declared in gtest-internal.h but defined here, so that it has access // Declared in gtest-internal.h but defined here, so that it has access
// to the definition of the Message class, required by the ARM // to the definition of the Message class, required by the ARM
skipping to change at line 355 skipping to change at line 397
// matches one of the positive patterns and does not match any of // matches one of the positive patterns and does not match any of
// the negative patterns. // the negative patterns.
// //
// For example, *A*:Foo.* is a filter that matches any string that // For example, *A*:Foo.* is a filter that matches any string that
// contains the character 'A' or starts with "Foo.". // contains the character 'A' or starts with "Foo.".
bool should_run() const; bool should_run() const;
// Returns the result of the test. // Returns the result of the test.
const internal::TestResult* result() const; const internal::TestResult* result() const;
private: private:
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
friend class internal::DefaultDeathTestFactory; friend class internal::DefaultDeathTestFactory;
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
friend class internal::TestInfoImpl; friend class internal::TestInfoImpl;
friend class internal::UnitTestImpl; friend class internal::UnitTestImpl;
friend class Test; friend class Test;
friend class TestCase; friend class TestCase;
friend TestInfo* internal::MakeAndRegisterTestInfo( friend TestInfo* internal::MakeAndRegisterTestInfo(
const char* test_case_name, const char* name, const char* test_case_name, const char* name,
const char* test_case_comment, const char* comment, const char* test_case_comment, const char* comment,
internal::TypeId fixture_class_id, internal::TypeId fixture_class_id,
skipping to change at line 486 skipping to change at line 528
const char* original_working_dir() const; const char* original_working_dir() const;
// Returns the TestCase object for the test that's currently running, // Returns the TestCase object for the test that's currently running,
// or NULL if no test is running. // or NULL if no test is running.
const TestCase* current_test_case() const; const TestCase* current_test_case() const;
// Returns the TestInfo object for the test that's currently running, // Returns the TestInfo object for the test that's currently running,
// or NULL if no test is running. // or NULL if no test is running.
const TestInfo* current_test_info() const; const TestInfo* current_test_info() const;
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
// Returns the ParameterizedTestCaseRegistry object used to keep track of // Returns the ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them. // value-parameterized tests and instantiate and register them.
internal::ParameterizedTestCaseRegistry& parameterized_test_registry(); internal::ParameterizedTestCaseRegistry& parameterized_test_registry();
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
// Accessors for the implementation object. // Accessors for the implementation object.
internal::UnitTestImpl* impl() { return impl_; } internal::UnitTestImpl* impl() { return impl_; }
const internal::UnitTestImpl* impl() const { return impl_; } const internal::UnitTestImpl* impl() const { return impl_; }
private: private:
// ScopedTrace is a friend as it needs to modify the per-thread // ScopedTrace is a friend as it needs to modify the per-thread
skipping to change at line 616 skipping to change at line 658
const T2& /* other_operand */) { const T2& /* other_operand */) {
return FormatForFailureMessage(value); return FormatForFailureMessage(value);
} }
// The helper function for {ASSERT|EXPECT}_EQ. // The helper function for {ASSERT|EXPECT}_EQ.
template <typename T1, typename T2> template <typename T1, typename T2>
AssertionResult CmpHelperEQ(const char* expected_expression, AssertionResult CmpHelperEQ(const char* expected_expression,
const char* actual_expression, const char* actual_expression,
const T1& expected, const T1& expected,
const T2& actual) { const T2& actual) {
#ifdef _MSC_VER
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4389) // Temporarily disables warning on
// signed/unsigned mismatch.
#endif
if (expected == actual) { if (expected == actual) {
return AssertionSuccess(); return AssertionSuccess();
} }
#ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state.
#endif
return EqFailure(expected_expression, return EqFailure(expected_expression,
actual_expression, actual_expression,
FormatForComparisonFailureMessage(expected, actual), FormatForComparisonFailureMessage(expected, actual),
FormatForComparisonFailureMessage(actual, expected), FormatForComparisonFailureMessage(actual, expected),
false); false);
} }
// With this overloaded version, we allow anonymous enums to be used // With this overloaded version, we allow anonymous enums to be used
// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
// can be implicitly cast to BiggestInt. // can be implicitly cast to BiggestInt.
skipping to change at line 690 skipping to change at line 742
const T2& actual) { const T2& actual) {
return CmpHelperEQ(expected_expression, actual_expression, expected, return CmpHelperEQ(expected_expression, actual_expression, expected,
actual); actual);
} }
// This version will be picked when the second argument to // This version will be picked when the second argument to
// ASSERT_EQ() is a pointer, e.g. ASSERT_EQ(NULL, a_pointer). // ASSERT_EQ() is a pointer, e.g. ASSERT_EQ(NULL, a_pointer).
template <typename T1, typename T2> template <typename T1, typename T2>
static AssertionResult Compare(const char* expected_expression, static AssertionResult Compare(const char* expected_expression,
const char* actual_expression, const char* actual_expression,
const T1& expected, const T1& /* expected */,
T2* actual) { T2* actual) {
// We already know that 'expected' is a null pointer. // We already know that 'expected' is a null pointer.
return CmpHelperEQ(expected_expression, actual_expression, return CmpHelperEQ(expected_expression, actual_expression,
static_cast<T2*>(NULL), actual); static_cast<T2*>(NULL), actual);
} }
}; };
// A macro for implementing the helper functions needed to implement // A macro for implementing the helper functions needed to implement
// ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste // ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste
// of similar code. // of similar code.
skipping to change at line 894 skipping to change at line 946
TestPartResultType const type_; TestPartResultType const type_;
const char* const file_; const char* const file_;
int const line_; int const line_;
String const message_; String const message_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper); GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
}; };
} // namespace internal } // namespace internal
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
// The abstract base class that all value-parameterized tests inherit from. // The abstract base class that all value-parameterized tests inherit from.
// //
// This class adds support for accessing the test parameter value via // This class adds support for accessing the test parameter value via
// the GetParam() method. // the GetParam() method.
// //
// Use it with one of the parameter generator defining functions, like Rang e(), // Use it with one of the parameter generator defining functions, like Rang e(),
// Values(), ValuesIn(), Bool(), and Combine(). // Values(), ValuesIn(), Bool(), and Combine().
// //
// class FooTest : public ::testing::TestWithParam<int> { // class FooTest : public ::testing::TestWithParam<int> {
// protected: // protected:
skipping to change at line 1187 skipping to change at line 1239
// //
// EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0); // EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);
// Asserts that val1 is less than, or almost equal to, val2. Fails // Asserts that val1 is less than, or almost equal to, val2. Fails
// otherwise. In particular, it fails if either val1 or val2 is NaN. // otherwise. In particular, it fails if either val1 or val2 is NaN.
AssertionResult FloatLE(const char* expr1, const char* expr2, AssertionResult FloatLE(const char* expr1, const char* expr2,
float val1, float val2); float val1, float val2);
AssertionResult DoubleLE(const char* expr1, const char* expr2, AssertionResult DoubleLE(const char* expr1, const char* expr2,
double val1, double val2); double val1, double val2);
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// Macros that test for HRESULT failure and success, these are only useful // Macros that test for HRESULT failure and success, these are only useful
// on Windows, and rely on Windows SDK macros and APIs to compile. // on Windows, and rely on Windows SDK macros and APIs to compile.
// //
// * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr) // * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)
// //
// When expr unexpectedly fails or succeeds, Google Test prints the // When expr unexpectedly fails or succeeds, Google Test prints the
// expected result and the actual result with both a human-readable // expected result and the actual result with both a human-readable
// string representation of the error, if available, as well as the // string representation of the error, if available, as well as the
// hex result code. // hex result code.
skipping to change at line 1242 skipping to change at line 1294
// The message argument can be anything streamable to std::ostream. // The message argument can be anything streamable to std::ostream.
// //
// In the implementation, we include the current line number as part // In the implementation, we include the current line number as part
// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s // of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
// to appear in the same block - as long as they are on different // to appear in the same block - as long as they are on different
// lines. // lines.
#define SCOPED_TRACE(message) \ #define SCOPED_TRACE(message) \
::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE __)(\ ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE __)(\
__FILE__, __LINE__, ::testing::Message() << (message)) __FILE__, __LINE__, ::testing::Message() << (message))
namespace internal {
// This template is declared, but intentionally undefined.
template <typename T1, typename T2>
struct StaticAssertTypeEqHelper;
template <typename T>
struct StaticAssertTypeEqHelper<T, T> {};
} // namespace internal
// Compile-time assertion for type equality.
// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
// the same type. The value it returns is not interesting.
//
// Instead of making StaticAssertTypeEq a class template, we make it a
// function template that invokes a helper class template. This
// prevents a user from misusing StaticAssertTypeEq<T1, T2> by
// defining objects of that type.
//
// CAVEAT:
//
// When used inside a method of a class template,
// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
// instantiated. For example, given:
//
// template <typename T> class Foo {
// public:
// void Bar() { testing::StaticAssertTypeEq<int, T>(); }
// };
//
// the code:
//
// void Test1() { Foo<bool> foo; }
//
// will NOT generate a compiler error, as Foo<bool>::Bar() is never
// actually instantiated. Instead, you need:
//
// void Test2() { Foo<bool> foo; foo.Bar(); }
//
// to cause a compiler error.
template <typename T1, typename T2>
bool StaticAssertTypeEq() {
internal::StaticAssertTypeEqHelper<T1, T2>();
return true;
}
// Defines a test. // Defines a test.
// //
// The first parameter is the name of the test case, and the second // The first parameter is the name of the test case, and the second
// parameter is the name of the test within the test case. // parameter is the name of the test within the test case.
// //
// The convention is to end the test case name with "Test". For // The convention is to end the test case name with "Test". For
// example, a test case for the Foo class can be named FooTest. // example, a test case for the Foo class can be named FooTest.
// //
// The user should put his test code between braces after using this // The user should put his test code between braces after using this
// macro. Example: // macro. Example:
skipping to change at line 1268 skipping to change at line 1367
// Note that we call GetTestTypeId() instead of GetTypeId< // Note that we call GetTestTypeId() instead of GetTypeId<
// ::testing::Test>() here to get the type ID of testing::Test. This // ::testing::Test>() here to get the type ID of testing::Test. This
// is to work around a suspected linker bug when using Google Test as // is to work around a suspected linker bug when using Google Test as
// a framework on Mac OS X. The bug causes GetTypeId< // a framework on Mac OS X. The bug causes GetTypeId<
// ::testing::Test>() to return different values depending on whether // ::testing::Test>() to return different values depending on whether
// the call is from the Google Test framework itself or from user test // the call is from the Google Test framework itself or from user test
// code. GetTestTypeId() is guaranteed to always return the same // code. GetTestTypeId() is guaranteed to always return the same
// value, as it always calls GetTypeId<>() from the Google Test // value, as it always calls GetTypeId<>() from the Google Test
// framework. // framework.
#define TEST(test_case_name, test_name)\ #define TEST(test_case_name, test_name)\
GTEST_TEST_(test_case_name, test_name,\ GTEST_TEST_(test_case_name, test_name, \
::testing::Test, ::testing::internal::GetTestTypeId()) ::testing::Test, ::testing::internal::GetTestTypeId())
// Defines a test that uses a test fixture. // Defines a test that uses a test fixture.
// //
// The first parameter is the name of the test fixture class, which // The first parameter is the name of the test fixture class, which
// also doubles as the test case name. The second parameter is the // also doubles as the test case name. The second parameter is the
// name of the test within the test case. // name of the test within the test case.
// //
// A test fixture class must be declared earlier. The user should put // A test fixture class must be declared earlier. The user should put
// his test code between braces after using this macro. Example: // his test code between braces after using this macro. Example:
skipping to change at line 1298 skipping to change at line 1397
// TEST_F(FooTest, InitializesCorrectly) { // TEST_F(FooTest, InitializesCorrectly) {
// EXPECT_TRUE(a_.StatusIsOK()); // EXPECT_TRUE(a_.StatusIsOK());
// } // }
// //
// TEST_F(FooTest, ReturnsElementCountCorrectly) { // TEST_F(FooTest, ReturnsElementCountCorrectly) {
// EXPECT_EQ(0, a_.size()); // EXPECT_EQ(0, a_.size());
// EXPECT_EQ(1, b_.size()); // EXPECT_EQ(1, b_.size());
// } // }
#define TEST_F(test_fixture, test_name)\ #define TEST_F(test_fixture, test_name)\
GTEST_TEST_(test_fixture, test_name, test_fixture,\ GTEST_TEST_(test_fixture, test_name, test_fixture, \
::testing::internal::GetTypeId<test_fixture>()) ::testing::internal::GetTypeId<test_fixture>())
// Use this macro in main() to run all tests. It returns 0 if all // Use this macro in main() to run all tests. It returns 0 if all
// tests are successful, or 1 otherwise. // tests are successful, or 1 otherwise.
// //
// RUN_ALL_TESTS() should be invoked after the command line has been // RUN_ALL_TESTS() should be invoked after the command line has been
// parsed by InitGoogleTest(). // parsed by InitGoogleTest().
#define RUN_ALL_TESTS()\ #define RUN_ALL_TESTS()\
(::testing::UnitTest::GetInstance()->Run()) (::testing::UnitTest::GetInstance()->Run())
 End of changes. 13 change blocks. 
12 lines changed or deleted 113 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/