| 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-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 | |
|
| 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.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 | |
|