gmock-actions.h   gmock-actions.h 
skipping to change at line 46 skipping to change at line 46
#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 #ifndef _WIN32_WCE
#include <errno.h> #include <errno.h>
#endif #endif
#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>
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 127 skipping to change at line 128
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.
// 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
// wchar_t or unsigned wchar_t (obviously, assuming the compiler
// supports them).
//
// To gcc,
//
// wchar_t == signed wchar_t != unsigned wchar_t == unsigned int
//
// MSVC does not recognize signed wchar_t or unsigned wchar_t. It
// treats wchar_t as a native type usually, but treats it as the same
// as unsigned short when the compiler option /Zc:wchar_t- is
// specified.
//
// Therefore we provide a default action for wchar_t when compiled
// 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 GMOCK_WCHAR_T_IS_NATIVE_
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); // NOLIN T GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLIN T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLIN T GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLIN T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLIN T GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLIN T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLIN T GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLIN T
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);
skipping to change at line 600 skipping to change at line 582
}; };
// Implements the Assign action to set a given pointer referent to a // Implements the Assign action to set a given pointer referent to a
// particular value. // particular value.
template <typename T1, typename T2> template <typename T1, typename T2>
class AssignAction { class AssignAction {
public: public:
AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {} AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {}
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 #if !GTEST_OS_WINDOWS_MOBILE
// 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 #endif // !GTEST_OS_WINDOWS_MOBILE
// 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'.
skipping to change at line 671 skipping to change at line 653
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>();
::std::tr1::get<N>(args)->CopyFrom(*proto_); ::std::tr1::get<N>(args)->CopyFrom(*proto_);
} }
private: private:
const internal::linked_ptr<Proto> proto_; const internal::linked_ptr<Proto> proto_;
}; };
// Implements the SetArrayArgument<N>(first, last) action for any function
// whose N-th argument (0-based) is a pointer or iterator to a type that ca
n be
// implicitly converted from *first.
template <size_t N, typename InputIterator>
class SetArrayArgumentAction {
public:
// Constructs an action that sets the variable pointed to by the
// N-th function argument to 'value'.
explicit SetArrayArgumentAction(InputIterator first, InputIterator last)
: first_(first), last_(last) {
}
template <typename Result, typename ArgumentTuple>
void Perform(const ArgumentTuple& args) const {
CompileAssertTypesEqual<void, Result>();
// Microsoft compiler deprecates ::std::copy, so we want to suppress wa
rning
// 4996 (Function call with parameters that may be unsafe) there.
#if GTEST_OS_WINDOWS
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996.
#endif // GTEST_OS_WINDOWS
::std::copy(first_, last_, ::std::tr1::get<N>(args));
#if GTEST_OS_WINDOWS
#pragma warning(pop) // Restores the warning state.
#endif // GTEST_OS_WINDOWS
}
private:
const InputIterator first_;
const InputIterator last_;
};
// Implements the InvokeWithoutArgs(f) action. The template argument // Implements the InvokeWithoutArgs(f) action. The template argument
// FunctionImpl is the implementation type of f, which can be either a // FunctionImpl is the implementation type of f, which can be either a
// function pointer or a functor. InvokeWithoutArgs(f) can be used as an // function pointer or a functor. InvokeWithoutArgs(f) can be used as an
// Action<F> as long as f's type is compatible with F (i.e. f can be // Action<F> as long as f's type is compatible with F (i.e. f can be
// assigned to a tr1::function<F>). // assigned to a tr1::function<F>).
template <typename FunctionImpl> template <typename FunctionImpl>
class InvokeWithoutArgsAction { class InvokeWithoutArgsAction {
public: public:
// The c'tor makes a copy of function_impl (either a function // The c'tor makes a copy of function_impl (either a function
// pointer or a functor). // pointer or a functor).
skipping to change at line 790 skipping to change at line 739
// type is IgnoredValue. // type is IgnoredValue.
typedef typename internal::Function<F>::MakeResultIgnoredValue typedef typename internal::Function<F>::MakeResultIgnoredValue
OriginalFunction; OriginalFunction;
const Action<OriginalFunction> action_; const Action<OriginalFunction> action_;
}; };
const A action_; const A action_;
}; };
// A ReferenceWrapper<T> object represents a reference to type T,
// which can be either const or not. It can be explicitly converted
// from, and implicitly converted to, a T&. Unlike a reference,
// ReferenceWrapper<T> can be copied and can survive template type
// inference. This is used to support by-reference arguments in the
// InvokeArgument<N>(...) action. The idea was from "reference
// wrappers" in tr1, which we don't have in our source tree yet.
template <typename T>
class ReferenceWrapper {
public:
// Constructs a ReferenceWrapper<T> object from a T&.
explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {} // NOLINT
// Allows a ReferenceWrapper<T> object to be implicitly converted to
// a T&.
operator T&() const { return *pointer_; }
private:
T* pointer_;
};
// Allows the expression ByRef(x) to be printed as a reference to x.
template <typename T>
void PrintTo(const ReferenceWrapper<T>& ref, ::std::ostream* os) {
T& value = ref;
UniversalPrinter<T&>::Print(value, os);
}
// Does two actions sequentially. Used for implementing the DoAll(a1,
// a2, ...) action.
template <typename Action1, typename Action2>
class DoBothAction {
public:
DoBothAction(Action1 action1, Action2 action2)
: action1_(action1), action2_(action2) {}
// This template type conversion operator allows DoAll(a1, ..., a_n)
// to be used in ANY function of compatible type.
template <typename F>
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>::ArgumentTuple ArgumentTuple;
typedef typename Function<F>::MakeResultVoid VoidResult;
Impl(const Action<VoidResult>& action1, const Action<F>& action2)
: action1_(action1), action2_(action2) {}
virtual Result Perform(const ArgumentTuple& args) {
action1_.Perform(args);
return action2_.Perform(args);
}
private:
const Action<VoidResult> action1_;
const Action<F> action2_;
};
Action1 action1_;
Action2 action2_;
};
} // namespace internal } // namespace internal
// An Unused object can be implicitly constructed from ANY value. // An Unused object can be implicitly constructed from ANY value.
// This is handy when defining actions that ignore some or all of the // This is handy when defining actions that ignore some or all of the
// mock function arguments. For example, given // mock function arguments. For example, given
// //
// MOCK_METHOD3(Foo, double(const string& label, double x, double y)); // MOCK_METHOD3(Foo, double(const string& label, double x, double y));
// MOCK_METHOD3(Bar, double(int index, double x, double y)); // MOCK_METHOD3(Bar, double(int index, double x, double y));
// //
// instead of // instead of
skipping to change at line 873 skipping to change at line 890
// (0-based) function argument to 'value'. // (0-based) function argument to 'value'.
template <size_t N, typename T> template <size_t N, typename T>
PolymorphicAction< PolymorphicAction<
internal::SetArgumentPointeeAction< internal::SetArgumentPointeeAction<
N, T, internal::IsAProtocolMessage<T>::value> > N, T, internal::IsAProtocolMessage<T>::value> >
SetArgumentPointee(const T& x) { SetArgumentPointee(const T& x) {
return MakePolymorphicAction(internal::SetArgumentPointeeAction< return MakePolymorphicAction(internal::SetArgumentPointeeAction<
N, T, internal::IsAProtocolMessage<T>::value>(x)); N, T, internal::IsAProtocolMessage<T>::value>(x));
} }
// Creates an action that sets the elements of the array pointed to by the
N-th
// (0-based) function argument, which can be either a pointer or an iterato
r,
// to the values of the elements in the source range [first, last).
template <size_t N, typename InputIterator>
PolymorphicAction<internal::SetArrayArgumentAction<N, InputIterator> >
SetArrayArgument(InputIterator first, InputIterator last) {
return MakePolymorphicAction(internal::SetArrayArgumentAction<
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 #if !GTEST_OS_WINDOWS_MOBILE
// 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 #endif // !GTEST_OS_WINDOWS_MOBILE
// 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));
} }
skipping to change at line 929 skipping to change at line 936
} }
// Creates an action that performs an_action and throws away its // Creates an action that performs an_action and throws away its
// result. In other words, it changes the return type of an_action to // result. In other words, it changes the return type of an_action to
// void. an_action MUST NOT return void, or the code won't compile. // void. an_action MUST NOT return void, or the code won't compile.
template <typename A> template <typename A>
inline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) { inline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) {
return internal::IgnoreResultAction<A>(an_action); return internal::IgnoreResultAction<A>(an_action);
} }
// Creates a reference wrapper for the given L-value. If necessary,
// you can explicitly specify the type of the reference. For example,
// suppose 'derived' is an object of type Derived, ByRef(derived)
// would wrap a Derived&. If you want to wrap a const Base& instead,
// where Base is a base class of Derived, just write:
//
// ByRef<const Base>(derived)
template <typename T>
inline internal::ReferenceWrapper<T> ByRef(T& l_value) { // NOLINT
return internal::ReferenceWrapper<T>(l_value);
}
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
 End of changes. 13 change blocks. 
73 lines changed or deleted 88 lines changed or added


 gmock-generated-actions.h   gmock-generated-actions.h 
skipping to change at line 285 skipping to change at line 285
MethodPtr method_ptr, MethodPtr method_ptr,
const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
A9, A10>& args) { A9, A10>& args) {
using ::std::tr1::get; using ::std::tr1::get;
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args), return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args ), get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args ),
get<8>(args), get<9>(args)); get<8>(args), get<9>(args));
} }
}; };
// Implements the Invoke(f) action. The template argument
// FunctionImpl is the implementation type of f, which can be either a
// function pointer or a functor. Invoke(f) can be used as an
// Action<F> as long as f's type is compatible with F (i.e. f can be
// assigned to a tr1::function<F>).
template <typename FunctionImpl>
class InvokeAction {
public:
// The c'tor makes a copy of function_impl (either a function
// pointer or a functor).
explicit InvokeAction(FunctionImpl function_impl)
: function_impl_(function_impl) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args
);
}
private:
FunctionImpl function_impl_;
};
// Implements the Invoke(object_ptr, &Class::Method) action.
template <class Class, typename MethodPtr>
class InvokeMethodAction {
public:
InvokeMethodAction(Class* obj_ptr, MethodPtr method_ptr)
: obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) const {
return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
obj_ptr_, method_ptr_, args);
}
private:
Class* const obj_ptr_;
const MethodPtr method_ptr_;
};
// A ReferenceWrapper<T> object represents a reference to type T,
// which can be either const or not. It can be explicitly converted
// from, and implicitly converted to, a T&. Unlike a reference,
// ReferenceWrapper<T> can be copied and can survive template type
// inference. This is used to support by-reference arguments in the
// InvokeArgument<N>(...) action. The idea was from "reference
// wrappers" in tr1, which we don't have in our source tree yet.
template <typename T>
class ReferenceWrapper {
public:
// Constructs a ReferenceWrapper<T> object from a T&.
explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {} // NOLINT
// Allows a ReferenceWrapper<T> object to be implicitly converted to
// a T&.
operator T&() const { return *pointer_; }
private:
T* pointer_;
};
// CallableHelper has static methods for invoking "callables", // CallableHelper has static methods for invoking "callables",
// i.e. function pointers and functors. It uses overloading to // i.e. function pointers and functors. It uses overloading to
// provide a uniform interface for invoking different kinds of // provide a uniform interface for invoking different kinds of
// callables. In particular, you can use: // callables. In particular, you can use:
// //
// CallableHelper<R>::Call(callable, a1, a2, ..., an) // CallableHelper<R>::Call(callable, a1, a2, ..., an)
// //
// to invoke an n-ary callable, where R is its return type. If an // to invoke an n-ary callable, where R is its return type. If an
// argument, say a2, needs to be passed by reference, you should write // argument, say a2, needs to be passed by reference, you should write
// ByRef(a2) instead of a2 in the above expression. // ByRef(a2) instead of a2 in the above expression.
skipping to change at line 445 skipping to change at line 387
template <typename Function, typename A1, typename A2, typename A3, template <typename Function, typename A1, typename A2, typename A3,
typename A4, typename A5, typename A6, typename A7, typename A8, typename A4, typename A5, typename A6, typename A7, typename A8,
typename A9, typename A10> typename A9, typename A10>
static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 , static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 ,
A7 a7, A8 a8, A9 a9, A10 a10) { A7 a7, A8 a8, A9 a9, A10 a10) {
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
} }
}; // class CallableHelper }; // class CallableHelper
// Invokes a nullary callable argument.
template <size_t N>
class InvokeArgumentAction0 {
public:
template <typename Result, typename ArgumentTuple>
static Result Perform(const ArgumentTuple& args) {
return CallableHelper<Result>::Call(::std::tr1::get<N>(args));
}
};
// Invokes a unary callable argument with the given argument.
template <size_t N, typename A1>
class InvokeArgumentAction1 {
public:
// We deliberately pass a1 by value instead of const reference here
// in case it is a C-string literal.
//
// Since this function is defined inline, the compiler can get rid
// of the copying of the arguments. Therefore the performance won't
// be hurt.
explicit InvokeArgumentAction1(A1 a1) : arg1_(a1) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
return CallableHelper<Result>::Call(::std::tr1::get<N>(args), arg1_);
}
private:
const A1 arg1_;
};
// Invokes a binary callable argument with the given arguments.
template <size_t N, typename A1, typename A2>
class InvokeArgumentAction2 {
public:
InvokeArgumentAction2(A1 a1, A2 a2) :
arg1_(a1), arg2_(a2) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
return CallableHelper<Result>::Call(::std::tr1::get<N>(args), arg1_, ar
g2_);
}
private:
const A1 arg1_;
const A2 arg2_;
};
// Invokes a ternary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3>
class InvokeArgumentAction3 {
public:
InvokeArgumentAction3(A1 a1, A2 a2, A3 a3) :
arg1_(a1), arg2_(a2), arg3_(a3) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
return CallableHelper<Result>::Call(::std::tr1::get<N>(args), arg1_, ar
g2_,
arg3_);
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
};
// Invokes a 4-ary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3, typename A4>
class InvokeArgumentAction4 {
public:
InvokeArgumentAction4(A1 a1, A2 a2, A3 a3, A4 a4) :
arg1_(a1), arg2_(a2), arg3_(a3), arg4_(a4) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
return CallableHelper<Result>::Call(::std::tr1::get<N>(args), arg1_, ar
g2_,
arg3_, arg4_);
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
const A4 arg4_;
};
// Invokes a 5-ary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5>
class InvokeArgumentAction5 {
public:
InvokeArgumentAction5(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) :
arg1_(a1), arg2_(a2), arg3_(a3), arg4_(a4), arg5_(a5) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
// We extract the callable to a variable before invoking it, in
// case it is a functor passed by value and its operator() is not
// const.
typename ::std::tr1::tuple_element<N, ArgumentTuple>::type function =
::std::tr1::get<N>(args);
return function(arg1_, arg2_, arg3_, arg4_, arg5_);
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
const A4 arg4_;
const A5 arg5_;
};
// Invokes a 6-ary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6>
class InvokeArgumentAction6 {
public:
InvokeArgumentAction6(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) :
arg1_(a1), arg2_(a2), arg3_(a3), arg4_(a4), arg5_(a5), arg6_(a6) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
// We extract the callable to a variable before invoking it, in
// case it is a functor passed by value and its operator() is not
// const.
typename ::std::tr1::tuple_element<N, ArgumentTuple>::type function =
::std::tr1::get<N>(args);
return function(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_);
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
const A4 arg4_;
const A5 arg5_;
const A6 arg6_;
};
// Invokes a 7-ary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7>
class InvokeArgumentAction7 {
public:
InvokeArgumentAction7(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) :
arg1_(a1), arg2_(a2), arg3_(a3), arg4_(a4), arg5_(a5), arg6_(a6),
arg7_(a7) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
// We extract the callable to a variable before invoking it, in
// case it is a functor passed by value and its operator() is not
// const.
typename ::std::tr1::tuple_element<N, ArgumentTuple>::type function =
::std::tr1::get<N>(args);
return function(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_, arg7_);
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
const A4 arg4_;
const A5 arg5_;
const A6 arg6_;
const A7 arg7_;
};
// Invokes a 8-ary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8>
class InvokeArgumentAction8 {
public:
InvokeArgumentAction8(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
A8 a8) :
arg1_(a1), arg2_(a2), arg3_(a3), arg4_(a4), arg5_(a5), arg6_(a6),
arg7_(a7), arg8_(a8) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
// We extract the callable to a variable before invoking it, in
// case it is a functor passed by value and its operator() is not
// const.
typename ::std::tr1::tuple_element<N, ArgumentTuple>::type function =
::std::tr1::get<N>(args);
return function(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_, arg7_, arg8_)
;
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
const A4 arg4_;
const A5 arg5_;
const A6 arg6_;
const A7 arg7_;
const A8 arg8_;
};
// Invokes a 9-ary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9>
class InvokeArgumentAction9 {
public:
InvokeArgumentAction9(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8
a8,
A9 a9) :
arg1_(a1), arg2_(a2), arg3_(a3), arg4_(a4), arg5_(a5), arg6_(a6),
arg7_(a7), arg8_(a8), arg9_(a9) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
// We extract the callable to a variable before invoking it, in
// case it is a functor passed by value and its operator() is not
// const.
typename ::std::tr1::tuple_element<N, ArgumentTuple>::type function =
::std::tr1::get<N>(args);
return function(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_, arg7_, arg8_,
arg9_);
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
const A4 arg4_;
const A5 arg5_;
const A6 arg6_;
const A7 arg7_;
const A8 arg8_;
const A9 arg9_;
};
// Invokes a 10-ary callable argument with the given arguments.
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9,
typename A10>
class InvokeArgumentAction10 {
public:
InvokeArgumentAction10(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7,
A8 a8, A9 a9, A10 a10) :
arg1_(a1), arg2_(a2), arg3_(a3), arg4_(a4), arg5_(a5), arg6_(a6),
arg7_(a7), arg8_(a8), arg9_(a9), arg10_(a10) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) {
// We extract the callable to a variable before invoking it, in
// case it is a functor passed by value and its operator() is not
// const.
typename ::std::tr1::tuple_element<N, ArgumentTuple>::type function =
::std::tr1::get<N>(args);
return function(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_, arg7_, arg8_,
arg9_, arg10_);
}
private:
const A1 arg1_;
const A2 arg2_;
const A3 arg3_;
const A4 arg4_;
const A5 arg5_;
const A6 arg6_;
const A7 arg7_;
const A8 arg8_;
const A9 arg9_;
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
skipping to change at line 751 skipping to change at line 435
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>
class SelectArgs<Result, ArgumentTuple, class SelectArgs<Result, ArgumentTuple,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
public: public:
typedef Result type(); typedef Result type();
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(); 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));
skipping to change at line 936 skipping to change at line 620
private: private:
typedef typename SelectArgs<Result, ArgumentTuple, typedef typename SelectArgs<Result, ArgumentTuple,
k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType; k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
Action<InnerFunctionType> action_; Action<InnerFunctionType> action_;
}; };
const InnerAction action_; const InnerAction action_;
}; };
// Does two actions sequentially. Used for implementing the DoAll(a1,
// a2, ...) action.
template <typename Action1, typename Action2>
class DoBothAction {
public:
DoBothAction(Action1 action1, Action2 action2)
: action1_(action1), action2_(action2) {}
// This template type conversion operator allows DoAll(a1, ..., a_n)
// to be used in ANY function of compatible type.
template <typename F>
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>::ArgumentTuple ArgumentTuple;
typedef typename Function<F>::MakeResultVoid VoidResult;
Impl(const Action<VoidResult>& action1, const Action<F>& action2)
: action1_(action1), action2_(action2) {}
virtual Result Perform(const ArgumentTuple& args) {
action1_.Perform(args);
return action2_.Perform(args);
}
private:
const Action<VoidResult> action1_;
const Action<F> action2_;
};
Action1 action1_;
Action2 action2_;
};
// A macro from the ACTION* family (defined later in this file) // A macro from the ACTION* family (defined later in this file)
// defines an action that can be used in a mock function. Typically, // 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 // these actions only care about a subset of the arguments of the mock
// function. For example, if such an action only uses the second // function. For example, if such an action only uses the second
// argument, it can be used in any mock function that takes >= 2 // argument, it can be used in any mock function that takes >= 2
// arguments where the type of the second argument is compatible. // arguments where the type of the second argument is compatible.
// //
// Therefore, the action implementation must be prepared to take more // Therefore, the action implementation must be prepared to take more
// arguments than it needs. The ExcessiveArg type is used to // arguments than it needs. The ExcessiveArg type is used to
// represent those excessive arguments. In order to keep the compiler // represent those excessive arguments. In order to keep the compiler
skipping to change at line 1112 skipping to change at line 755
A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args), 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<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args ),
get<9>(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
// function's arguments.
template <typename FunctionImpl>
PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
FunctionImpl function_impl) {
return MakePolymorphicAction(
internal::InvokeAction<FunctionImpl>(function_impl));
}
// Creates an action that invokes the given method on the given object
// with the mock function's arguments.
template <class Class, typename MethodPtr>
PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
Class* obj_ptr, MethodPtr method_ptr) {
return MakePolymorphicAction(
internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));
}
// Creates a reference wrapper for the given L-value. If necessary,
// you can explicitly specify the type of the reference. For example,
// suppose 'derived' is an object of type Derived, ByRef(derived)
// would wrap a Derived&. If you want to wrap a const Base& instead,
// where Base is a base class of Derived, just write:
//
// ByRef<const Base>(derived)
template <typename T>
inline internal::ReferenceWrapper<T> ByRef(T& l_value) { // NOLINT
return internal::ReferenceWrapper<T>(l_value);
}
// Various overloads for InvokeArgument<N>().
//
// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
// (0-based) argument, which must be a k-ary callable, of the mock
// function, with arguments a1, a2, ..., a_k.
//
// Notes:
//
// 1. The arguments are passed by value by default. If you need to
// pass an argument by reference, wrap it inside ByRef(). For
// example,
//
// InvokeArgument<1>(5, string("Hello"), ByRef(foo))
//
// passes 5 and string("Hello") by value, and passes foo by
// reference.
//
// 2. If the callable takes an argument by reference but ByRef() is
// not used, it will receive the reference to a copy of the value,
// instead of the original value. For example, when the 0-th
// argument of the mock function takes a const string&, the action
//
// InvokeArgument<0>(string("Hello"))
//
// makes a copy of the temporary string("Hello") object and passes a
// reference of the copy, instead of the original temporary object,
// to the callable. This makes it easy for a user to define an
// InvokeArgument action from temporary values and have it performed
// later.
template <size_t N>
inline PolymorphicAction<internal::InvokeArgumentAction0<N> > InvokeArgumen
t() {
return MakePolymorphicAction(internal::InvokeArgumentAction0<N>());
}
// We deliberately pass a1 by value instead of const reference here in
// case it is a C-string literal. If we had declared the parameter as
// 'const A1& a1' and write InvokeArgument<0>("Hi"), the compiler
// would've thought A1 is 'char[3]', which causes trouble as the
// implementation needs to copy a value of type A1. By declaring the
// parameter as 'A1 a1', the compiler will correctly infer that A1 is
// 'const char*' when it sees InvokeArgument<0>("Hi").
//
// Since this function is defined inline, the compiler can get rid of
// the copying of the arguments. Therefore the performance won't be
// hurt.
template <size_t N, typename A1>
inline PolymorphicAction<internal::InvokeArgumentAction1<N, A1> >
InvokeArgument(A1 a1) {
return MakePolymorphicAction(internal::InvokeArgumentAction1<N, A1>(a1));
}
template <size_t N, typename A1, typename A2>
inline PolymorphicAction<internal::InvokeArgumentAction2<N, A1, A2> >
InvokeArgument(A1 a1, A2 a2) {
return MakePolymorphicAction(
internal::InvokeArgumentAction2<N, A1, A2>(a1, a2));
}
template <size_t N, typename A1, typename A2, typename A3>
inline PolymorphicAction<internal::InvokeArgumentAction3<N, A1, A2, A3> >
InvokeArgument(A1 a1, A2 a2, A3 a3) {
return MakePolymorphicAction(
internal::InvokeArgumentAction3<N, A1, A2, A3>(a1, a2, a3));
}
template <size_t N, typename A1, typename A2, typename A3, typename A4>
inline PolymorphicAction<internal::InvokeArgumentAction4<N, A1, A2, A3, A4>
>
InvokeArgument(A1 a1, A2 a2, A3 a3, A4 a4) {
return MakePolymorphicAction(
internal::InvokeArgumentAction4<N, A1, A2, A3, A4>(a1, a2, a3, a4));
}
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5>
inline PolymorphicAction<internal::InvokeArgumentAction5<N, A1, A2, A3, A4,
A5> >
InvokeArgument(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
return MakePolymorphicAction(
internal::InvokeArgumentAction5<N, A1, A2, A3, A4, A5>(a1, a2, a3, a4
,
a5));
}
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6>
inline PolymorphicAction<internal::InvokeArgumentAction6<N, A1, A2, A3, A4,
A5,
A6> >
InvokeArgument(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
return MakePolymorphicAction(
internal::InvokeArgumentAction6<N, A1, A2, A3, A4, A5, A6>(a1, a2, a3
,
a4, a5, a6));
}
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7>
inline PolymorphicAction<internal::InvokeArgumentAction7<N, A1, A2, A3, A4,
A5,
A6, A7> >
InvokeArgument(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
return MakePolymorphicAction(
internal::InvokeArgumentAction7<N, A1, A2, A3, A4, A5, A6, A7>(a1, a2
,
a3, a4, a5, a6, a7));
}
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8>
inline PolymorphicAction<internal::InvokeArgumentAction8<N, A1, A2, A3, A4,
A5,
A6, A7, A8> >
InvokeArgument(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
return MakePolymorphicAction(
internal::InvokeArgumentAction8<N, A1, A2, A3, A4, A5, A6, A7, A8>(a1
,
a2, a3, a4, a5, a6, a7, a8));
}
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9>
inline PolymorphicAction<internal::InvokeArgumentAction9<N, A1, A2, A3, A4,
A5,
A6, A7, A8, A9> >
InvokeArgument(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a
9) {
return MakePolymorphicAction(
internal::InvokeArgumentAction9<N, A1, A2, A3, A4, A5, A6, A7, A8,
A9>(a1, a2, a3, a4, a5, a6, a7, a8, a9));
}
template <size_t N, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9,
typename A10>
inline PolymorphicAction<internal::InvokeArgumentAction10<N, A1, A2, A3, A4
,
A5, A6, A7, A8, A9, A10> >
InvokeArgument(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a
9,
A10 a10) {
return MakePolymorphicAction(
internal::InvokeArgumentAction10<N, A1, A2, A3, A4, A5, A6, A7, A8, A
9,
A10>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
}
// WithoutArgs(inner_action) can be used in a mock function with a
// non-empty argument list to perform inner_action, which takes no
// argument. In other words, it adapts an action accepting no
// argument to one that accepts (and ignores) arguments.
template <typename InnerAction>
inline internal::WithArgsAction<InnerAction>
WithoutArgs(const InnerAction& action) {
return internal::WithArgsAction<InnerAction>(action);
}
// WithArg<k>(an_action) creates an action that passes the k-th
// (0-based) argument of the mock function to an_action and performs
// it. It adapts an action accepting one argument to one that accepts
// multiple arguments. For convenience, we also provide
// WithArgs<k>(an_action) (defined below) as a synonym.
template <int k, typename InnerAction>
inline internal::WithArgsAction<InnerAction, k>
WithArg(const InnerAction& action) {
return internal::WithArgsAction<InnerAction, k>(action);
}
// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes // WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
// the selected arguments of the mock function to an_action and // the selected arguments of the mock function to an_action and
// performs it. It serves as an adaptor between actions with // performs it. It serves as an adaptor between actions with
// different argument lists. C++ doesn't support default arguments for // different argument lists. C++ doesn't support default arguments for
// function templates, so we have to overload it. // function templates, so we have to overload it.
template <int k1, typename InnerAction> template <int k1, typename InnerAction>
inline internal::WithArgsAction<InnerAction, k1> inline internal::WithArgsAction<InnerAction, k1>
WithArgs(const InnerAction& action) { WithArgs(const InnerAction& action) {
return internal::WithArgsAction<InnerAction, k1>(action); return internal::WithArgsAction<InnerAction, k1>(action);
} }
skipping to change at line 1559 skipping to change at line 1017
// that C++ doesn't yet allow function-local types to be used to // that C++ doesn't yet allow function-local types to be used to
// instantiate templates. The up-coming C++0x standard will fix this. // instantiate templates. The up-coming C++0x standard will fix this.
// Once that's done, we'll consider supporting using ACTION*() inside // Once that's done, we'll consider supporting using ACTION*() inside
// a function. // a function.
// //
// MORE INFORMATION: // MORE INFORMATION:
// //
// To learn more about using these macros, please search for 'ACTION' // To learn more about using these macros, please search for 'ACTION'
// on http://code.google.com/p/googlemock/wiki/CookBook. // on http://code.google.com/p/googlemock/wiki/CookBook.
// An internal macro needed for implementing ACTION*().
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
const args_type& args GTEST_ATTRIBUTE_UNUSED_,\
arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_,\
arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_,\
arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_,\
arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_,\
arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_,\
arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_,\
arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_,\
arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_,\
arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_,\
arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
// Sometimes you want to give an action explicit template parameters
// that cannot be inferred from its value parameters. ACTION() and
// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that
// and can be viewed as an extension to ACTION() and ACTION_P*().
//
// The syntax:
//
// ACTION_TEMPLATE(ActionName,
// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_
m),
// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
//
// defines an action template that takes m explicit template
// parameters and n value parameters. name_i is the name of the i-th
// template parameter, and kind_i specifies whether it's a typename,
// an integral constant, or a template. p_i is the name of the i-th
// value parameter.
//
// Example:
//
// // DuplicateArg<k, T>(output) converts the k-th argument of the mock
// // function to type T and copies it to *output.
// ACTION_TEMPLATE(DuplicateArg,
// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
// AND_1_VALUE_PARAMS(output)) {
// *output = T(std::tr1::get<k>(args));
// }
// ...
// int n;
// EXPECT_CALL(mock, Foo(_, _))
// .WillOnce(DuplicateArg<1, unsigned char>(&n));
//
// To create an instance of an action template, write:
//
// ActionName<t1, ..., t_m>(v1, ..., v_n)
//
// where the ts are the template arguments and the vs are the value
// arguments. The value argument types are inferred by the compiler.
// If you want to explicitly specify the value argument types, you can
// provide additional template arguments:
//
// ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
//
// where u_i is the desired type of v_i.
//
// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
// number of value parameters, but not on the number of template
// parameters. Without the restriction, the meaning of the following
// is unclear:
//
// OverloadedAction<int, bool>(x);
//
// Are we using a single-template-parameter action where 'bool' refers
// to the type of x, or are we using a two-template-parameter action
// where the compiler is asked to infer the type of x?
//
// Implementation notes:
//
// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
// implementing ACTION_TEMPLATE. The main trick we use is to create
// new macro invocations when expanding a macro. For example, we have
//
// #define ACTION_TEMPLATE(name, template_params, value_params)
// ... GMOCK_INTERNAL_DECL_##template_params ...
//
// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ..
.)
// to expand to
//
// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
//
// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
// preprocessor will continue to expand it to
//
// ... typename T ...
//
// This technique conforms to the C++ standard and is portable. It
// allows us to implement action templates using O(N) code, where N is
// the maximum number of template/value parameters supported. Without
// using it, we'd have to devote O(N^2) amount of code to implement all
// combinations of m and n.
// Declares the template parameters.
#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
name1) kind0 name0, kind1 name1
#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2) kind0 name0, kind1 name1, kind2 name2
#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
kind3 name3
#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
kind2 name2, kind3 name3, kind4 name4
#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4,
\
kind5 name5, kind6 name6
#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
kind4 name4, kind5 name5, kind6 name6, kind7 name7
#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
kind8 name8
#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
kind6 name6, kind7 name7, kind8 name8, kind9 name9
// Lists the template parameters.
#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
name1) name0, name1
#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2) name0, name1, name2
#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3) name0, name1, name2, name3
#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
name4
#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
name2, name3, name4, name5
#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
name6) name0, name1, name2, name3, name4, name5, name6
#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name
1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
name6, name7, name8
#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
name3, name4, name5, name6, name7, name8, name9
// Declares the types of value parameters.
#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_typ
e
#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
typename p0##_type, typename p1##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
typename p0##_type, typename p1##_type, typename p2##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)
, \
typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5,
\
p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5,
\
p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5,
\
p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_typ
e, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5
, \
p6, p7, p8, p9) , 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
// Initializes the value parameters.
#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
()
#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
(p0##_type gmock_p0) : p0(gmock_p0)
#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)
#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)
#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
(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)
#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
(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)
#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
(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)
#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
(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)
#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
p7)\
(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)
#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7, p8)\
(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)
#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7, p8, p9)\
(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)
// Declares the fields for storing the value parameters.
#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
p1##_type p1;
#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
p1##_type p1; p2##_type p2;
#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0
; \
p1##_type p1; p2##_type p2; p3##_type p3;
#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p
4;
#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p
4; \
p5##_type p5;
#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p
4; \
p5##_type p5; p6##_type p6;
#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p
4; \
p5##_type p5; p6##_type p6; p7##_type p7;
#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(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;
#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(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;
// Lists the value parameters.
#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2,
p3
#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1,
\
p2, p3, p4
#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0,
\
p1, p2, p3, p4, p5
#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6) p0, p1, p2, p3, p4, p5, p6
#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7) p0, p1, p2, p3, p4, p5, p6, p7
#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
// Lists the value parameter types.
#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
p1##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type
, \
p1##_type, p2##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
p0##_type, p1##_type, p2##_type, p3##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)
, \
p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5,
\
p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type,
\
p6##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5,
\
p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p5##_type, p6##_type, p7##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5,
\
p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p5##_type, p6##_type, p7##_type, p8##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5
, \
p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
, \
p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
// Declares the value parameters.
#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
p1##_type p1
#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
p1##_type p1, p2##_type p2
#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0
, \
p1##_type p1, p2##_type p2, p3##_type p3
#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p
4
#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p
4, \
p5##_type p5
#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p
4, \
p5##_type p5, p6##_type p6
#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p
4, \
p5##_type p5, p6##_type p6, p7##_type p7
#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(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
#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(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
// The suffix of the class template implementing the action template.
#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)
P7
#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7) P8
#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6,
\
p7, p8) P9
#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6
, \
p7, p8, p9) P10
// The name of the class template implementing the action template.
#define GMOCK_ACTION_CLASS_(name, value_params)\
GMOCK_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
#define ACTION_TEMPLATE(name, template_params, value_params)\
template <GMOCK_INTERNAL_DECL_##template_params\
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
class GMOCK_ACTION_CLASS_(name, value_params) {\
public:\
GMOCK_ACTION_CLASS_(name, value_params)\
GMOCK_INTERNAL_INIT_##value_params {}\
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 GMOCK_INTERNAL_INIT_##value_params {}\
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;\
GMOCK_INTERNAL_DEFN_##value_params\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(\
new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
}\
GMOCK_INTERNAL_DEFN_##value_params\
};\
template <GMOCK_INTERNAL_DECL_##template_params\
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
inline GMOCK_ACTION_CLASS_(name, value_params)<\
GMOCK_INTERNAL_LIST_##template_params\
GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
GMOCK_INTERNAL_DECL_##value_params) {\
return GMOCK_ACTION_CLASS_(name, value_params)<\
GMOCK_INTERNAL_LIST_##template_params\
GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
GMOCK_INTERNAL_LIST_##value_params);\
}\
template <GMOCK_INTERNAL_DECL_##template_params\
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
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\
GMOCK_ACTION_CLASS_(name, value_params)<\
GMOCK_INTERNAL_LIST_##template_params\
GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
gmock_PerformImpl(\
GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
#define ACTION(name)\ #define ACTION(name)\
class name##Action {\ class name##Action {\
public:\ public:\
name##Action() {}\ name##Action() {}\
template <typename F>\ template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\ class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\ public:\
typedef F function_type;\ typedef F function_type;\
typedef typename ::testing::internal::Function<F>::Result return_type ;\ typedef typename ::testing::internal::Function<F>::Result return_type ;\
typedef typename ::testing::internal::Function<F>::ArgumentTuple\ typedef typename ::testing::internal::Function<F>::ArgumentTuple\
skipping to change at line 1597 skipping to change at line 1479
};\ };\
inline name##Action name() {\ inline name##Action name() {\
return name##Action();\ return name##Action();\
}\ }\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##Action::\ name##Action::gmock_Impl<F>::gmock_PerformImpl(\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P(name, p0)\
template <typename p0##_type>\ template <typename p0##_type>\
class name##ActionP {\ class name##ActionP {\
public:\ public:\
name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\ name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
template <typename F>\ template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\ class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\ public:\
typedef F function_type;\ typedef F function_type;\
skipping to change at line 1646 skipping to change at line 1525
inline name##ActionP<p0##_type> name(p0##_type p0) {\ inline name##ActionP<p0##_type> name(p0##_type p0) {\
return name##ActionP<p0##_type>(p0);\ return name##ActionP<p0##_type>(p0);\
}\ }\
template <typename p0##_type>\ template <typename p0##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP<p0##_type>::\ name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P2(name, p0, p1)\
template <typename p0##_type, typename p1##_type>\ template <typename p0##_type, typename p1##_type>\
class name##ActionP2 {\ class name##ActionP2 {\
public:\ public:\
name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \ name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
p1(gmock_p1) {}\ p1(gmock_p1) {}\
template <typename F>\ template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\ class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\ public:\
skipping to change at line 1700 skipping to change at line 1576
p1##_type p1) {\ p1##_type p1) {\
return name##ActionP2<p0##_type, p1##_type>(p0, p1);\ return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
}\ }\
template <typename p0##_type, typename p1##_type>\ template <typename p0##_type, typename p1##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP2<p0##_type, p1##_type>::\ name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImp
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ l(\
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P3(name, p0, p1, p2)\
template <typename p0##_type, typename p1##_type, typename p2##_type>\ template <typename p0##_type, typename p1##_type, typename p2##_type>\
class name##ActionP3 {\ class name##ActionP3 {\
public:\ public:\
name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \ name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\ p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
template <typename F>\ template <typename F>\
class gmock_Impl : public ::testing::ActionInterface<F> {\ class gmock_Impl : public ::testing::ActionInterface<F> {\
public:\ public:\
skipping to change at line 1756 skipping to change at line 1629
p1##_type p1, p2##_type p2) {\ p1##_type p1, p2##_type p2) {\
return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, 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 p0##_type, typename p1##_type, typename p2##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP3<p0##_type, p1##_type, p2##_type>::\ name##ActionP3<p0##_type, p1##_type, \
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P4(name, p0, p1, p2, p3)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\ typename p3##_type>\
class name##ActionP4 {\ class name##ActionP4 {\
public:\ public:\
name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \ 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##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1 ), \
p2(gmock_p2), p3(gmock_p3) {}\ p2(gmock_p2), p3(gmock_p3) {}\
template <typename F>\ template <typename F>\
skipping to change at line 1821 skipping to change at line 1692
p2, p3);\ p2, p3);\
}\ }\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\ typename p3##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>::\ name##ActionP4<p0##_type, p1##_type, p2##_type, \
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P5(name, p0, p1, p2, p3, p4)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\ typename p3##_type, typename p4##_type>\
class name##ActionP5 {\ class name##ActionP5 {\
public:\ public:\
name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \ name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, \ p2##_type gmock_p2, p3##_type gmock_p3, \
p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \ p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4) {}\ p3(gmock_p3), p4(gmock_p4) {}\
skipping to change at line 1889 skipping to change at line 1758
p4##_type>(p0, p1, p2, p3, p4);\ p4##_type>(p0, p1, p2, p3, p4);\
}\ }\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\ typename p3##_type, typename p4##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type> name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
::\ p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\ typename p3##_type, typename p4##_type, typename p5##_type>\
class name##ActionP6 {\ class name##ActionP6 {\
public:\ public:\
name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \ name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ 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), \ p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\ p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
skipping to change at line 1961 skipping to change at line 1828
}\ }\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\ typename p3##_type, typename p4##_type, typename p5##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p5##_type>::\ p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\ typename p6##_type>\
class name##ActionP7 {\ class name##ActionP7 {\
public:\ public:\
name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \ name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ 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 ), \ p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1 ), \
skipping to change at line 2041 skipping to change at line 1905
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type>\ typename p6##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p5##_type, p6##_type>::\ p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\ typename p6##_type, typename p7##_type>\
class name##ActionP8 {\ class name##ActionP8 {\
public:\ public:\
name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \ name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, \ p5##_type gmock_p5, p6##_type gmock_p6, \
skipping to change at line 2126 skipping to change at line 1987
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type>\ typename p6##_type, typename p7##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p5##_type, p6##_type, p7##_type>::\ p5##_type, p6##_type, \
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\ typename p6##_type, typename p7##_type, typename p8##_type>\
class name##ActionP9 {\ class name##ActionP9 {\
public:\ public:\
name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \ name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
skipping to change at line 2215 skipping to change at line 2074
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type>\ typename p6##_type, typename p7##_type, typename p8##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p5##_type, p6##_type, p7##_type, p8##_type>::\ p5##_type, p6##_type, p7##_type, \
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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)\ #define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \ typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\ typename p9##_type>\
class name##ActionP10 {\ class name##ActionP10 {\
public:\ public:\
name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \ name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
skipping to change at line 2309 skipping to change at line 2166
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \ typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\ typename p9##_type>\
template <typename F>\ template <typename F>\
template <typename arg0_type, typename arg1_type, typename arg2_type, \ template <typename arg0_type, typename arg1_type, typename arg2_type, \
typename arg3_type, typename arg4_type, typename arg5_type, \ typename arg3_type, typename arg4_type, typename arg5_type, \
typename arg6_type, typename arg7_type, typename arg8_type, \ typename arg6_type, typename arg7_type, typename arg8_type, \
typename arg9_type>\ typename arg9_type>\
typename ::testing::internal::Function<F>::Result\ typename ::testing::internal::Function<F>::Result\
name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type , \ name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type , \
p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>::\ p5##_type, p6##_type, p7##_type, p8##_type, \
gmock_Impl<F>::gmock_PerformImpl(const args_type& args, \ p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
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 // 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 // such that we don't have to run 'pump' every time the code is
// updated. // updated.
namespace testing { namespace testing {
namespace internal { // Various overloads for InvokeArgument<N>().
//
// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
// (0-based) argument, which must be a k-ary callable, of the mock
// function, with arguments a1, a2, ..., a_k.
//
// Notes:
//
// 1. The arguments are passed by value by default. If you need to
// pass an argument by reference, wrap it inside ByRef(). For
// example,
//
// InvokeArgument<1>(5, string("Hello"), ByRef(foo))
//
// passes 5 and string("Hello") by value, and passes foo by
// reference.
//
// 2. If the callable takes an argument by reference but ByRef() is
// not used, it will receive the reference to a copy of the value,
// instead of the original value. For example, when the 0-th
// argument of the mock function takes a const string&, the action
//
// InvokeArgument<0>(string("Hello"))
//
// makes a copy of the temporary string("Hello") object and passes a
// reference of the copy, instead of the original temporary object,
// to the callable. This makes it easy for a user to define an
// InvokeArgument action from temporary values and have it performed
// later.
// Saves argument #0 to where the pointer points. ACTION_TEMPLATE(InvokeArgument,
ACTION_P(SaveArg0, pointer) { *pointer = arg0; } HAS_1_TEMPLATE_PARAMS(int, k),
AND_0_VALUE_PARAMS()) {
return internal::CallableHelper<return_type>::Call(
::std::tr1::get<k>(args));
}
// Assigns 'value' to the variable referenced by argument #0. ACTION_TEMPLATE(InvokeArgument,
ACTION_P(SetArg0Referee, value) { HAS_1_TEMPLATE_PARAMS(int, k),
// Ensures that argument #0 is a reference. If you get a compiler AND_1_VALUE_PARAMS(p0)) {
// error on the next line, you are using SetArgReferee<k>(value) in return internal::CallableHelper<return_type>::Call(
// a mock function whose k-th (0-based) argument is not a reference. ::std::tr1::get<k>(args), p0);
GMOCK_COMPILE_ASSERT_(internal::is_reference<arg0_type>::value,
SetArgReferee_must_be_used_with_a_reference_argumen
t);
arg0 = value;
} }
} // namespace internal ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_2_VALUE_PARAMS(p0, p1)) {
return internal::CallableHelper<return_type>::Call(
::std::tr1::get<k>(args), p0, p1);
}
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the ACTION_TEMPLATE(InvokeArgument,
// mock function to *pointer. HAS_1_TEMPLATE_PARAMS(int, k),
template <int k, typename Pointer> AND_3_VALUE_PARAMS(p0, p1, p2)) {
inline internal::WithArgsAction<internal::SaveArg0ActionP<Pointer>, k> return internal::CallableHelper<return_type>::Call(
SaveArg(const Pointer& pointer) { ::std::tr1::get<k>(args), p0, p1, p2);
return WithArg<k>(internal::SaveArg0(pointer));
} }
// Action SetArgReferee<k>(value) assigns 'value' to the variable ACTION_TEMPLATE(InvokeArgument,
// referenced by the k-th (0-based) argument of the mock function. HAS_1_TEMPLATE_PARAMS(int, k),
template <int k, typename Value> AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
inline internal::WithArgsAction<internal::SetArg0RefereeActionP<Value>, k> return internal::CallableHelper<return_type>::Call(
SetArgReferee(const Value& value) { ::std::tr1::get<k>(args), p0, p1, p2, p3);
return WithArg<k>(internal::SetArg0Referee(value));
} }
// Action Throw(exception) can be used in a mock function of any type ACTION_TEMPLATE(InvokeArgument,
// to throw the given exception. Any copyable value can be thrown. HAS_1_TEMPLATE_PARAMS(int, k),
#if GTEST_HAS_EXCEPTIONS AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
ACTION_P(Throw, exception) { throw exception; } return internal::CallableHelper<return_type>::Call(
#endif // GTEST_HAS_EXCEPTIONS ::std::tr1::get<k>(args), p0, p1, p2, p3, p4);
}
ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
return internal::CallableHelper<return_type>::Call(
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);
}
ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
return internal::CallableHelper<return_type>::Call(
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
}
ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
return internal::CallableHelper<return_type>::Call(
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
}
ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
return internal::CallableHelper<return_type>::Call(
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
}
ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)
) {
return internal::CallableHelper<return_type>::Call(
::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
// Various overloads for ReturnNew<T>().
//
// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
// instance of type T, constructed on the heap with constructor arguments
// a1, a2, ..., and a_k. The caller assumes ownership of the returned value
.
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_0_VALUE_PARAMS()) {
return new T();
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_1_VALUE_PARAMS(p0)) {
return new T(p0);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_2_VALUE_PARAMS(p0, p1)) {
return new T(p0, p1);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_3_VALUE_PARAMS(p0, p1, p2)) {
return new T(p0, p1, p2);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
return new T(p0, p1, p2, p3);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
return new T(p0, p1, p2, p3, p4);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
return new T(p0, p1, p2, p3, p4, p5);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
return new T(p0, p1, p2, p3, p4, p5, p6);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
return new T(p0, p1, p2, p3, p4, p5, p6, p7);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
}
ACTION_TEMPLATE(ReturnNew,
HAS_1_TEMPLATE_PARAMS(typename, T),
AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)
) {
return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
 End of changes. 24 change blocks. 
671 lines changed or deleted 695 lines changed or added


 gmock-generated-function-mockers.h   gmock-generated-function-mockers.h 
skipping to change at line 300 skipping to change at line 300
// 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_(arity, constness, Method) \
__) GMOCK_CONCAT_TOKEN_(gmock##constness##arity##_##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_(0, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(); \ return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
} \ } \
::testing::MockSpec<F>& \ ::testing::MockSpec<F>& \
gmock_##Method() constness { \ gmock_##Method() constness { \
return GMOCK_MOCKER_(Method).RegisterOwner(this).With(); \ return GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this).With(); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(0, constness, 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_(1, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1); \ return GMOCK_MOCKER_(1, constness, 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_(1, constness, \
Method).RegisterOwner(this).With(gmock_a1); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(1, constness, 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_(2, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2); \ return GMOCK_MOCKER_(2, constness, 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_a return GMOCK_MOCKER_(2, constness, \
2); \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(2, constness, 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_(3, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3); \ return GMOCK_MOCKER_(3, constness, 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_a return GMOCK_MOCKER_(3, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3); \
gmock_a3); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(3, constness, 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_(4, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
gmock_a4); \ gmock_a3, 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_a return GMOCK_MOCKER_(4, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
gmock_a3, gmock_a4); \ gmock_a4); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(4, constness, 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_(5, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
gmock_a4, gmock_a5); \ gmock_a3, 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_a return GMOCK_MOCKER_(5, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
gmock_a3, gmock_a4, gmock_a5); \ gmock_a4, gmock_a5); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(5, constness, 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_(6, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
gmock_a4, gmock_a5, gmock_a6); \ gmock_a3, 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_a return GMOCK_MOCKER_(6, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6); \ gmock_a4, gmock_a5, gmock_a6); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(6, constness, 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_(7, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
gmock_a4, gmock_a5, gmock_a6, gmock_a7); \ gmock_a3, 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_a return GMOCK_MOCKER_(7, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \ gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(7, constness, 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_(8, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \ gmock_a3, 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_a return GMOCK_MOCKER_(8, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \ gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(8, constness, 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_(9, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9); \ gmock_a3, 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_a return GMOCK_MOCKER_(9, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \ 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_(9, constness, 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_(10, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(Method).Invoke(gmock_a1, gmock_a2, gmock_a3, \ return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2,
gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \ \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a
9, \
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_a return GMOCK_MOCKER_(10, constness, \
2, \ Method).RegisterOwner(this).With(gmock_a1, gmock_a2, gmock_a3, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
9, \
gmock_a10); \ gmock_a10); \
} \ } \
mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(Method) mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(10, constness, 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)
skipping to change at line 704 skipping to change at line 715
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)
// A MockFunction<F> class has one mock method whose type is F. It is
// useful when you just want your test code to emit some messages and
// have Google Mock verify the right messages are sent (and perhaps at
// the right times). For example, if you are exercising code:
//
// Foo(1);
// Foo(2);
// Foo(3);
//
// and want to verify that Foo(1) and Foo(3) both invoke
// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
//
// TEST(FooTest, InvokesBarCorrectly) {
// MyMock mock;
// MockFunction<void(string check_point_name)> check;
// {
// InSequence s;
//
// EXPECT_CALL(mock, Bar("a"));
// EXPECT_CALL(check, Call("1"));
// EXPECT_CALL(check, Call("2"));
// EXPECT_CALL(mock, Bar("a"));
// }
// Foo(1);
// check.Call("1");
// Foo(2);
// check.Call("2");
// Foo(3);
// }
//
// The expectation spec says that the first Bar("a") must happen
// before check point "1", the second Bar("a") must happen after check
// point "2", and nothing should happen between the two check
// points. The explicit check points make it easy to tell which
// Bar("a") is called by which call to Foo().
template <typename F>
class MockFunction;
template <typename R>
class MockFunction<R()> {
public:
MOCK_METHOD0_T(Call, R());
};
template <typename R, typename A0>
class MockFunction<R(A0)> {
public:
MOCK_METHOD1_T(Call, R(A0));
};
template <typename R, typename A0, typename A1>
class MockFunction<R(A0, A1)> {
public:
MOCK_METHOD2_T(Call, R(A0, A1));
};
template <typename R, typename A0, typename A1, typename A2>
class MockFunction<R(A0, A1, A2)> {
public:
MOCK_METHOD3_T(Call, R(A0, A1, A2));
};
template <typename R, typename A0, typename A1, typename A2, typename A3>
class MockFunction<R(A0, A1, A2, A3)> {
public:
MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
};
template <typename R, typename A0, typename A1, typename A2, typename A3,
typename A4>
class MockFunction<R(A0, A1, A2, A3, A4)> {
public:
MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
};
template <typename R, typename A0, typename A1, typename A2, typename A3,
typename A4, typename A5>
class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
public:
MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
};
template <typename R, typename A0, typename A1, typename A2, typename A3,
typename A4, typename A5, typename A6>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
public:
MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
};
template <typename R, typename A0, typename A1, typename A2, typename A3,
typename A4, typename A5, typename A6, typename A7>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
public:
MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
};
template <typename R, typename A0, typename A1, typename A2, typename A3,
typename A4, typename A5, typename A6, typename A7, typename A8>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
public:
MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
};
template <typename R, typename A0, typename A1, typename A2, typename A3,
typename A4, typename A5, typename A6, typename A7, typename A8,
typename A9>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
public:
MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
};
} // 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. 35 change blocks. 
72 lines changed or deleted 186 lines changed or added


 gmock-generated-matchers.h   gmock-generated-matchers.h 
skipping to change at line 48 skipping to change at line 48
#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> #include <gmock/gmock-printers.h>
namespace testing { namespace testing {
namespace internal { namespace internal {
// Implements ElementsAre() and ElementsAreArray(). // The type of the i-th (0-based) field of Tuple.
template <typename Container> #define GMOCK_FIELD_TYPE_(Tuple, i) \
class ElementsAreMatcherImpl : public MatcherInterface<Container> { typename ::std::tr1::tuple_element<i, Tuple>::type
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
// tuple of type Tuple. It has two members:
//
// type: a tuple type whose i-th field is the ki-th field of Tuple.
// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
//
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have
:
//
// type is tuple<int, bool>, and
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
template <class Tuple, int k0 = -1, 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 k9 = -1>
class TupleFields;
// This generic version is used when there are 10 selectors.
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int
k6,
int k7, int k8, int k9>
class TupleFields {
public: public:
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
ner; GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
typedef typename RawContainer::value_type Element; GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
GMOCK_FIELD_TYPE_(Tuple, k9)> type;
static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
}
};
// Constructs the matcher from a sequence of element values or // The following specialization is used for 0 ~ 9 selectors.
// element matchers.
template <typename InputIter> template <class Tuple>
ElementsAreMatcherImpl(InputIter first, size_t count) { class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
matchers_.reserve(count); public:
InputIter it = first; typedef ::std::tr1::tuple<> type;
for (size_t i = 0; i != count; ++i, ++it) { static type GetSelectedFields(const Tuple& t) {
matchers_.push_back(MatcherCast<const Element&>(*it)); using ::std::tr1::get;
} return type();
} }
};
// Returns true iff 'container' matches. template <class Tuple, int k0>
virtual bool Matches(Container container) const { class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
if (container.size() != count()) public:
return false; typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t));
}
};
typename RawContainer::const_iterator container_iter = container.begin( template <class Tuple, int k0, int k1>
); class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
for (size_t i = 0; i != count(); ++container_iter, ++i) { public:
if (!matchers_[i].Matches(*container_iter)) typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
return false; GMOCK_FIELD_TYPE_(Tuple, k1)> type;
} static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t), get<k1>(t));
}
};
return true; template <class Tuple, int k0, int k1, int k2>
class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
public:
typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t), get<k1>(t), get<k2>(t));
} }
};
// Describes what this matcher does. template <class Tuple, int k0, int k1, int k2, int k3>
virtual void DescribeTo(::std::ostream* os) const { class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
if (count() == 0) { public:
*os << "is empty"; typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
} else if (count() == 1) { GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
*os << "has 1 element that "; GMOCK_FIELD_TYPE_(Tuple, k3)> type;
matchers_[0].DescribeTo(os); static type GetSelectedFields(const Tuple& t) {
} else { using ::std::tr1::get;
*os << "has " << Elements(count()) << " where\n"; return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
for (size_t i = 0; i != count(); ++i) {
*os << "element " << i << " ";
matchers_[i].DescribeTo(os);
if (i + 1 < count()) {
*os << ",\n";
}
}
}
} }
};
// Describes what the negation of this matcher does. template <class Tuple, int k0, int k1, int k2, int k3, int k4>
virtual void DescribeNegationTo(::std::ostream* os) const { class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
if (count() == 0) { public:
*os << "is not empty"; typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
return; GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
} GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t))
;
}
};
*os << "does not have " << Elements(count()) << ", or\n"; template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
for (size_t i = 0; i != count(); ++i) { class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
*os << "element " << i << " "; public:
matchers_[i].DescribeNegationTo(os); typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
if (i + 1 < count()) { GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
*os << ", or\n"; GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
} GMOCK_FIELD_TYPE_(Tuple, k5)> type;
} static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t));
} }
};
// Explains why 'container' matches, or doesn't match, this matcher. template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int
virtual void ExplainMatchResultTo(Container container, k6>
::std::ostream* os) const { class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
if (Matches(container)) { public:
// We need to explain why *each* element matches (the obvious typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
// ones can be skipped). GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t), get<k6>(t));
}
};
bool reason_printed = false; template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int
typename RawContainer::const_iterator container_iter = container.begi k6,
n(); int k7>
for (size_t i = 0; i != count(); ++container_iter, ++i) { class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
::std::stringstream ss; public:
matchers_[i].ExplainMatchResultTo(*container_iter, &ss); typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
GMOCK_FIELD_TYPE_(Tuple, k7)> type;
static type GetSelectedFields(const Tuple& t) {
using ::std::tr1::get;
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t), get<k6>(t), get<k7>(t));
}
};
const string s = ss.str(); template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int
if (!s.empty()) { k6,
if (reason_printed) { int k7, int k8>
*os << ",\n"; class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
} public:
*os << "element " << i << " " << s; typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
reason_printed = true; GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
} GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
} GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
} else { GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
// We need to explain why the container doesn't match. static type GetSelectedFields(const Tuple& t) {
const size_t actual_count = container.size(); using ::std::tr1::get;
if (actual_count != count()) { return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
// The element count doesn't match. If the container is get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
// empty, there's no need to explain anything as Google Mock }
// already prints the empty container. Otherwise we just need };
// to show how many elements there actually are.
if (actual_count != 0) {
*os << "has " << Elements(actual_count);
}
return;
}
// The container has the right size but at least one element #undef GMOCK_FIELD_TYPE_
// doesn't match expectation. We need to find this element and
// explain why it doesn't match.
typename RawContainer::const_iterator container_iter = container.begi
n();
for (size_t i = 0; i != count(); ++container_iter, ++i) {
if (matchers_[i].Matches(*container_iter)) {
continue;
}
*os << "element " << i << " doesn't match"; // Implements the Args() matcher.
template <class ArgsTuple, int k0 = -1, 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 k9 = -1>
class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
public:
// ArgsTuple may have top-level const or reference modifiers.
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(ArgsTuple)) RawArgsTu
ple;
typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4,
k5,
k6, k7, k8, k9>::type SelectedArgs;
typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
::std::stringstream ss; template <typename InnerMatcher>
matchers_[i].ExplainMatchResultTo(*container_iter, &ss); explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
const string s = ss.str(); : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher))
if (!s.empty()) { {}
*os << " (" << s << ")";
} virtual bool Matches(ArgsTuple args) const {
return; return inner_matcher_.Matches(GetSelectedArgs(args));
} }
}
virtual void DescribeTo(::std::ostream* os) const {
PrintIndices(os);
inner_matcher_.DescribeTo(os);
}
virtual void DescribeNegationTo(::std::ostream* os) const {
PrintIndices(os);
inner_matcher_.DescribeNegationTo(os);
}
virtual void ExplainMatchResultTo(ArgsTuple args,
::std::ostream* os) const {
inner_matcher_.ExplainMatchResultTo(GetSelectedArgs(args), os);
} }
private: private:
static Message Elements(size_t count) { static SelectedArgs GetSelectedArgs(ArgsTuple args) {
return Message() << count << (count == 1 ? " element" : " elements"); return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
k9>::GetSelectedFields(args);
} }
size_t count() const { return matchers_.size(); } // Prints the indices of the selected fields.
std::vector<Matcher<const Element&> > matchers_; static void PrintIndices(::std::ostream* os) {
}; *os << "are a tuple whose fields (";
const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
for (int i = 0; i < 10; i++) {
if (indices[i] < 0)
break;
// Implements ElementsAre() of 0-10 arguments. if (i >= 1)
*os << ", ";
class ElementsAreMatcher0 { *os << "#" << indices[i];
public: }
ElementsAreMatcher0() {} *os << ") ";
}
template <typename Container> const MonomorphicInnerMatcher inner_matcher_;
operator Matcher<Container>() const { };
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer;
typedef typename RawContainer::value_type Element;
const Matcher<const Element&>* const matchers = NULL; template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 0)); int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
int k8 = -1, int k9 = -1>
class ArgsMatcher {
public:
explicit ArgsMatcher(const InnerMatcher& inner_matcher)
: inner_matcher_(inner_matcher) {}
template <typename ArgsTuple>
operator Matcher<ArgsTuple>() const {
return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k
5,
k6, k7, k8, k9>(inner_matcher_));
} }
const InnerMatcher inner_matcher_;
}; };
// Implements ElementsAre() of 1-10 arguments.
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::value_
type
const Matcher<const Element&> matchers[] = { Element;
MatcherCast<const Element&>(e1_),
};
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 1)); // Nokia's Symbian Compiler has a nasty bug where the object put
// in a one-element local array is not destructed when the array
// goes out of scope. This leads to obvious badness as we've
// added the linked_ptr in it to our other linked_ptrs list.
// Hence we implement ElementsAreMatcher1 specially to avoid using
// a local array.
const Matcher<const Element&> matcher =
MatcherCast<const Element&>(e1_);
return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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));
} }
private: private:
skipping to change at line 256 skipping to change at line 357
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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 283 skipping to change at line 385
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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 312 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>
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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_),
}; };
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5)); return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5));
skipping to change at line 345 skipping to change at line 449
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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 380 skipping to change at line 485
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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 417 skipping to change at line 523
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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_),
MatcherCast<const Element&>(e8_), MatcherCast<const Element&>(e8_),
skipping to change at line 457 skipping to change at line 564
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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_),
MatcherCast<const Element&>(e8_), MatcherCast<const Element&>(e8_),
skipping to change at line 499 skipping to change at line 607
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)) typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer; RawContainer;
typedef typename RawContainer::value_type Element; typedef typename internal::StlContainerView<RawContainer>::type::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_),
MatcherCast<const Element&>(e8_), MatcherCast<const Element&>(e8_),
skipping to change at line 530 skipping to change at line 639
const T3& e3_; const T3& e3_;
const T4& e4_; const T4& e4_;
const T5& e5_; const T5& e5_;
const T6& e6_; const T6& e6_;
const T7& e7_; const T7& e7_;
const T8& e8_; const T8& e8_;
const T9& e9_; const T9& e9_;
const T10& e10_; const T10& e10_;
}; };
// Implements ElementsAreArray(). } // namespace internal
template <typename T>
class ElementsAreArrayMatcher {
public:
ElementsAreArrayMatcher(const T* first, size_t count) :
first_(first), count_(count) {}
template <typename Container> // Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
operator Matcher<Container>() const { // fields of it matches a_matcher. C++ doesn't support default
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) // arguments for function templates, so we have to overload it.
RawContainer; template <typename InnerMatcher>
typedef typename RawContainer::value_type Element; inline internal::ArgsMatcher<InnerMatcher>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher>(matcher);
}
return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_ template <int k1, typename InnerMatcher>
)); inline internal::ArgsMatcher<InnerMatcher, k1>
} Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
}
private: template <int k1, int k2, typename InnerMatcher>
const T* const first_; inline internal::ArgsMatcher<InnerMatcher, k1, k2>
const size_t count_; Args(const InnerMatcher& matcher) {
}; return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
}
} // namespace internal template <int k1, int k2, int k3, typename InnerMatcher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
}
template <int k1, int k2, int k3, int k4, typename InnerMatcher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
}
template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
}
template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMat
cher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matche
r);
}
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
typename InnerMatcher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
k7>(matcher);
}
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
typename InnerMatcher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
k8>(matcher);
}
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
int k9, typename InnerMatcher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
k9>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8
,
k9>(matcher);
}
template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
int k9, int k10, typename InnerMatcher>
inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
k9,
k10>
Args(const InnerMatcher& matcher) {
return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8
,
k9, k10>(matcher);
}
// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with // ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
// (n + 1) elements, where the i-th element in the container must // (n + 1) elements, where the i-th element in the container must
// match the i-th argument in the list. Each argument of // match the i-th argument in the list. Each argument of
// ElementsAre() can be either a value or a matcher. We support up to // ElementsAre() can be either a value or a matcher. We support up to
// 10 arguments. // 10 arguments.
// //
// NOTE: Since ElementsAre() cares about the order of the elements, it // NOTE: Since ElementsAre() cares about the order of the elements, it
// must not be used with containers whose elements's order is // must not be used with containers whose elements's order is
// undefined (e.g. hash_map). // undefined (e.g. hash_map).
skipping to change at line 832 skipping to change at line 998
// that C++ doesn't yet allow function-local types to be used to // that C++ doesn't yet allow function-local types to be used to
// instantiate templates. The up-coming C++0x standard will fix this. // instantiate templates. The up-coming C++0x standard will fix this.
// Once that's done, we'll consider supporting using MATCHER*() inside // Once that's done, we'll consider supporting using MATCHER*() inside
// a function. // a function.
// //
// MORE INFORMATION: // MORE INFORMATION:
// //
// To learn more about using these macros, please search for 'MATCHER' // To learn more about using these macros, please search for 'MATCHER'
// on http://code.google.com/p/googlemock/wiki/CookBook. // 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)\ #define MATCHER(name, description)\
class name##Matcher {\ class name##Matcher {\
public:\ public:\
template <typename arg_type>\ template <typename arg_type>\
class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
public:\ public:\
gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\ gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\
: gmock_interp_(gmock_interp) {}\ : gmock_interp_(gmock_interp) {}\
virtual bool Matches(arg_type arg) const;\ virtual bool Matches(arg_type arg) const;\
virtual void DescribeTo(::std::ostream* gmock_os) const {\ virtual void DescribeTo(::std::ostream* gmock_os) const {\
skipping to change at line 1576 skipping to change at line 1700
}\ }\
template <typename p0##_type, typename p1##_type, typename p2##_type, \ template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \ typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type, \ typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type>\ typename p9##_type>\
template <typename arg_type>\ template <typename arg_type>\
bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \ bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>::\ p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>::\
gmock_Impl<arg_type>::Matches(arg_type arg) const 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. 45 change blocks. 
246 lines changed or deleted 348 lines changed or added


 gmock-generated-nice-strict.h   gmock-generated-nice-strict.h 
skipping to change at line 73 skipping to change at line 73
#include <gmock/internal/gmock-port.h> #include <gmock/internal/gmock-port.h>
namespace testing { namespace testing {
template <class MockClass> template <class MockClass>
class NiceMock : public MockClass { class NiceMock : public MockClass {
public: public:
// We don't factor out the constructor body to a common method, as // We don't factor out the constructor body to a common method, as
// we have to avoid a possible clash with members of MockClass. // we have to avoid a possible clash with members of MockClass.
NiceMock() { NiceMock() {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
// C++ doesn't (yet) allow inheritance of constructors, so we have // C++ doesn't (yet) allow inheritance of constructors, so we have
// to define it for each arity. // to define it for each arity.
template <typename A1> template <typename A1>
explicit NiceMock(const A1& a1) : MockClass(a1) { explicit NiceMock(const A1& a1) : MockClass(a1) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2> template <typename A1, typename A2>
NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) { NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3> template <typename A1, typename A2, typename A3>
NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3 ) { NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3 ) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4> template <typename A1, typename A2, typename A3, typename A4>
NiceMock(const A1& a1, const A2& a2, const A3& a3, NiceMock(const A1& a1, const A2& a2, const A3& a3,
const A4& a4) : MockClass(a1, a2, a3, a4) { const A4& a4) : MockClass(a1, a2, a3, a4) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 > template <typename A1, typename A2, typename A3, typename A4, typename A5 >
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5) : MockClass(a1, a2, a3, a4, a5) { const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6> typename A6>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) { const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7> typename A6, typename A7>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5, const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
a6, a7) { a6, a7) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7, typename A8> typename A6, typename A7, typename A8>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a 1, const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a 1,
a2, a3, a4, a5, a6, a7, a8) { a2, a3, a4, a5, a6, a7, a8) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7, typename A8, typename A9> typename A6, typename A7, typename A8, typename A9>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A5& a5, const A6& a6, const A7& a7, const A8& a8,
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) { const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7, typename A8, typename A9, typename A10> typename A6, typename A7, typename A8, typename A9, typename A10>
NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this) ::testing::Mock::AllowUninterestingCalls(
); internal::implicit_cast<MockClass*>(this));
} }
virtual ~NiceMock() { virtual ~NiceMock() {
Mock::UnregisterCallReaction(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::UnregisterCallReaction(
; internal::implicit_cast<MockClass*>(this));
} }
}; };
template <class MockClass> template <class MockClass>
class StrictMock : public MockClass { class StrictMock : public MockClass {
public: public:
// We don't factor out the constructor body to a common method, as // We don't factor out the constructor body to a common method, as
// we have to avoid a possible clash with members of MockClass. // we have to avoid a possible clash with members of MockClass.
StrictMock() { StrictMock() {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1> template <typename A1>
explicit StrictMock(const A1& a1) : MockClass(a1) { explicit StrictMock(const A1& a1) : MockClass(a1) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2> template <typename A1, typename A2>
StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) { StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3> template <typename A1, typename A2, typename A3>
StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) { StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4> template <typename A1, typename A2, typename A3, typename A4>
StrictMock(const A1& a1, const A2& a2, const A3& a3, StrictMock(const A1& a1, const A2& a2, const A3& a3,
const A4& a4) : MockClass(a1, a2, a3, a4) { const A4& a4) : MockClass(a1, a2, a3, a4) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 > template <typename A1, typename A2, typename A3, typename A4, typename A5 >
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5) : MockClass(a1, a2, a3, a4, a5) { const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6> typename A6>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) { const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7> typename A6, typename A7>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5, const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
a6, a7) { a6, a7) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7, typename A8> typename A6, typename A7, typename A8>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a 1, const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a 1,
a2, a3, a4, a5, a6, a7, a8) { a2, a3, a4, a5, a6, a7, a8) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7, typename A8, typename A9> typename A6, typename A7, typename A8, typename A9>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A5& a5, const A6& a6, const A7& a7, const A8& a8,
const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) { const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
template <typename A1, typename A2, typename A3, typename A4, typename A5 , template <typename A1, typename A2, typename A3, typename A4, typename A5 ,
typename A6, typename A7, typename A8, typename A9, typename A10> typename A6, typename A7, typename A8, typename A9, typename A10>
StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::FailUninterestingCalls(
; internal::implicit_cast<MockClass*>(this));
} }
virtual ~StrictMock() { virtual ~StrictMock() {
Mock::UnregisterCallReaction(internal::implicit_cast<MockClass*>(this)) ::testing::Mock::UnregisterCallReaction(
; internal::implicit_cast<MockClass*>(this));
} }
}; };
// The following specializations catch some (relatively more common) // The following specializations catch some (relatively more common)
// user errors of nesting nice and strict mocks. They do NOT catch // user errors of nesting nice and strict mocks. They do NOT catch
// all possible errors. // all possible errors.
// These specializations are declared but not defined, as NiceMock and // These specializations are declared but not defined, as NiceMock and
// StrictMock cannot be nested. // StrictMock cannot be nested.
template <typename MockClass> template <typename MockClass>
 End of changes. 24 change blocks. 
48 lines changed or deleted 48 lines changed or added


 gmock-internal-utils.h   gmock-internal-utils.h 
skipping to change at line 102 skipping to change at line 102
typename ::testing::internal::RemoveReference<T>::type typename ::testing::internal::RemoveReference<T>::type
// Removes const from a type if it is a const type, otherwise leaves // Removes const from a type if it is a const type, otherwise leaves
// it unchanged. This is the same as tr1::remove_const, which is not // it unchanged. This is the same as tr1::remove_const, which is not
// widely available yet. // widely available yet.
template <typename T> template <typename T>
struct RemoveConst { typedef T type; }; // NOLINT struct RemoveConst { typedef T type; }; // NOLINT
template <typename T> template <typename T>
struct RemoveConst<const T> { typedef T type; }; // NOLINT struct RemoveConst<const T> { typedef T type; }; // NOLINT
// MSVC 8.0 has a bug which causes the above definition to fail to
// remove the const in 'const int[3]'. The following specialization
// works around the bug. However, it causes trouble with gcc and thus
// needs to be conditionally compiled.
#ifdef _MSC_VER
template <typename T, size_t N>
struct RemoveConst<T[N]> {
typedef typename RemoveConst<T>::type type[N];
};
#endif // _MSC_VER
// A handy wrapper around RemoveConst that works when the argument // A handy wrapper around RemoveConst that works when the argument
// T depends on template parameters. // T depends on template parameters.
#define GMOCK_REMOVE_CONST_(T) \ #define GMOCK_REMOVE_CONST_(T) \
typename ::testing::internal::RemoveConst<T>::type typename ::testing::internal::RemoveConst<T>::type
// Adds reference to a type if it is not a reference type, // Adds reference to a type if it is not a reference type,
// otherwise leaves it unchanged. This is the same as // otherwise leaves it unchanged. This is the same as
// tr1::add_reference, which is not widely available yet. // tr1::add_reference, which is not widely available yet.
template <typename T> template <typename T>
struct AddReference { typedef T& type; }; // NOLINT struct AddReference { typedef T& type; }; // NOLINT
skipping to change at line 213 skipping to change at line 224
sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#else #else
static const bool value = static const bool value =
sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
#endif // _MSV_VER #endif // _MSV_VER
}; };
template <typename From, typename To> template <typename From, typename To>
const bool ImplicitlyConvertible<From, To>::value; const bool ImplicitlyConvertible<From, To>::value;
// Symbian compilation can be done with wchar_t being either a native
// type or a typedef. Using Google Mock with OpenC without wchar_t
// should require the definition of _STLP_NO_WCHAR_T.
//
// MSVC treats wchar_t as a native type usually, but treats it as the
// same as unsigned short when the compiler option /Zc:wchar_t- is
// specified. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t
// is a native type.
#if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \
(defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
// wchar_t is a typedef.
#else
#define GMOCK_WCHAR_T_IS_NATIVE_ 1
#endif
// 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.
//
// Still, Google Mock is designed to work even if the user uses signed
// wchar_t or unsigned wchar_t (obviously, assuming the compiler
// supports them).
//
// To gcc,
// wchar_t == signed wchar_t != unsigned wchar_t == unsigned int
#ifdef __GNUC__
#define GMOCK_HAS_SIGNED_WCHAR_T_ 1 // signed/unsigned wchar_t are valid t
ypes.
#endif
// In what follows, we use the term "kind" to indicate whether a type
// is bool, an integer type (excluding bool), a floating-point type,
// or none of them. This categorization is useful for determining
// when a matcher argument type can be safely converted to another
// type in the implementation of SafeMatcherCast.
enum TypeKind {
kBool, kInteger, kFloatingPoint, kOther
};
// KindOf<T>::value is the kind of type T.
template <typename T> struct KindOf {
enum { value = kOther }; // The default kind.
};
// This macro declares that the kind of 'type' is 'kind'.
#define GMOCK_DECLARE_KIND_(type, kind) \
template <> struct KindOf<type> { enum { value = kind }; }
GMOCK_DECLARE_KIND_(bool, kBool);
// All standard integer types.
GMOCK_DECLARE_KIND_(char, kInteger);
GMOCK_DECLARE_KIND_(signed char, kInteger);
GMOCK_DECLARE_KIND_(unsigned char, kInteger);
GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(int, kInteger);
GMOCK_DECLARE_KIND_(unsigned int, kInteger);
GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
#if GMOCK_WCHAR_T_IS_NATIVE_
GMOCK_DECLARE_KIND_(wchar_t, kInteger);
#endif
// Non-standard integer types.
GMOCK_DECLARE_KIND_(Int64, kInteger);
GMOCK_DECLARE_KIND_(UInt64, kInteger);
// All standard floating-point types.
GMOCK_DECLARE_KIND_(float, kFloatingPoint);
GMOCK_DECLARE_KIND_(double, kFloatingPoint);
GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
#undef GMOCK_DECLARE_KIND_
// Evaluates to the kind of 'type'.
#define GMOCK_KIND_OF_(type) \
static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value)
// Evaluates to true iff integer type T is signed.
#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
// is true iff arithmetic type From can be losslessly converted to
// arithmetic type To.
//
// It's the user's responsibility to ensure that both From and To are
// raw (i.e. has no CV modifier, is not a pointer, and is not a
// reference) built-in arithmetic types, kFromKind is the kind of
// From, and kToKind is the kind of To; the value is
// implementation-defined when the above pre-condition is violated.
template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
struct LosslessArithmeticConvertibleImpl : public false_type {};
// Converting bool to bool is lossless.
template <>
struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>
: public true_type {}; // NOLINT
// Converting bool to any integer type is lossless.
template <typename To>
struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>
: public true_type {}; // NOLINT
// Converting bool to any floating-point type is lossless.
template <typename To>
struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>
: public true_type {}; // NOLINT
// Converting an integer to bool is lossy.
template <typename From>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
: public false_type {}; // NOLINT
// Converting an integer to another non-bool integer is lossless iff
// the target type's range encloses the source type's range.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
: public bool_constant<
// When converting from a smaller size to a larger size, we are
// fine as long as we are not converting from signed to unsigned.
((sizeof(From) < sizeof(To)) &&
(!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
// When converting between the same size, the signedness must match.
((sizeof(From) == sizeof(To)) &&
(GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {}; // NOLINT
#undef GMOCK_IS_SIGNED_
// Converting an integer to a floating-point type may be lossy, since
// the format of a floating-point number is implementation-defined.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To
>
: public false_type {}; // NOLINT
// Converting a floating-point to bool is lossy.
template <typename From>
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
: public false_type {}; // NOLINT
// Converting a floating-point to an integer is lossy.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To
>
: public false_type {}; // NOLINT
// Converting a floating-point to another floating-point is lossless
// iff the target type is at least as big as the source type.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<
kFloatingPoint, From, kFloatingPoint, To>
: public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
// LosslessArithmeticConvertible<From, To>::value is true iff arithmetic
// type From can be losslessly converted to arithmetic type To.
//
// It's the user's responsibility to ensure that both From and To are
// raw (i.e. has no CV modifier, is not a pointer, and is not a
// reference) built-in arithmetic types; the value is
// implementation-defined when the above pre-condition is violated.
template <typename From, typename To>
struct LosslessArithmeticConvertible
: public LosslessArithmeticConvertibleImpl<
GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {}; // NOLINT
// IsAProtocolMessage<T>::value is a compile-time bool constant that's // IsAProtocolMessage<T>::value is a compile-time bool constant that's
// true iff T is type ProtocolMessage, proto2::Message, or a subclass // true iff T is type ProtocolMessage, proto2::Message, or a subclass
// of those. // of those.
template <typename T> template <typename T>
struct IsAProtocolMessage { struct IsAProtocolMessage
static const bool value = : public bool_constant<
ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value || ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value ||
ImplicitlyConvertible<const T*, const ::proto2::Message*>::value; ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> {
}; };
template <typename T>
const bool IsAProtocolMessage<T>::value;
// When the compiler sees expression IsContainerTest<C>(0), the first // When the compiler sees expression IsContainerTest<C>(0), the first
// overload of IsContainerTest will be picked if C is an STL-style // overload of IsContainerTest will be picked if C is an STL-style
// container class (since C::const_iterator* is a valid type and 0 can // container class (since C::const_iterator* is a valid type and 0 can
// be converted to it), while the second overload will be picked // be converted to it), while the second overload will be picked
// otherwise (since C::const_iterator will be an invalid type in this // otherwise (since C::const_iterator will be an invalid type in this
// case). Therefore, we can determine whether C is a container class // case). Therefore, we can determine whether C is a container class
// by checking the type of IsContainerTest<C>(0). The value of the // by checking the type of IsContainerTest<C>(0). The value of the
// expression is insignificant. // expression is insignificant.
typedef int IsContainer; typedef int IsContainer;
skipping to change at line 304 skipping to change at line 477
// Valid values for the --gmock_verbose flag. // Valid values for the --gmock_verbose flag.
// All logs (informational and warnings) are printed. // All logs (informational and warnings) are printed.
const char kInfoVerbosity[] = "info"; const char kInfoVerbosity[] = "info";
// Only warnings are printed. // Only warnings are printed.
const char kWarningVerbosity[] = "warning"; const char kWarningVerbosity[] = "warning";
// No logs are printed. // No logs are printed.
const char kErrorVerbosity[] = "error"; const char kErrorVerbosity[] = "error";
// Returns true iff a log with the given severity is visible according
// to the --gmock_verbose flag.
bool LogIsVisible(LogSeverity severity);
// Prints the given message to stdout iff 'severity' >= the level // Prints the given message to stdout iff 'severity' >= the level
// specified by the --gmock_verbose flag. If stack_frames_to_skip >= // specified by the --gmock_verbose flag. If stack_frames_to_skip >=
// 0, also prints the stack trace excluding the top // 0, also prints the stack trace excluding the top
// stack_frames_to_skip frames. In opt mode, any positive // stack_frames_to_skip frames. In opt mode, any positive
// stack_frames_to_skip is treated as 0, since we don't know which // stack_frames_to_skip is treated as 0, since we don't know which
// function calls will be inlined by the compiler and need to be // function calls will be inlined by the compiler and need to be
// conservative. // conservative.
void Log(LogSeverity severity, const string& message, int stack_frames_to_s kip); void Log(LogSeverity severity, const string& message, int stack_frames_to_s kip);
// The universal value printer (public/gmock-printers.h) needs this // TODO(wan@google.com): group all type utilities together.
// to declare an unused << operator in the global namespace.
struct Unused {};
// Type traits. // Type traits.
// is_reference<T>::value is non-zero iff T is a reference type. // is_reference<T>::value is non-zero iff T is a reference type.
template <typename T> struct is_reference : public false_type {}; template <typename T> struct is_reference : public false_type {};
template <typename T> struct is_reference<T&> : public true_type {}; template <typename T> struct is_reference<T&> : public true_type {};
// type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type. // type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type.
template <typename T1, typename T2> struct type_equals : public false_type {}; template <typename T1, typename T2> struct type_equals : public false_type {};
template <typename T> struct type_equals<T, T> : public true_type {}; template <typename T> struct type_equals<T, T> : public true_type {};
// remove_reference<T>::type removes the reference from type T, if any. // remove_reference<T>::type removes the reference from type T, if any.
template <typename T> struct remove_reference { typedef T type; }; template <typename T> struct remove_reference { typedef T type; }; // NOLI
template <typename T> struct remove_reference<T&> { typedef T type; }; NT
template <typename T> struct remove_reference<T&> { typedef T type; }; // N
OLINT
// Invalid<T>() returns an invalid value of type T. This is useful // Invalid<T>() returns an invalid value of type T. This is useful
// when a value of type T is needed for compilation, but the statement // when a value of type T is needed for compilation, but the statement
// will not really be executed (or we don't care if the statement // will not really be executed (or we don't care if the statement
// crashes). // crashes).
template <typename T> template <typename T>
inline T Invalid() { inline T Invalid() {
return *static_cast<typename remove_reference<T>::type*>(NULL); return *static_cast<typename remove_reference<T>::type*>(NULL);
} }
template <> template <>
inline void Invalid<void>() {} inline void Invalid<void>() {}
// Utilities for native arrays.
// ArrayEq() compares two k-dimensional native arrays using the
// elements' operator==, where k can be any integer >= 0. When k is
// 0, ArrayEq() degenerates into comparing a single pair of values.
template <typename T, typename U>
bool ArrayEq(const T* lhs, size_t size, const U* rhs);
// This generic version is used when k is 0.
template <typename T, typename U>
inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
// This overload is used when k >= 1.
template <typename T, typename U, size_t N>
inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
return internal::ArrayEq(lhs, N, rhs);
}
// This helper reduces code bloat. If we instead put its logic inside
// the previous ArrayEq() function, arrays with different sizes would
// lead to different copies of the template code.
template <typename T, typename U>
bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
for (size_t i = 0; i != size; i++) {
if (!internal::ArrayEq(lhs[i], rhs[i]))
return false;
}
return true;
}
// Finds the first element in the iterator range [begin, end) that
// equals elem. Element may be a native array type itself.
template <typename Iter, typename Element>
Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
for (Iter it = begin; it != end; ++it) {
if (internal::ArrayEq(*it, elem))
return it;
}
return end;
}
// CopyArray() copies a k-dimensional native array using the elements'
// operator=, where k can be any integer >= 0. When k is 0,
// CopyArray() degenerates into copying a single value.
template <typename T, typename U>
void CopyArray(const T* from, size_t size, U* to);
// This generic version is used when k is 0.
template <typename T, typename U>
inline void CopyArray(const T& from, U* to) { *to = from; }
// This overload is used when k >= 1.
template <typename T, typename U, size_t N>
inline void CopyArray(const T(&from)[N], U(*to)[N]) {
internal::CopyArray(from, N, *to);
}
// This helper reduces code bloat. If we instead put its logic inside
// the previous CopyArray() function, arrays with different sizes
// would lead to different copies of the template code.
template <typename T, typename U>
void CopyArray(const T* from, size_t size, U* to) {
for (size_t i = 0; i != size; i++) {
internal::CopyArray(from[i], to + i);
}
}
// The relation between an NativeArray object (see below) and the
// native array it represents.
enum RelationToSource {
kReference, // The NativeArray references the native array.
kCopy // The NativeArray makes a copy of the native array and
// owns the copy.
};
// Adapts a native array to a read-only STL-style container. Instead
// of the complete STL container concept, this adaptor only implements
// members useful for Google Mock's container matchers. New members
// should be added as needed. To simplify the implementation, we only
// support Element being a raw type (i.e. having no top-level const or
// reference modifier). It's the client's responsibility to satisfy
// this requirement. Element can be an array type itself (hence
// multi-dimensional arrays are supported).
template <typename Element>
class NativeArray {
public:
// STL-style container typedefs.
typedef Element value_type;
typedef const Element* const_iterator;
// Constructs from a native array.
NativeArray(const Element* array, size_t count, RelationToSource relation
) {
Init(array, count, relation);
}
// Copy constructor.
NativeArray(const NativeArray& rhs) {
Init(rhs.array_, rhs.size_, rhs.relation_to_source_);
}
~NativeArray() {
// Ensures that the user doesn't instantiate NativeArray with a
// const or reference type.
testing::StaticAssertTypeEq<Element,
GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Element))>();
if (relation_to_source_ == kCopy)
delete[] array_;
}
// STL-style container methods.
size_t size() const { return size_; }
const_iterator begin() const { return array_; }
const_iterator end() const { return array_ + size_; }
bool operator==(const NativeArray& rhs) const {
return size() == rhs.size() &&
ArrayEq(begin(), size(), rhs.begin());
}
private:
// Not implemented as we don't want to support assignment.
void operator=(const NativeArray& rhs);
// Initializes this object; makes a copy of the input array if
// 'relation' is kCopy.
void Init(const Element* array, size_t size, RelationToSource relation) {
if (relation == kReference) {
array_ = array;
} else {
Element* const copy = new Element[size];
CopyArray(array, size, copy);
array_ = copy;
}
size_ = size;
relation_to_source_ = relation;
}
const Element* array_;
size_t size_;
RelationToSource relation_to_source_;
};
// Given a raw type (i.e. having no top-level reference or const
// modifier) RawContainer that's either an STL-style container or a
// native array, class StlContainerView<RawContainer> has the
// following members:
//
// - type is a type that provides an STL-style container view to
// (i.e. implements the STL container concept for) RawContainer;
// - const_reference is a type that provides a reference to a const
// RawContainer;
// - ConstReference(raw_container) returns a const reference to an STL-st
yle
// container view to raw_container, which is a RawContainer.
// - Copy(raw_container) returns an STL-style container view of a
// copy of raw_container, which is a RawContainer.
//
// This generic version is used when RawContainer itself is already an
// STL-style container.
template <class RawContainer>
class StlContainerView {
public:
typedef RawContainer type;
typedef const type& const_reference;
static const_reference ConstReference(const RawContainer& container) {
// Ensures that RawContainer is not a const type.
testing::StaticAssertTypeEq<RawContainer,
GMOCK_REMOVE_CONST_(RawContainer)>();
return container;
}
static type Copy(const RawContainer& container) { return container; }
};
// This specialization is used when RawContainer is a native array type.
template <typename Element, size_t N>
class StlContainerView<Element[N]> {
public:
typedef GMOCK_REMOVE_CONST_(Element) RawElement;
typedef internal::NativeArray<RawElement> type;
// NativeArray<T> can represent a native array either by value or by
// reference (selected by a constructor argument), so 'const type'
// can be used to reference a const native array. We cannot
// 'typedef const type& const_reference' here, as that would mean
// ConstReference() has to return a reference to a local variable.
typedef const type const_reference;
static const_reference ConstReference(const Element (&array)[N]) {
// Ensures that Element is not a const type.
testing::StaticAssertTypeEq<Element, RawElement>();
#if GTEST_OS_SYMBIAN
// The Nokia Symbian compiler confuses itself in template instantiation
// for this call without the cast to Element*:
// function call '[testing::internal::NativeArray<char *>].NativeArray(
// {lval} const char *[4], long, testing::internal::RelationToSourc
e)'
// does not match
// 'testing::internal::NativeArray<char *>::NativeArray(
// char *const *, unsigned int, testing::internal::RelationToSource
)'
// (instantiating: 'testing::internal::ContainsMatcherImpl
// <const char * (&)[4]>::Matches(const char * (&)[4]) const')
// (instantiating: 'testing::internal::StlContainerView<char *[4]>::
// ConstReference(const char * (&)[4])')
// (and though the N parameter type is mismatched in the above explicit
// conversion of it doesn't help - only the conversion of the array).
return type(const_cast<Element*>(&array[0]), N, kReference);
#else
return type(array, N, kReference);
#endif // GTEST_OS_SYMBIAN
}
static type Copy(const Element (&array)[N]) {
#if GTEST_OS_SYMBIAN
return type(const_cast<Element*>(&array[0]), N, kCopy);
#else
return type(array, N, kCopy);
#endif // GTEST_OS_SYMBIAN
}
};
// This specialization is used when RawContainer is a native array
// represented as a (pointer, size) tuple.
template <typename ElementPointer, typename Size>
class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {
public:
typedef GMOCK_REMOVE_CONST_(
typename internal::PointeeOf<ElementPointer>::type) RawElement;
typedef internal::NativeArray<RawElement> type;
typedef const type const_reference;
static const_reference ConstReference(
const ::std::tr1::tuple<ElementPointer, Size>& array) {
using ::std::tr1::get;
return type(get<0>(array), get<1>(array), kReference);
}
static type Copy(const ::std::tr1::tuple<ElementPointer, Size>& array) {
using ::std::tr1::get;
return type(get<0>(array), get<1>(array), kCopy);
}
};
// The following specialization prevents the user from instantiating
// StlContainer with a reference type.
template <typename T> class StlContainerView<T&>;
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
 End of changes. 8 change blocks. 
11 lines changed or deleted 438 lines changed or added


 gmock-matchers.h   gmock-matchers.h 
skipping to change at line 42 skipping to change at line 42
// 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 <algorithm>
#include <limits>
#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 93 skipping to change at line 94
// can produce good error messages. // can produce good error messages.
virtual void DescribeNegationTo(::std::ostream* os) const { virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "not ("; *os << "not (";
DescribeTo(os); DescribeTo(os);
*os << ")"; *os << ")";
} }
// Explains why x matches, or doesn't match, the matcher. Override // Explains why x matches, or doesn't match, the matcher. Override
// this to provide any additional information that helps a user // this to provide any additional information that helps a user
// understand the match result. // understand the match result.
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { virtual void ExplainMatchResultTo(T /* x */, ::std::ostream* /* os */) co nst {
// By default, nothing more needs to be explained, as Google Mock // By default, nothing more needs to be explained, as Google Mock
// has already printed the value of x when this function is // has already printed the value of x when this function is
// called. // called.
} }
}; };
namespace internal { namespace internal {
// An internal class for implementing Matcher<T>, which will derive // An internal class for implementing Matcher<T>, which will derive
// from it. We put functionalities common to all Matcher<T> // from it. We put functionalities common to all Matcher<T>
skipping to change at line 149 skipping to change at line 150
// than the default constructor. // than the default constructor.
// //
// If performance becomes a problem, we should see if using // If performance becomes a problem, we should see if using
// shared_ptr helps. // shared_ptr helps.
::testing::internal::linked_ptr<const MatcherInterface<T> > impl_; ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_;
}; };
// The default implementation of ExplainMatchResultTo() for // The default implementation of ExplainMatchResultTo() for
// polymorphic matchers. // polymorphic matchers.
template <typename PolymorphicMatcherImpl, typename T> template <typename PolymorphicMatcherImpl, typename T>
inline void ExplainMatchResultTo(const PolymorphicMatcherImpl& impl, const inline void ExplainMatchResultTo(const PolymorphicMatcherImpl& /* impl */,
T& x, const T& /* x */,
::std::ostream* os) { ::std::ostream* /* os */) {
// By default, nothing more needs to be said, as Google Mock already // By default, nothing more needs to be said, as Google Mock already
// prints the value of x elsewhere. // prints the value of x elsewhere.
} }
} // namespace internal } // namespace internal
// A Matcher<T> is a copyable and IMMUTABLE (except by assignment) // A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
// object that can check whether a value of type T matches. The // object that can check whether a value of type T matches. The
// implementation of Matcher<T> is just a linked_ptr to const // implementation of Matcher<T> is just a linked_ptr to const
// MatcherInterface<T>, so copying is fairly cheap. Don't inherit // MatcherInterface<T>, so copying is fairly cheap. Don't inherit
skipping to change at line 173 skipping to change at line 175
class Matcher : public internal::MatcherBase<T> { class Matcher : public internal::MatcherBase<T> {
public: public:
// Constructs a null matcher. Needed for storing Matcher objects in // Constructs a null matcher. Needed for storing Matcher objects in
// STL containers. // STL containers.
Matcher() {} Matcher() {}
// Constructs a matcher from its implementation. // Constructs a matcher from its implementation.
explicit Matcher(const MatcherInterface<T>* impl) explicit Matcher(const MatcherInterface<T>* impl)
: internal::MatcherBase<T>(impl) {} : internal::MatcherBase<T>(impl) {}
// Implicit constructor here allows ipeople to write // Implicit constructor here allows people to write
// EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) somet imes // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) somet imes
Matcher(T value); // NOLINT Matcher(T value); // NOLINT
}; };
// The following two specializations allow the user to write str // The following two specializations allow the user to write str
// instead of Eq(str) and "foo" instead of Eq("foo") when a string // instead of Eq(str) and "foo" instead of Eq("foo") when a string
// matcher is expected. // matcher is expected.
template <> template <>
class Matcher<const internal::string&> class Matcher<const internal::string&>
: public internal::MatcherBase<const internal::string&> { : public internal::MatcherBase<const internal::string&> {
skipping to change at line 237 skipping to change at line 239
// void ExplainMatchResultTo(const Impl& matcher, const Value& value, // void ExplainMatchResultTo(const Impl& matcher, const Value& value,
// ::std::ostream* os); // ::std::ostream* os);
// //
// in the SAME NAME SPACE where Impl is defined. See the definition // in the SAME NAME SPACE where Impl is defined. See the definition
// of NotNull() for a complete example. // of NotNull() for a complete example.
template <class Impl> template <class Impl>
class PolymorphicMatcher { class PolymorphicMatcher {
public: public:
explicit PolymorphicMatcher(const Impl& impl) : impl_(impl) {} explicit PolymorphicMatcher(const Impl& impl) : impl_(impl) {}
// Returns a mutable reference to the underlying matcher
// implementation object.
Impl& mutable_impl() { return impl_; }
// Returns an immutable reference to the underlying matcher
// implementation object.
const Impl& impl() const { return impl_; }
template <typename T> template <typename T>
operator Matcher<T>() const { operator Matcher<T>() const {
return Matcher<T>(new MonomorphicImpl<T>(impl_)); return Matcher<T>(new MonomorphicImpl<T>(impl_));
} }
private: private:
template <typename T> template <typename T>
class MonomorphicImpl : public MatcherInterface<T> { class MonomorphicImpl : public MatcherInterface<T> {
public: public:
explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
skipping to change at line 274 skipping to change at line 284
// will be picked by the compiler as the better match. // will be picked by the compiler as the better match.
// Otherwise the default implementation of it in // Otherwise the default implementation of it in
// ::testing::internal will be picked. // ::testing::internal will be picked.
// //
// This look-up rule lets a writer of a polymorphic matcher // This look-up rule lets a writer of a polymorphic matcher
// customize the behavior of ExplainMatchResultTo() when he // customize the behavior of ExplainMatchResultTo() when he
// cares to. Nothing needs to be done by the writer if he // cares to. Nothing needs to be done by the writer if he
// doesn't need to customize it. // doesn't need to customize it.
ExplainMatchResultTo(impl_, x, os); ExplainMatchResultTo(impl_, x, os);
} }
private: private:
const Impl impl_; const Impl impl_;
}; };
const Impl impl_; Impl impl_;
}; };
// Creates a matcher from its implementation. This is easier to use // Creates a matcher from its implementation. This is easier to use
// than the Matcher<T> constructor as it doesn't require you to // than the Matcher<T> constructor as it doesn't require you to
// explicitly write the template argument, e.g. // explicitly write the template argument, e.g.
// //
// MakeMatcher(foo); // MakeMatcher(foo);
// vs // vs
// Matcher<const string&>(foo); // Matcher<const string&>(foo);
template <typename T> template <typename T>
skipping to change at line 312 skipping to change at line 323
return PolymorphicMatcher<Impl>(impl); return PolymorphicMatcher<Impl>(impl);
} }
// In order to be safe and clear, casting between different matcher // In order to be safe and clear, casting between different matcher
// types is done explicitly via MatcherCast<T>(m), which takes a // types is done explicitly via MatcherCast<T>(m), which takes a
// matcher m and returns a Matcher<T>. It compiles only when T can be // matcher m and returns a Matcher<T>. It compiles only when T can be
// statically converted to the argument type of m. // statically converted to the argument type of m.
template <typename T, typename M> template <typename T, typename M>
Matcher<T> MatcherCast(M m); Matcher<T> MatcherCast(M m);
// Implements SafeMatcherCast().
//
// We use an intermediate class to do the actual safe casting as Nokia's
// Symbian compiler cannot decide between
// template <T, M> ... (M) and
// template <T, U> ... (const Matcher<U>&)
// for function templates but can for member function templates.
template <typename T>
class SafeMatcherCastImpl {
public:
// This overload handles polymorphic matchers only since monomorphic
// matchers are handled by the next one.
template <typename M>
static inline Matcher<T> Cast(M polymorphic_matcher) {
return Matcher<T>(polymorphic_matcher);
}
// This overload handles monomorphic matchers.
//
// In general, if type T can be implicitly converted to type U, we can
// safely convert a Matcher<U> to a Matcher<T> (i.e. Matcher is
// contravariant): just keep a copy of the original Matcher<U>, convert t
he
// argument from type T to U, and then pass it to the underlying Matcher<
U>.
// The only exception is when U is a reference and T is not, as the
// underlying Matcher<U> may be interested in the argument's address, whi
ch
// is not preserved in the conversion from T to U.
template <typename U>
static inline Matcher<T> Cast(const Matcher<U>& matcher) {
// Enforce that T can be implicitly converted to U.
GMOCK_COMPILE_ASSERT_((internal::ImplicitlyConvertible<T, U>::value),
T_must_be_implicitly_convertible_to_U);
// Enforce that we are not converting a non-reference type T to a refer
ence
// type U.
GMOCK_COMPILE_ASSERT_(
internal::is_reference<T>::value || !internal::is_reference<U>::val
ue,
cannot_convert_non_referentce_arg_to_reference);
// In case both T and U are arithmetic types, enforce that the
// conversion is not lossy.
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(T)) RawT;
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(U)) RawU;
const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;
const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;
GMOCK_COMPILE_ASSERT_(
kTIsOther || kUIsOther ||
(internal::LosslessArithmeticConvertible<RawT, RawU>::value),
conversion_of_arithmetic_types_must_be_lossless);
return MatcherCast<T>(matcher);
}
};
template <typename T, typename M>
inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {
return SafeMatcherCastImpl<T>::Cast(polymorphic_matcher);
}
// A<T>() returns a matcher that matches any value of type T. // A<T>() returns a matcher that matches any value of type T.
template <typename T> template <typename T>
Matcher<T> A(); Matcher<T> A();
// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
// and MUST NOT BE USED IN USER CODE!!! // and MUST NOT BE USED IN USER CODE!!!
namespace internal { namespace internal {
// Appends the explanation on the result of matcher.Matches(value) to // Appends the explanation on the result of matcher.Matches(value) to
// os iff the explanation is not empty. // os iff the explanation is not empty.
skipping to change at line 393 skipping to change at line 459
*os << "\n"; *os << "\n";
} }
} }
}; };
// The base case. // The base case.
template <> template <>
class TuplePrefix<0> { class TuplePrefix<0> {
public: public:
template <typename MatcherTuple, typename ValueTuple> template <typename MatcherTuple, typename ValueTuple>
static bool Matches(const MatcherTuple& matcher_tuple, static bool Matches(const MatcherTuple& /* matcher_tuple */,
const ValueTuple& value_tuple) { const ValueTuple& /* value_tuple */) {
return true; return true;
} }
template <typename MatcherTuple, typename ValueTuple> template <typename MatcherTuple, typename ValueTuple>
static void DescribeMatchFailuresTo(const MatcherTuple& matchers, static void DescribeMatchFailuresTo(const MatcherTuple& /* matchers */,
const ValueTuple& values, const ValueTuple& /* values */,
::std::ostream* os) {} ::std::ostream* /* os */) {}
}; };
// TupleMatches(matcher_tuple, value_tuple) returns true iff all // TupleMatches(matcher_tuple, value_tuple) returns true iff all
// 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) {
skipping to change at line 498 skipping to change at line 564
template <typename T> template <typename T>
class MatcherCastImpl<T, Matcher<T> > { class MatcherCastImpl<T, Matcher<T> > {
public: public:
static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; } static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
}; };
// Implements A<T>(). // Implements A<T>().
template <typename T> template <typename T>
class AnyMatcherImpl : public MatcherInterface<T> { class AnyMatcherImpl : public MatcherInterface<T> {
public: public:
virtual bool Matches(T x) const { return true; } virtual bool Matches(T /* x */) const { return true; }
virtual void DescribeTo(::std::ostream* os) const { *os << "is anything"; } virtual void DescribeTo(::std::ostream* os) const { *os << "is anything"; }
virtual void DescribeNegationTo(::std::ostream* os) const { virtual void DescribeNegationTo(::std::ostream* os) const {
// This is mostly for completeness' safe, as it's not very useful // This is mostly for completeness' safe, as it's not very useful
// to write Not(A<bool>()). However we cannot completely rule out // to write Not(A<bool>()). However we cannot completely rule out
// such a possibility, and it doesn't hurt to be prepared. // such a possibility, and it doesn't hurt to be prepared.
*os << "never matches"; *os << "never matches";
} }
}; };
// Implements _, a matcher that matches any value of any // Implements _, a matcher that matches any value of any
skipping to change at line 570 skipping to change at line 636
// 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 IsNull() matcher, which matches any
// pointer that is NULL.
class IsNullMatcher {
public:
template <typename T>
bool Matches(T* p) const { return p == NULL; }
void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
void DescribeNegationTo(::std::ostream* os) const {
*os << "is not NULL";
}
};
// 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 {
*os << "is NULL"; *os << "is NULL";
skipping to change at line 896 skipping to change at line 975
// 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) \
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: \
virtual bool Matches(const ::std::tr1::tuple<T1, T2>& args) const { \ virtual bool Matches(const ::std::tr1::tuple<T1, T2>& args) const { \
return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \ return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \
} \ } \
virtual void DescribeTo(::std::ostream* os) const { \ virtual void DescribeTo(::std::ostream* os) const { \
*os << "argument #0 is " relation " argument #1"; \ *os << "are a pair (x, y) where x " #op " y"; \
} \ } \
virtual void DescribeNegationTo(::std::ostream* os) const { \ virtual void DescribeNegationTo(::std::ostream* os) const { \
*os << "argument #0 is not " relation " argument #1"; \ *os << "are a pair (x, y) where x " #op " y is false"; \
} \ } \
}; \ }; \
} }
// 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, ==);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ge, >=, "greater than or equal to"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ge, >=);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Gt, >, "greater than"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Gt, >);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Le, <=, "less than or equal to"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Le, <=);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Lt, <, "less than"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Lt, <);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, "not equal to"); GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=);
#undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_ #undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
// Implements the Not(...) matcher for a particular argument type T.
// We do not nest it inside the NotMatcher class template, as that
// will prevent different instantiations of NotMatcher from sharing
// the same NotMatcherImpl<T> class.
template <typename T>
class NotMatcherImpl : public MatcherInterface<T> {
public:
explicit NotMatcherImpl(const Matcher<T>& matcher)
: matcher_(matcher) {}
virtual bool Matches(T x) const {
return !matcher_.Matches(x);
}
virtual void DescribeTo(::std::ostream* os) const {
matcher_.DescribeNegationTo(os);
}
virtual void DescribeNegationTo(::std::ostream* os) const {
matcher_.DescribeTo(os);
}
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
matcher_.ExplainMatchResultTo(x, os);
}
private:
const Matcher<T> 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.
template <typename T> template <typename T>
operator Matcher<T>() const { operator Matcher<T>() const {
return Matcher<T>(new Impl<T>(matcher_)); return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
} }
private: private:
// Implements the Not(...) matcher for a particular argument type T. InnerMatcher matcher_;
template <typename T> };
class Impl : public MatcherInterface<T> {
public:
explicit Impl(const Matcher<T>& matcher) : matcher_(matcher) {}
virtual bool Matches(T x) const { // Implements the AllOf(m1, m2) matcher for a particular argument type
return !matcher_.Matches(x); // T. We do not nest it inside the BothOfMatcher class template, as
} // that will prevent different instantiations of BothOfMatcher from
// sharing the same BothOfMatcherImpl<T> class.
template <typename T>
class BothOfMatcherImpl : public MatcherInterface<T> {
public:
BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
: matcher1_(matcher1), matcher2_(matcher2) {}
virtual void DescribeTo(::std::ostream* os) const { virtual bool Matches(T x) const {
matcher_.DescribeNegationTo(os); return matcher1_.Matches(x) && matcher2_.Matches(x);
} }
virtual void DescribeNegationTo(::std::ostream* os) const { virtual void DescribeTo(::std::ostream* os) const {
matcher_.DescribeTo(os); *os << "(";
} matcher1_.DescribeTo(os);
*os << ") and (";
matcher2_.DescribeTo(os);
*os << ")";
}
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { virtual void DescribeNegationTo(::std::ostream* os) const {
matcher_.ExplainMatchResultTo(x, os); *os << "not ";
} DescribeTo(os);
private: }
const Matcher<T> matcher_;
};
InnerMatcher matcher_; virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
if (Matches(x)) {
// When both matcher1_ and matcher2_ match x, we need to
// explain why *both* of them match.
::std::stringstream ss1;
matcher1_.ExplainMatchResultTo(x, &ss1);
const internal::string s1 = ss1.str();
::std::stringstream ss2;
matcher2_.ExplainMatchResultTo(x, &ss2);
const internal::string s2 = ss2.str();
if (s1 == "") {
*os << s2;
} else {
*os << s1;
if (s2 != "") {
*os << "; " << s2;
}
}
} else {
// Otherwise we only need to explain why *one* of them fails
// to match.
if (!matcher1_.Matches(x)) {
matcher1_.ExplainMatchResultTo(x, os);
} else {
matcher2_.ExplainMatchResultTo(x, os);
}
}
}
private:
const Matcher<T> matcher1_;
const Matcher<T> matcher2_;
}; };
// Used for implementing the AllOf(m_1, ..., m_n) matcher, which // Used for implementing the AllOf(m_1, ..., m_n) matcher, which
// matches a value that matches all of the matchers m_1, ..., and m_n. // matches a value that matches all of the matchers m_1, ..., and m_n.
template <typename Matcher1, typename Matcher2> template <typename Matcher1, typename Matcher2>
class BothOfMatcher { class BothOfMatcher {
public: public:
BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2) BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
: matcher1_(matcher1), matcher2_(matcher2) {} : matcher1_(matcher1), matcher2_(matcher2) {}
// This template type conversion operator allows a // This template type conversion operator allows a
// BothOfMatcher<Matcher1, Matcher2> object to match any type that // BothOfMatcher<Matcher1, Matcher2> object to match any type that
// both Matcher1 and Matcher2 can match. // both Matcher1 and Matcher2 can match.
template <typename T> template <typename T>
operator Matcher<T>() const { operator Matcher<T>() const {
return Matcher<T>(new Impl<T>(matcher1_, matcher2_)); return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_
),
SafeMatcherCast<T>(matcher2_
)));
} }
private: private:
// Implements the AllOf(m1, m2) matcher for a particular argument Matcher1 matcher1_;
// type T. Matcher2 matcher2_;
template <typename T> };
class Impl : public MatcherInterface<T> {
public:
Impl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
: matcher1_(matcher1), matcher2_(matcher2) {}
virtual bool Matches(T x) const { // Implements the AnyOf(m1, m2) matcher for a particular argument type
return matcher1_.Matches(x) && matcher2_.Matches(x); // T. We do not nest it inside the AnyOfMatcher class template, as
} // that will prevent different instantiations of AnyOfMatcher from
// sharing the same EitherOfMatcherImpl<T> class.
template <typename T>
class EitherOfMatcherImpl : public MatcherInterface<T> {
public:
EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher
2)
: matcher1_(matcher1), matcher2_(matcher2) {}
virtual void DescribeTo(::std::ostream* os) const { virtual bool Matches(T x) const {
*os << "("; return matcher1_.Matches(x) || matcher2_.Matches(x);
matcher1_.DescribeTo(os); }
*os << ") and (";
matcher2_.DescribeTo(os);
*os << ")";
}
virtual void DescribeNegationTo(::std::ostream* os) const { virtual void DescribeTo(::std::ostream* os) const {
*os << "not "; *os << "(";
DescribeTo(os); matcher1_.DescribeTo(os);
} *os << ") or (";
matcher2_.DescribeTo(os);
*os << ")";
}
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { virtual void DescribeNegationTo(::std::ostream* os) const {
if (Matches(x)) { *os << "not ";
// When both matcher1_ and matcher2_ match x, we need to DescribeTo(os);
// explain why *both* of them match. }
::std::stringstream ss1;
matcher1_.ExplainMatchResultTo(x, &ss1);
const internal::string s1 = ss1.str();
::std::stringstream ss2; virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
matcher2_.ExplainMatchResultTo(x, &ss2); if (Matches(x)) {
const internal::string s2 = ss2.str(); // If either matcher1_ or matcher2_ matches x, we just need
// to explain why *one* of them matches.
if (matcher1_.Matches(x)) {
matcher1_.ExplainMatchResultTo(x, os);
} else {
matcher2_.ExplainMatchResultTo(x, os);
}
} else {
// Otherwise we need to explain why *neither* matches.
::std::stringstream ss1;
matcher1_.ExplainMatchResultTo(x, &ss1);
const internal::string s1 = ss1.str();
if (s1 == "") { ::std::stringstream ss2;
*os << s2; matcher2_.ExplainMatchResultTo(x, &ss2);
} else { const internal::string s2 = ss2.str();
*os << s1;
if (s2 != "") { if (s1 == "") {
*os << "; " << s2; *os << s2;
}
}
} else { } else {
// Otherwise we only need to explain why *one* of them fails *os << s1;
// to match. if (s2 != "") {
if (!matcher1_.Matches(x)) { *os << "; " << s2;
matcher1_.ExplainMatchResultTo(x, os);
} else {
matcher2_.ExplainMatchResultTo(x, os);
} }
} }
} }
private: }
const Matcher<T> matcher1_; private:
const Matcher<T> matcher2_; const Matcher<T> matcher1_;
}; const Matcher<T> matcher2_;
Matcher1 matcher1_;
Matcher2 matcher2_;
}; };
// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which // Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
// matches a value that matches at least one of the matchers m_1, ..., // matches a value that matches at least one of the matchers m_1, ...,
// and m_n. // and m_n.
template <typename Matcher1, typename Matcher2> template <typename Matcher1, typename Matcher2>
class EitherOfMatcher { class EitherOfMatcher {
public: public:
EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2) EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
: matcher1_(matcher1), matcher2_(matcher2) {} : matcher1_(matcher1), matcher2_(matcher2) {}
// This template type conversion operator allows a // This template type conversion operator allows a
// EitherOfMatcher<Matcher1, Matcher2> object to match any type that // EitherOfMatcher<Matcher1, Matcher2> object to match any type that
// both Matcher1 and Matcher2 can match. // both Matcher1 and Matcher2 can match.
template <typename T> template <typename T>
operator Matcher<T>() const { operator Matcher<T>() const {
return Matcher<T>(new Impl<T>(matcher1_, matcher2_)); return Matcher<T>(new EitherOfMatcherImpl<T>(
SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
} }
private: private:
// Implements the AnyOf(m1, m2) matcher for a particular argument
// type T.
template <typename T>
class Impl : public MatcherInterface<T> {
public:
Impl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
: matcher1_(matcher1), matcher2_(matcher2) {}
virtual bool Matches(T x) const {
return matcher1_.Matches(x) || matcher2_.Matches(x);
}
virtual void DescribeTo(::std::ostream* os) const {
*os << "(";
matcher1_.DescribeTo(os);
*os << ") or (";
matcher2_.DescribeTo(os);
*os << ")";
}
virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "not ";
DescribeTo(os);
}
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
if (Matches(x)) {
// If either matcher1_ or matcher2_ matches x, we just need
// to explain why *one* of them matches.
if (matcher1_.Matches(x)) {
matcher1_.ExplainMatchResultTo(x, os);
} else {
matcher2_.ExplainMatchResultTo(x, os);
}
} else {
// Otherwise we need to explain why *neither* matches.
::std::stringstream ss1;
matcher1_.ExplainMatchResultTo(x, &ss1);
const internal::string s1 = ss1.str();
::std::stringstream ss2;
matcher2_.ExplainMatchResultTo(x, &ss2);
const internal::string s2 = ss2.str();
if (s1 == "") {
*os << s2;
} else {
*os << s1;
if (s2 != "") {
*os << "; " << s2;
}
}
}
}
private:
const Matcher<T> matcher1_;
const Matcher<T> matcher2_;
};
Matcher1 matcher1_; Matcher1 matcher1_;
Matcher2 matcher2_; Matcher2 matcher2_;
}; };
// Used for implementing Truly(pred), which turns a predicate into a // Used for implementing Truly(pred), which turns a predicate into a
// matcher. // matcher.
template <typename Predicate> template <typename Predicate>
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 { // NOLINT
#if 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);
#if 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
} }
skipping to change at line 1435 skipping to change at line 1524
void DescribeTo(::std::ostream* os) const { void DescribeTo(::std::ostream* os) const {
*os << "the given field "; *os << "the given field ";
matcher_.DescribeTo(os); matcher_.DescribeTo(os);
} }
void DescribeNegationTo(::std::ostream* os) const { void DescribeNegationTo(::std::ostream* os) const {
*os << "the given field "; *os << "the given field ";
matcher_.DescribeNegationTo(os); matcher_.DescribeNegationTo(os);
} }
void ExplainMatchResultTo(const Class& obj, ::std::ostream* os) const { // The first argument of ExplainMatchResultTo() is needed to help
// Symbian's C++ compiler choose which overload to use. Its type is
// true_type iff the Field() matcher is used to match a pointer.
void ExplainMatchResultTo(false_type /* is_not_pointer */, const Class& o
bj,
::std::ostream* os) const {
::std::stringstream ss; ::std::stringstream ss;
matcher_.ExplainMatchResultTo(obj.*field_, &ss); matcher_.ExplainMatchResultTo(obj.*field_, &ss);
const internal::string s = ss.str(); const internal::string s = ss.str();
if (s != "") { if (s != "") {
*os << "the given field " << s; *os << "the given field " << s;
} }
} }
void ExplainMatchResultTo(const Class* p, ::std::ostream* os) const { void ExplainMatchResultTo(true_type /* is_pointer */, const Class* p,
::std::ostream* os) const {
if (p != NULL) { if (p != NULL) {
ExplainMatchResultTo(*p, os); // Since *p has a field, it must be a class/struct/union type
// and thus cannot be a pointer. Therefore we pass false_type()
// as the first argument.
ExplainMatchResultTo(false_type(), *p, os);
} }
} }
private: private:
const FieldType Class::*field_; const FieldType Class::*field_;
const Matcher<const FieldType&> matcher_; const Matcher<const FieldType&> matcher_;
}; };
// Explains the result of matching an object against a field matcher. // Explains the result of matching an object or pointer against a field mat
template <typename Class, typename FieldType> cher.
void ExplainMatchResultTo(const FieldMatcher<Class, FieldType>& matcher, template <typename Class, typename FieldType, typename T>
const Class& obj, ::std::ostream* os) {
matcher.ExplainMatchResultTo(obj, os);
}
// Explains the result of matching a pointer against a field matcher.
template <typename Class, typename FieldType>
void ExplainMatchResultTo(const FieldMatcher<Class, FieldType>& matcher, void ExplainMatchResultTo(const FieldMatcher<Class, FieldType>& matcher,
const Class* p, ::std::ostream* os) { const T& value, ::std::ostream* os) {
matcher.ExplainMatchResultTo(p, os); matcher.ExplainMatchResultTo(
typename ::testing::internal::is_pointer<T>::type(), value, os);
} }
// 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
skipping to change at line 1503 skipping to change at line 1594
void DescribeTo(::std::ostream* os) const { void DescribeTo(::std::ostream* os) const {
*os << "the given property "; *os << "the given property ";
matcher_.DescribeTo(os); matcher_.DescribeTo(os);
} }
void DescribeNegationTo(::std::ostream* os) const { void DescribeNegationTo(::std::ostream* os) const {
*os << "the given property "; *os << "the given property ";
matcher_.DescribeNegationTo(os); matcher_.DescribeNegationTo(os);
} }
void ExplainMatchResultTo(const Class& obj, ::std::ostream* os) const { // The first argument of ExplainMatchResultTo() is needed to help
// Symbian's C++ compiler choose which overload to use. Its type is
// true_type iff the Property() matcher is used to match a pointer.
void ExplainMatchResultTo(false_type /* is_not_pointer */, const Class& o
bj,
::std::ostream* os) const {
::std::stringstream ss; ::std::stringstream ss;
matcher_.ExplainMatchResultTo((obj.*property_)(), &ss); matcher_.ExplainMatchResultTo((obj.*property_)(), &ss);
const internal::string s = ss.str(); const internal::string s = ss.str();
if (s != "") { if (s != "") {
*os << "the given property " << s; *os << "the given property " << s;
} }
} }
void ExplainMatchResultTo(const Class* p, ::std::ostream* os) const { void ExplainMatchResultTo(true_type /* is_pointer */, const Class* p,
::std::ostream* os) const {
if (p != NULL) { if (p != NULL) {
ExplainMatchResultTo(*p, os); // Since *p has a property method, it must be a
// class/struct/union type and thus cannot be a pointer.
// Therefore we pass false_type() as the first argument.
ExplainMatchResultTo(false_type(), *p, os);
} }
} }
private: private:
PropertyType (Class::*property_)() const; PropertyType (Class::*property_)() const;
const Matcher<RefToConstProperty> matcher_; const Matcher<RefToConstProperty> matcher_;
}; };
// Explains the result of matching an object against a property matcher. // Explains the result of matching an object or pointer against a
template <typename Class, typename PropertyType> // property matcher.
void ExplainMatchResultTo(const PropertyMatcher<Class, PropertyType>& match template <typename Class, typename PropertyType, typename T>
er,
const Class& obj, ::std::ostream* os) {
matcher.ExplainMatchResultTo(obj, os);
}
// Explains the result of matching a pointer against a property matcher.
template <typename Class, typename PropertyType>
void ExplainMatchResultTo(const PropertyMatcher<Class, PropertyType>& match er, void ExplainMatchResultTo(const PropertyMatcher<Class, PropertyType>& match er,
const Class* p, ::std::ostream* os) { const T& value, ::std::ostream* os) {
matcher.ExplainMatchResultTo(p, os); matcher.ExplainMatchResultTo(
typename ::testing::internal::is_pointer<T>::type(), value, os);
} }
// Type traits specifying various features of different functors for Result Of. // Type traits specifying various features of different functors for Result Of.
// The default template specifies features for functor objects. // The default template specifies features for functor objects.
// Functor classes have to typedef argument_type and result_type // Functor classes have to typedef argument_type and result_type
// to be compatible with ResultOf. // to be compatible with ResultOf.
template <typename Functor> template <typename Functor>
struct CallableTraits { struct CallableTraits {
typedef typename Functor::result_type ResultType; typedef typename Functor::result_type ResultType;
typedef Functor StorageType; typedef Functor StorageType;
skipping to change at line 1557 skipping to change at line 1651
static ResultType Invoke(Functor f, T arg) { return f(arg); } static ResultType Invoke(Functor f, T arg) { return f(arg); }
}; };
// Specialization for function pointers. // Specialization for function pointers.
template <typename ArgType, typename ResType> template <typename ArgType, typename ResType>
struct CallableTraits<ResType(*)(ArgType)> { struct CallableTraits<ResType(*)(ArgType)> {
typedef ResType ResultType; typedef ResType ResultType;
typedef ResType(*StorageType)(ArgType); typedef ResType(*StorageType)(ArgType);
static void CheckIsValid(ResType(*f)(ArgType)) { static void CheckIsValid(ResType(*f)(ArgType)) {
GMOCK_CHECK_(f != NULL) GTEST_CHECK_(f != NULL)
<< "NULL function pointer is passed into ResultOf()."; << "NULL function pointer is passed into ResultOf().";
} }
template <typename T> template <typename T>
static ResType Invoke(ResType(*f)(ArgType), T arg) { static ResType Invoke(ResType(*f)(ArgType), T arg) {
return (*f)(arg); return (*f)(arg);
} }
}; };
// Implements the ResultOf() matcher for matching a return value of a // Implements the ResultOf() matcher for matching a return value of a
// unary function of an object. // unary function of an object.
skipping to change at line 1652 skipping to change at line 1746
// The failure message reports elements that are in one of the operands but not // 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 // 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 // elements in the containers (which don't properly matter to sets, but can
// occur if the containers are vectors or lists, for example). // occur if the containers are vectors or lists, for example).
// //
// Uses the container's const_iterator, value_type, operator ==, // Uses the container's const_iterator, value_type, operator ==,
// begin(), and end(). // begin(), and end().
template <typename Container> template <typename Container>
class ContainerEqMatcher { class ContainerEqMatcher {
public: public:
explicit ContainerEqMatcher(const Container& rhs) : rhs_(rhs) {} typedef internal::StlContainerView<Container> View;
bool Matches(const Container& lhs) const { return lhs == rhs_; } typedef typename View::type StlContainer;
typedef typename View::const_reference StlContainerReference;
// We make a copy of rhs in case the elements in it are modified
// after this matcher is created.
explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs))
{
// Makes sure the user doesn't instantiate this class template
// with a const or reference type.
testing::StaticAssertTypeEq<Container,
GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))>();
}
template <typename LhsContainer>
bool Matches(const LhsContainer& lhs) const {
// GMOCK_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
// that causes LhsContainer to be a const type sometimes.
typedef internal::StlContainerView<GMOCK_REMOVE_CONST_(LhsContainer)>
LhsView;
StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
return lhs_stl_container == rhs_;
}
void DescribeTo(::std::ostream* os) const { void DescribeTo(::std::ostream* os) const {
*os << "equals "; *os << "equals ";
UniversalPrinter<Container>::Print(rhs_, os); UniversalPrinter<StlContainer>::Print(rhs_, os);
} }
void DescribeNegationTo(::std::ostream* os) const { void DescribeNegationTo(::std::ostream* os) const {
*os << "does not equal "; *os << "does not equal ";
UniversalPrinter<Container>::Print(rhs_, os); UniversalPrinter<StlContainer>::Print(rhs_, os);
} }
void ExplainMatchResultTo(const Container& lhs, template <typename LhsContainer>
void ExplainMatchResultTo(const LhsContainer& lhs,
::std::ostream* os) const { ::std::ostream* os) const {
// GMOCK_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
// that causes LhsContainer to be a const type sometimes.
typedef internal::StlContainerView<GMOCK_REMOVE_CONST_(LhsContainer)>
LhsView;
typedef typename LhsView::type LhsStlContainer;
StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
// Something is different. Check for missing values first. // Something is different. Check for missing values first.
bool printed_header = false; bool printed_header = false;
for (typename Container::const_iterator it = lhs.begin(); for (typename LhsStlContainer::const_iterator it =
it != lhs.end(); ++it) { lhs_stl_container.begin();
if (std::find(rhs_.begin(), rhs_.end(), *it) == rhs_.end()) { it != lhs_stl_container.end(); ++it) {
if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) ==
rhs_.end()) {
if (printed_header) { if (printed_header) {
*os << ", "; *os << ", ";
} else { } else {
*os << "Only in actual: "; *os << "Only in actual: ";
printed_header = true; printed_header = true;
} }
UniversalPrinter<typename Container::value_type>::Print(*it, os); UniversalPrinter<typename LhsStlContainer::value_type>::Print(*it, os);
} }
} }
// Now check for extra values. // Now check for extra values.
bool printed_header2 = false; bool printed_header2 = false;
for (typename Container::const_iterator it = rhs_.begin(); for (typename StlContainer::const_iterator it = rhs_.begin();
it != rhs_.end(); ++it) { it != rhs_.end(); ++it) {
if (std::find(lhs.begin(), lhs.end(), *it) == lhs.end()) { if (internal::ArrayAwareFind(
lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
lhs_stl_container.end()) {
if (printed_header2) { if (printed_header2) {
*os << ", "; *os << ", ";
} else { } else {
*os << (printed_header ? "; not" : "Not") << " in actual: "; *os << (printed_header ? "; not" : "Not") << " in actual: ";
printed_header2 = true; printed_header2 = true;
} }
UniversalPrinter<typename Container::value_type>::Print(*it, os); UniversalPrinter<typename StlContainer::value_type>::Print(*it, os) ;
} }
} }
} }
private: private:
const Container rhs_; const StlContainer rhs_;
}; };
template <typename Container> template <typename LhsContainer, typename Container>
void ExplainMatchResultTo(const ContainerEqMatcher<Container>& matcher, void ExplainMatchResultTo(const ContainerEqMatcher<Container>& matcher,
const Container& lhs, const LhsContainer& lhs,
::std::ostream* os) { ::std::ostream* os) {
matcher.ExplainMatchResultTo(lhs, os); matcher.ExplainMatchResultTo(lhs, os);
} }
// Implements Contains(element_matcher) for the given argument type Contain
er.
template <typename Container>
class ContainsMatcherImpl : public MatcherInterface<Container> {
public:
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai
ner;
typedef StlContainerView<RawContainer> View;
typedef typename View::type StlContainer;
typedef typename View::const_reference StlContainerReference;
typedef typename StlContainer::value_type Element;
template <typename InnerMatcher>
explicit ContainsMatcherImpl(InnerMatcher inner_matcher)
: inner_matcher_(
testing::SafeMatcherCast<const Element&>(inner_matcher)) {}
// Returns true iff 'container' matches.
virtual bool Matches(Container container) const {
StlContainerReference stl_container = View::ConstReference(container);
for (typename StlContainer::const_iterator it = stl_container.begin();
it != stl_container.end(); ++it) {
if (inner_matcher_.Matches(*it))
return true;
}
return false;
}
// Describes what this matcher does.
virtual void DescribeTo(::std::ostream* os) const {
*os << "contains at least one element that ";
inner_matcher_.DescribeTo(os);
}
// Describes what the negation of this matcher does.
virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "doesn't contain any element that ";
inner_matcher_.DescribeTo(os);
}
// Explains why 'container' matches, or doesn't match, this matcher.
virtual void ExplainMatchResultTo(Container container,
::std::ostream* os) const {
StlContainerReference stl_container = View::ConstReference(container);
// We need to explain which (if any) element matches inner_matcher_.
typename StlContainer::const_iterator it = stl_container.begin();
for (size_t i = 0; it != stl_container.end(); ++it, ++i) {
if (inner_matcher_.Matches(*it)) {
*os << "element " << i << " matches";
return;
}
}
}
private:
const Matcher<const Element&> inner_matcher_;
};
// Implements polymorphic Contains(element_matcher).
template <typename M>
class ContainsMatcher {
public:
explicit ContainsMatcher(M m) : inner_matcher_(m) {}
template <typename Container>
operator Matcher<Container>() const {
return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_));
}
private:
const M inner_matcher_;
};
// Implements Key(inner_matcher) for the given argument pair type.
// Key(inner_matcher) matches an std::pair whose 'first' field matches
// inner_matcher. For example, Contains(Key(Ge(5))) can be used to match a
n
// std::map that contains at least one element whose key is >= 5.
template <typename PairType>
class KeyMatcherImpl : public MatcherInterface<PairType> {
public:
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(PairType)) RawPairTyp
e;
typedef typename RawPairType::first_type KeyType;
template <typename InnerMatcher>
explicit KeyMatcherImpl(InnerMatcher inner_matcher)
: inner_matcher_(
testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {
}
// Returns true iff 'key_value.first' (the key) matches the inner matcher
.
virtual bool Matches(PairType key_value) const {
return inner_matcher_.Matches(key_value.first);
}
// Describes what this matcher does.
virtual void DescribeTo(::std::ostream* os) const {
*os << "has a key that ";
inner_matcher_.DescribeTo(os);
}
// Describes what the negation of this matcher does.
virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "doesn't have a key that ";
inner_matcher_.DescribeTo(os);
}
// Explains why 'key_value' matches, or doesn't match, this matcher.
virtual void ExplainMatchResultTo(PairType key_value,
::std::ostream* os) const {
inner_matcher_.ExplainMatchResultTo(key_value.first, os);
}
private:
const Matcher<const KeyType&> inner_matcher_;
};
// Implements polymorphic Key(matcher_for_key).
template <typename M>
class KeyMatcher {
public:
explicit KeyMatcher(M m) : matcher_for_key_(m) {}
template <typename PairType>
operator Matcher<PairType>() const {
return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_));
}
private:
const M matcher_for_key_;
};
// Implements Pair(first_matcher, second_matcher) for the given argument pa
ir
// type with its two matchers. See Pair() function below.
template <typename PairType>
class PairMatcherImpl : public MatcherInterface<PairType> {
public:
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(PairType)) RawPairTyp
e;
typedef typename RawPairType::first_type FirstType;
typedef typename RawPairType::second_type SecondType;
template <typename FirstMatcher, typename SecondMatcher>
PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
: first_matcher_(
testing::SafeMatcherCast<const FirstType&>(first_matcher)),
second_matcher_(
testing::SafeMatcherCast<const SecondType&>(second_matcher)) {
}
// Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.seco
nd'
// matches second_matcher.
virtual bool Matches(PairType a_pair) const {
return first_matcher_.Matches(a_pair.first) &&
second_matcher_.Matches(a_pair.second);
}
// Describes what this matcher does.
virtual void DescribeTo(::std::ostream* os) const {
*os << "has a first field that ";
first_matcher_.DescribeTo(os);
*os << ", and has a second field that ";
second_matcher_.DescribeTo(os);
}
// Describes what the negation of this matcher does.
virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "has a first field that ";
first_matcher_.DescribeNegationTo(os);
*os << ", or has a second field that ";
second_matcher_.DescribeNegationTo(os);
}
// Explains why 'a_pair' matches, or doesn't match, this matcher.
virtual void ExplainMatchResultTo(PairType a_pair,
::std::ostream* os) const {
::std::stringstream ss1;
first_matcher_.ExplainMatchResultTo(a_pair.first, &ss1);
internal::string s1 = ss1.str();
if (s1 != "") {
s1 = "the first field " + s1;
}
::std::stringstream ss2;
second_matcher_.ExplainMatchResultTo(a_pair.second, &ss2);
internal::string s2 = ss2.str();
if (s2 != "") {
s2 = "the second field " + s2;
}
*os << s1;
if (s1 != "" && s2 != "") {
*os << ", and ";
}
*os << s2;
}
private:
const Matcher<const FirstType&> first_matcher_;
const Matcher<const SecondType&> second_matcher_;
};
// Implements polymorphic Pair(first_matcher, second_matcher).
template <typename FirstMatcher, typename SecondMatcher>
class PairMatcher {
public:
PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
: first_matcher_(first_matcher), second_matcher_(second_matcher) {}
template <typename PairType>
operator Matcher<PairType> () const {
return MakeMatcher(
new PairMatcherImpl<PairType>(
first_matcher_, second_matcher_));
}
private:
const FirstMatcher first_matcher_;
const SecondMatcher second_matcher_;
};
// Implements ElementsAre() and ElementsAreArray().
template <typename Container>
class ElementsAreMatcherImpl : public MatcherInterface<Container> {
public:
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai
ner;
typedef internal::StlContainerView<RawContainer> View;
typedef typename View::type StlContainer;
typedef typename View::const_reference StlContainerReference;
typedef typename StlContainer::value_type Element;
// Constructs the matcher from a sequence of element values or
// element matchers.
template <typename InputIter>
ElementsAreMatcherImpl(InputIter first, size_t count) {
matchers_.reserve(count);
InputIter it = first;
for (size_t i = 0; i != count; ++i, ++it) {
matchers_.push_back(MatcherCast<const Element&>(*it));
}
}
// Returns true iff 'container' matches.
virtual bool Matches(Container container) const {
StlContainerReference stl_container = View::ConstReference(container);
if (stl_container.size() != count())
return false;
typename StlContainer::const_iterator it = stl_container.begin();
for (size_t i = 0; i != count(); ++it, ++i) {
if (!matchers_[i].Matches(*it))
return false;
}
return true;
}
// Describes what this matcher does.
virtual void DescribeTo(::std::ostream* os) const {
if (count() == 0) {
*os << "is empty";
} else if (count() == 1) {
*os << "has 1 element that ";
matchers_[0].DescribeTo(os);
} else {
*os << "has " << Elements(count()) << " where\n";
for (size_t i = 0; i != count(); ++i) {
*os << "element " << i << " ";
matchers_[i].DescribeTo(os);
if (i + 1 < count()) {
*os << ",\n";
}
}
}
}
// Describes what the negation of this matcher does.
virtual void DescribeNegationTo(::std::ostream* os) const {
if (count() == 0) {
*os << "is not empty";
return;
}
*os << "does not have " << Elements(count()) << ", or\n";
for (size_t i = 0; i != count(); ++i) {
*os << "element " << i << " ";
matchers_[i].DescribeNegationTo(os);
if (i + 1 < count()) {
*os << ", or\n";
}
}
}
// Explains why 'container' matches, or doesn't match, this matcher.
virtual void ExplainMatchResultTo(Container container,
::std::ostream* os) const {
StlContainerReference stl_container = View::ConstReference(container);
if (Matches(container)) {
// We need to explain why *each* element matches (the obvious
// ones can be skipped).
bool reason_printed = false;
typename StlContainer::const_iterator it = stl_container.begin();
for (size_t i = 0; i != count(); ++it, ++i) {
::std::stringstream ss;
matchers_[i].ExplainMatchResultTo(*it, &ss);
const string s = ss.str();
if (!s.empty()) {
if (reason_printed) {
*os << ",\n";
}
*os << "element " << i << " " << s;
reason_printed = true;
}
}
} else {
// We need to explain why the container doesn't match.
const size_t actual_count = stl_container.size();
if (actual_count != count()) {
// The element count doesn't match. If the container is
// empty, there's no need to explain anything as Google Mock
// already prints the empty container. Otherwise we just need
// to show how many elements there actually are.
if (actual_count != 0) {
*os << "has " << Elements(actual_count);
}
return;
}
// The container has the right size but at least one element
// doesn't match expectation. We need to find this element and
// explain why it doesn't match.
typename StlContainer::const_iterator it = stl_container.begin();
for (size_t i = 0; i != count(); ++it, ++i) {
if (matchers_[i].Matches(*it)) {
continue;
}
*os << "element " << i << " doesn't match";
::std::stringstream ss;
matchers_[i].ExplainMatchResultTo(*it, &ss);
const string s = ss.str();
if (!s.empty()) {
*os << " (" << s << ")";
}
return;
}
}
}
private:
static Message Elements(size_t count) {
return Message() << count << (count == 1 ? " element" : " elements");
}
size_t count() const { return matchers_.size(); }
std::vector<Matcher<const Element&> > matchers_;
};
// Implements ElementsAre() of 0 arguments.
class ElementsAreMatcher0 {
public:
ElementsAreMatcher0() {}
template <typename Container>
operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer;
typedef typename internal::StlContainerView<RawContainer>::type::value_
type
Element;
const Matcher<const Element&>* const matchers = NULL;
return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 0));
}
};
// Implements ElementsAreArray().
template <typename T>
class ElementsAreArrayMatcher {
public:
ElementsAreArrayMatcher(const T* first, size_t count) :
first_(first), count_(count) {}
template <typename Container>
operator Matcher<Container>() const {
typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))
RawContainer;
typedef typename internal::StlContainerView<RawContainer>::type::value_
type
Element;
return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_
));
}
private:
const T* const first_;
const size_t count_;
};
// 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 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 1788 skipping to change at line 2347
inline internal::LtMatcher<Rhs> Lt(Rhs x) { inline internal::LtMatcher<Rhs> Lt(Rhs x) {
return internal::LtMatcher<Rhs>(x); return internal::LtMatcher<Rhs>(x);
} }
// Creates a polymorphic matcher that matches anything != x. // Creates a polymorphic matcher that matches anything != x.
template <typename Rhs> template <typename Rhs>
inline internal::NeMatcher<Rhs> Ne(Rhs x) { inline internal::NeMatcher<Rhs> Ne(Rhs x) {
return internal::NeMatcher<Rhs>(x); return internal::NeMatcher<Rhs>(x);
} }
// Creates a polymorphic matcher that matches any NULL pointer.
inline PolymorphicMatcher<internal::IsNullMatcher > IsNull() {
return MakePolymorphicMatcher(internal::IsNullMatcher());
}
// Creates a polymorphic matcher that matches any non-NULL pointer. // Creates a polymorphic matcher that matches any non-NULL pointer.
// This is convenient as Not(NULL) doesn't compile (the compiler // This is convenient as Not(NULL) doesn't compile (the compiler
// thinks that that expression is comparing a pointer with an integer). // thinks that that expression is comparing a pointer with an integer).
inline PolymorphicMatcher<internal::NotNullMatcher > NotNull() { inline PolymorphicMatcher<internal::NotNullMatcher > NotNull() {
return MakePolymorphicMatcher(internal::NotNullMatcher()); return MakePolymorphicMatcher(internal::NotNullMatcher());
} }
// Creates a polymorphic matcher that matches any argument that // Creates a polymorphic matcher that matches any argument that
// references variable x. // references variable x.
template <typename T> template <typename T>
skipping to change at line 2149 skipping to change at line 2713
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. // Returns a matcher that matches an equal container.
// This matcher behaves like Eq(), but in the event of mismatch lists the // 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 that are included in one container but not the other. (Duplicate
// values and order differences are not explained.) // values and order differences are not explained.)
template <typename Container> template <typename Container>
inline PolymorphicMatcher<internal::ContainerEqMatcher<Container> > inline PolymorphicMatcher<internal::ContainerEqMatcher<
GMOCK_REMOVE_CONST_(Container)> >
ContainerEq(const Container& rhs) { ContainerEq(const Container& rhs) {
return MakePolymorphicMatcher(internal::ContainerEqMatcher<Container>(rhs // This following line is for working around a bug in MSVC 8.0,
)); // which causes Container to be a const type sometimes.
typedef GMOCK_REMOVE_CONST_(Container) RawContainer;
return MakePolymorphicMatcher(internal::ContainerEqMatcher<RawContainer>(
rhs));
}
// Matches an STL-style container or a native array that contains at
// least one element matching the given value or matcher.
//
// 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(Gt(2)));
// EXPECT_THAT(page_ids, Not(Contains(4)));
//
// ::std::map<int, size_t> page_lengths;
// page_lengths[1] = 100;
// EXPECT_THAT(page_lengths,
// Contains(::std::pair<const int, size_t>(1, 100)));
//
// const char* user_ids[] = { "joe", "mike", "tom" };
// EXPECT_THAT(user_ids, Contains(Eq(::std::string("tom"))));
template <typename M>
inline internal::ContainsMatcher<M> Contains(M matcher) {
return internal::ContainsMatcher<M>(matcher);
}
// Key(inner_matcher) matches an std::pair whose 'first' field matches
// inner_matcher. For example, Contains(Key(Ge(5))) can be used to match a
n
// std::map that contains at least one element whose key is >= 5.
template <typename M>
inline internal::KeyMatcher<M> Key(M inner_matcher) {
return internal::KeyMatcher<M>(inner_matcher);
}
// Pair(first_matcher, second_matcher) matches a std::pair whose 'first' fi
eld
// matches first_matcher and whose 'second' field matches second_matcher.
For
// example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), "foo"))) can be u
sed
// to match a std::map<int, string> that contains exactly one element whose
key
// is >= 5 and whose value equals "foo".
template <typename FirstMatcher, typename SecondMatcher>
inline internal::PairMatcher<FirstMatcher, SecondMatcher>
Pair(FirstMatcher first_matcher, SecondMatcher second_matcher) {
return internal::PairMatcher<FirstMatcher, SecondMatcher>(
first_matcher, second_matcher);
} }
// 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);
} }
// Returns true iff the value matches the matcher.
template <typename T, typename M>
inline bool Value(const T& value, M matcher) {
return testing::Matches(matcher)(value);
}
// AllArgs(m) is a synonym of m. This is useful in
//
// EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
//
// which is easier to read than
//
// EXPECT_CALL(foo, Bar(_, _)).With(Eq());
template <typename InnerMatcher>
inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return 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,
// the value and the description of the matcher will be printed. // the value and the description of the matcher will be printed.
#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\ #define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\ #define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
} // namespace testing } // namespace testing
 End of changes. 66 change blocks. 
205 lines changed or deleted 860 lines changed or added


 gmock-port.h   gmock-port.h 
skipping to change at line 50 skipping to change at line 50
#include <stdlib.h> #include <stdlib.h>
#include <iostream> #include <iostream>
// Most of the types needed for porting Google Mock are also required // Most of the types needed for porting Google Mock are also required
// for Google Test and are defined in gtest-port.h. // for Google Test and are defined in gtest-port.h.
#include <gtest/internal/gtest-linked_ptr.h> #include <gtest/internal/gtest-linked_ptr.h>
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
// To avoid conditional compilation everywhere, we make it // To avoid conditional compilation everywhere, we make it
// gmock-port.h's responsibility to #include the header implementing // gmock-port.h's responsibility to #include the header implementing
// tr1/tuple. // tr1/tuple. gmock-port.h does this via gtest-port.h, which is
#if defined(__GNUC__) // guaranteed to pull in the tuple header.
// GCC implements tr1/tuple in the <tr1/tuple> header. This does not
// conform to the TR1 spec, which requires the header to be <tuple>.
#include <tr1/tuple>
#else
// If the compiler is not GCC, we assume the user is using a
// spec-conforming TR1 implementation.
#include <tuple>
#endif // __GNUC__
#if GTEST_OS_LINUX #if GTEST_OS_LINUX
// On some platforms, <regex.h> needs someone to define size_t, and // On some platforms, <regex.h> needs someone to define size_t, and
// won't compile otherwise. We can #include it here as we already // won't compile otherwise. We can #include it here as we already
// included <stdlib.h>, which is guaranteed to define size_t through // included <stdlib.h>, which is guaranteed to define size_t through
// <stddef.h>. // <stddef.h>.
#include <regex.h> // NOLINT #include <regex.h> // NOLINT
// Defines this iff Google Mock uses the enhanced POSIX regular // Defines this iff Google Mock uses the enhanced POSIX regular
skipping to change at line 86 skipping to change at line 78
#if defined(GMOCK_USES_PCRE) || defined(GMOCK_USES_POSIX_RE) #if defined(GMOCK_USES_PCRE) || defined(GMOCK_USES_POSIX_RE)
// Defines this iff regular expression matchers are supported. This // Defines this iff regular expression matchers are supported. This
// is public as it tells a user whether he can use regular expression // is public as it tells a user whether he can use regular expression
// matchers. // matchers.
#define GMOCK_HAS_REGEX 1 #define GMOCK_HAS_REGEX 1
#endif // defined(GMOCK_USES_PCRE) || defined(GMOCK_USES_POSIX_RE) #endif // defined(GMOCK_USES_PCRE) || defined(GMOCK_USES_POSIX_RE)
namespace testing { namespace testing {
namespace internal { namespace internal {
// For Windows, check the compiler version. At least VS 2005 SP1 is // For MS Visual C++, check the compiler version. At least VS 2003 is
// required to compile Google Mock. // required to compile Google Mock.
#if GTEST_OS_WINDOWS #if defined(_MSC_VER) && _MSC_VER < 1310
#error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
#if _MSC_VER < 1400 #endif
#error "At least Visual Studio 2005 SP1 is required to compile Google Mock.
"
#elif _MSC_VER == 1400
// Unfortunately there is no unique _MSC_VER number for SP1. So for VS 2005
// we have to check if it has SP1 by checking whether a bug fixed in SP1
// is present. The bug in question is
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Fee
dbackID=101702
// where the compiler incorrectly reports sizeof(poiter to an array).
class TestForSP1 {
private: // GCC complains if x_ is used by sizeof before defining it.
static char x_[100];
// VS 2005 RTM incorrectly reports sizeof(&x) as 100, and that value
// is used to trigger 'invalid negative array size' error. If you
// see this error, upgrade to VS 2005 SP1 since Google Mock will not
// compile in VS 2005 RTM.
static char Google_Mock_requires_Visual_Studio_2005_SP1_or_later_to_compi
le_[
sizeof(&x_) != 100 ? 1 : -1];
};
#endif // _MSC_VER
#endif // GTEST_OS_WINDOWS
// Use implicit_cast as a safe version of static_cast or const_cast // Use implicit_cast as a safe version of static_cast or const_cast
// for upcasting in the type hierarchy (i.e. casting a pointer to Foo // for upcasting in the type hierarchy (i.e. casting a pointer to Foo
// to a pointer to SuperclassOfFoo or casting a pointer to Foo to // to a pointer to SuperclassOfFoo or casting a pointer to Foo to
// a const pointer to Foo). // a const pointer to Foo).
// When you use implicit_cast, the compiler checks that the cast is safe. // When you use implicit_cast, the compiler checks that the cast is safe.
// Such explicit implicit_casts are necessary in surprisingly many // Such explicit implicit_casts are necessary in surprisingly many
// situations where C++ demands an exact type match instead of an // situations where C++ demands an exact type match instead of an
// argument type convertable to a target type. // argument type convertable to a target type.
// //
skipping to change at line 163 skipping to change at line 133
template<typename To, typename From> // use like this: down_cast<T*>(foo); template<typename To, typename From> // use like this: down_cast<T*>(foo);
inline To down_cast(From* f) { // so we only accept pointers inline To down_cast(From* f) { // so we only accept pointers
// Ensures that To is a sub-type of From *. This test is here only // Ensures that To is a sub-type of From *. This test is here only
// for compile-time type checking, and has no overhead in an // for compile-time type checking, and has no overhead in an
// optimized build at run-time, as it will be optimized away // optimized build at run-time, as it will be optimized away
// completely. // completely.
if (false) { if (false) {
implicit_cast<From*, To>(0); implicit_cast<From*, To>(0);
} }
#if GTEST_HAS_RTTI
assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode on ly! assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode on ly!
#endif
return static_cast<To>(f); return static_cast<To>(f);
} }
// The GMOCK_COMPILE_ASSERT macro can be used to verify that a compile time // The GMOCK_COMPILE_ASSERT_ macro can be used to verify that a compile tim e
// expression is true. For example, you could use it to verify the // expression is true. For example, you could use it to verify the
// size of a static array: // size of a static array:
// //
// GMOCK_COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPE // GMOCK_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYP
S, ES,
// content_type_names_incorrect_size); // content_type_names_incorrect_size);
// //
// or to make sure a struct is smaller than a certain size: // or to make sure a struct is smaller than a certain size:
// //
// GMOCK_COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); // GMOCK_COMPILE_ASSERT_(sizeof(foo) < 128, foo_too_large);
// //
// The second argument to the macro is the name of the variable. If // The second argument to the macro is the name of the variable. If
// the expression is false, most compilers will issue a warning/error // the expression is false, most compilers will issue a warning/error
// containing the name of the variable. // containing the name of the variable.
template <bool> template <bool>
struct CompileAssert { struct CompileAssert {
}; };
#define GMOCK_COMPILE_ASSERT_(expr, msg) \ #define GMOCK_COMPILE_ASSERT_(expr, msg) \
skipping to change at line 245 skipping to change at line 217
#else #else
#error "Google Mock requires ::std::string to compile." #error "Google Mock requires ::std::string to compile."
#endif // GTEST_HAS_GLOBAL_STRING #endif // GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_GLOBAL_WSTRING #if GTEST_HAS_GLOBAL_WSTRING
typedef ::wstring wstring; typedef ::wstring wstring;
#elif GTEST_HAS_STD_WSTRING #elif GTEST_HAS_STD_WSTRING
typedef ::std::wstring wstring; typedef ::std::wstring wstring;
#endif // GTEST_HAS_GLOBAL_WSTRING #endif // GTEST_HAS_GLOBAL_WSTRING
// INTERNAL IMPLEMENTATION - DO NOT USE.
//
// GMOCK_CHECK_ is an all mode assert. It aborts the program if the conditi
on
// is not satisfied.
// Synopsys:
// GMOCK_CHECK_(boolean_condition);
// or
// GMOCK_CHECK_(boolean_condition) << "Additional message";
//
// This checks the condition and if the condition is not satisfied
// it prints message about the condition violation, including the
// condition itself, plus additional message streamed into it, if any,
// and then it aborts the program. It aborts the program irrespective of
// whether it is built in the debug mode or not.
class GMockCheckProvider {
public:
GMockCheckProvider(const char* condition, const char* file, int line) {
FormatFileLocation(file, line);
::std::cerr << " ERROR: Condition " << condition << " failed. ";
}
~GMockCheckProvider() {
::std::cerr << ::std::endl;
abort();
}
void FormatFileLocation(const char* file, int line) {
if (file == NULL)
file = "unknown file";
if (line < 0) {
::std::cerr << file << ":";
} else {
#if _MSC_VER
::std::cerr << file << "(" << line << "):";
#else
::std::cerr << file << ":" << line << ":";
#endif
}
}
::std::ostream& GetStream() { return ::std::cerr; }
};
#define GMOCK_CHECK_(condition) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (condition) \
; \
else \
::testing::internal::GMockCheckProvider(\
#condition, __FILE__, __LINE__).GetStream()
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
// Macro for referencing flags. This is public as we want the user to // Macro for referencing flags. This is public as we want the user to
// use this syntax to reference Google Mock flags. // use this syntax to reference Google Mock flags.
#define GMOCK_FLAG(name) FLAGS_gmock_##name #define GMOCK_FLAG(name) FLAGS_gmock_##name
// Macros for declaring flags. // Macros for declaring flags.
#define GMOCK_DECLARE_bool_(name) extern bool GMOCK_FLAG(name) #define GMOCK_DECLARE_bool_(name) extern bool GMOCK_FLAG(name)
#define GMOCK_DECLARE_int32_(name) \ #define GMOCK_DECLARE_int32_(name) \
 End of changes. 9 change blocks. 
93 lines changed or deleted 13 lines changed or added


 gmock-printers.h   gmock-printers.h 
skipping to change at line 39 skipping to change at line 39
// //
// Author: wan@google.com (Zhanyong Wan) // Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements a universal value printer that can print a // This file implements a universal value printer that can print a
// value of any type T: // value of any type T:
// //
// void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_pt r); // void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_pt r);
// //
// It uses the << operator when possible, and prints the bytes in the // A user can teach this function how to print a class type T by
// object otherwise. A user can override its behavior for a class // defining either operator<<() or PrintTo() in the namespace that
// type Foo by defining either operator<<(::std::ostream&, const Foo&) // defines T. More specifically, the FIRST defined function in the
// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that // following list will be used (assuming T is defined in namespace
// defines Foo. If both are defined, PrintTo() takes precedence. // foo):
//
// 1. foo::PrintTo(const T&, ostream*)
// 2. operator<<(ostream&, const T&) defined in either foo or the
// global namespace.
//
// If none of the above is defined, it will print the debug string of
// the value if it is a protocol buffer, or print the raw bytes in the
// value otherwise.
// //
// To aid debugging: when T is a reference type, the address of the // To aid debugging: when T is a reference type, the address of the
// value is also printed; when T is a (const) char pointer, both the // value is also printed; when T is a (const) char pointer, both the
// pointer value and the NUL-terminated string it points to are // pointer value and the NUL-terminated string it points to are
// printed. // printed.
// //
// We also provide some convenient wrappers: // We also provide some convenient wrappers:
// //
// // Prints a value as the given type to a string. // // Prints a value as the given type to a string.
// string ::testing::internal::UniversalPrinter<T>::PrintToString(value); // string ::testing::internal::UniversalPrinter<T>::PrintToString(value);
// //
// // Prints a value tersely: for a reference type, the referenced // // Prints a value tersely: for a reference type, the referenced
// // value (but not the address) is printed; for a (const) char // // value (but not the address) is printed; for a (const) char
// // pointer, the NUL-terminated string (but not the pointer) is // // pointer, the NUL-terminated string (but not the pointer) is
// // printed. // // printed.
// void ::testing::internal::UniversalTersePrint(const T& value, ostream* ); // void ::testing::internal::UniversalTersePrint(const T& value, ostream* );
// //
// // Prints value using the type inferred by the compiler. The differen
ce
// // from UniversalTersePrint() is that this function prints both the
// // pointer and the NUL-terminated string for a (const) char pointer.
// void ::testing::internal::UniversalPrint(const T& value, ostream*);
//
// // Prints the fields of a tuple tersely to a string vector, one // // Prints the fields of a tuple tersely to a string vector, one
// // element for each field. // // element for each field.
// std::vector<string> UniversalTersePrintTupleFieldsToStrings( // std::vector<string> UniversalTersePrintTupleFieldsToStrings(
// const Tuple& value); // const Tuple& value);
//
// Known limitation:
//
// The print primitives print the elements of an STL-style container
// using the compiler-inferred type of *iter where iter is a
// const_iterator of the container. When const_iterator is an input
// iterator but not a forward iterator, this inferred type may not
// match value_type, and the print output may be incorrect. In
// practice, this is rarely a problem as for most containers
// const_iterator is a forward iterator. We'll fix this if there's an
// actual need for it. Note that this fix cannot rely on value_type
// being defined as many user-defined container types don't have
// value_type.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_PRINTERS_H_
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <gmock/internal/gmock-internal-utils.h> #include <gmock/internal/gmock-internal-utils.h>
#include <gmock/internal/gmock-port.h> #include <gmock/internal/gmock-port.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
// Makes sure there is at least one << operator declared in the global
// namespace. This has no implementation and won't be called
// anywhere. We just need the declaration such that we can say "using
// ::operator <<;" in the definition of PrintTo() below.
void operator<<(::testing::internal::Unused, int);
namespace testing { namespace testing {
// Definitions in the 'internal' and 'internal2' name spaces are // Definitions in the 'internal' and 'internal2' name spaces are
// subject to change without notice. DO NOT USE THEM IN USER CODE! // subject to change without notice. DO NOT USE THEM IN USER CODE!
namespace internal2 { namespace internal2 {
// Prints the given number of bytes in the given object to the given // Prints the given number of bytes in the given object to the given
// ostream. // ostream.
void PrintBytesInObjectTo(const unsigned char* obj_bytes, void PrintBytesInObjectTo(const unsigned char* obj_bytes,
size_t count, size_t count,
skipping to change at line 112 skipping to change at line 132
// value will be printed; otherwise kIsProto will be false and the // value will be printed; otherwise kIsProto will be false and the
// bytes in the value will be printed. // bytes in the value will be printed.
template <typename T, bool kIsProto> template <typename T, bool kIsProto>
class TypeWithoutFormatter { class TypeWithoutFormatter {
public: public:
static void PrintValue(const T& value, ::std::ostream* os) { static void PrintValue(const T& value, ::std::ostream* os) {
PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value), PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),
sizeof(value), os); sizeof(value), os);
} }
}; };
// We print a protobuf using its ShortDebugString() when the string
// doesn't exceed this many characters; otherwise we print it using
// DebugString() for better readability.
const size_t kProtobufOneLinerMaxLength = 50;
template <typename T> template <typename T>
class TypeWithoutFormatter<T, true> { class TypeWithoutFormatter<T, true> {
public: public:
static void PrintValue(const T& value, ::std::ostream* os) { static void PrintValue(const T& value, ::std::ostream* os) {
// Both ProtocolMessage and proto2::Message have the const ::testing::internal::string short_str = value.ShortDebugString();
// ShortDebugString() method, so the same implementation works for const ::testing::internal::string pretty_str =
// both. short_str.length() <= kProtobufOneLinerMaxLength ?
::std::operator<<(*os, "<" + value.ShortDebugString() + ">"); short_str : ("\n" + value.DebugString());
::std::operator<<(*os, "<" + pretty_str + ">");
} }
}; };
// Prints the given value to the given ostream. If the value is a // Prints the given value to the given ostream. If the value is a
// protocol message, its short debug string is printed; otherwise the // protocol message, its short debug string is printed; otherwise the
// bytes in the value are printed. This is what // bytes in the value are printed. This is what
// UniversalPrinter<T>::Print() does when it knows nothing about type // UniversalPrinter<T>::Print() does when it knows nothing about type
// T and T has no << operator. // T and T has no << operator.
// //
// A user can override this behavior for a class type Foo by defining // A user can override this behavior for a class type Foo by defining
skipping to change at line 155 skipping to change at line 182
// specific. // specific.
template <typename Char, typename CharTraits, typename T> template <typename Char, typename CharTraits, typename T>
::std::basic_ostream<Char, CharTraits>& operator<<( ::std::basic_ostream<Char, CharTraits>& operator<<(
::std::basic_ostream<Char, CharTraits>& os, const T& x) { ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
TypeWithoutFormatter<T, ::testing::internal::IsAProtocolMessage<T>::value >:: TypeWithoutFormatter<T, ::testing::internal::IsAProtocolMessage<T>::value >::
PrintValue(x, &os); PrintValue(x, &os);
return os; return os;
} }
} // namespace internal2 } // namespace internal2
} // namespace testing
// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
// magic needed for implementing UniversalPrinter won't work.
namespace testing_internal {
// Used to print a value that is not an STL-style container when the
// user doesn't define PrintTo() for it.
template <typename T>
void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
// With the following statement, during unqualified name lookup,
// testing::internal2::operator<< appears as if it was declared in
// the nearest enclosing namespace that contains both
// ::testing_internal and ::testing::internal2, i.e. the global
// namespace. For more details, refer to the C++ Standard section
// 7.3.4-1 [namespace.udir]. This allows us to fall back onto
// testing::internal2::operator<< in case T doesn't come with a <<
// operator.
//
// We cannot write 'using ::testing::internal2::operator<<;', which
// gcc 3.3 fails to compile due to a compiler bug.
using namespace ::testing::internal2; // NOLINT
// Assuming T is defined in namespace foo, in the next statement,
// the compiler will consider all of:
//
// 1. foo::operator<< (thanks to Koenig look-up),
// 2. ::operator<< (as the current namespace is enclosed in ::),
// 3. testing::internal2::operator<< (thanks to the using statement abo
ve).
//
// The operator<< whose type matches T best will be picked.
//
// We deliberately allow #2 to be a candidate, as sometimes it's
// impossible to define #1 (e.g. when foo is ::std, defining
// anything in it is undefined behavior unless you are a compiler
// vendor.).
*os << value;
}
} // namespace testing_internal
namespace testing {
namespace internal { namespace internal {
// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
// value to the given ostream. The caller must ensure that // value to the given ostream. The caller must ensure that
// 'ostream_ptr' is not NULL, or the behavior is undefined. // 'ostream_ptr' is not NULL, or the behavior is undefined.
// //
// We define UniversalPrinter as a class template (as opposed to a // We define UniversalPrinter as a class template (as opposed to a
// function template), as we need to partially specialize it for // function template), as we need to partially specialize it for
// reference types, which cannot be done with function templates. // reference types, which cannot be done with function templates.
template <typename T> template <typename T>
class UniversalPrinter; class UniversalPrinter;
template <typename T>
void UniversalPrint(const T& value, ::std::ostream* os);
// Used to print an STL-style container when the user doesn't define // Used to print an STL-style container when the user doesn't define
// a PrintTo() for it. // a PrintTo() for it.
template <typename C> template <typename C>
void DefaultPrintTo(IsContainer, const C& container, ::std::ostream* os) { void DefaultPrintTo(IsContainer /* dummy */,
false_type /* is not a pointer */,
const C& container, ::std::ostream* os) {
const size_t kMaxCount = 32; // The maximum number of elements to print. const size_t kMaxCount = 32; // The maximum number of elements to print.
*os << '{'; *os << '{';
size_t count = 0; size_t count = 0;
for (typename C::const_iterator it = container.begin(); for (typename C::const_iterator it = container.begin();
it != container.end(); ++it, ++count) { it != container.end(); ++it, ++count) {
if (count > 0) { if (count > 0) {
*os << ','; *os << ',';
if (count == kMaxCount) { // Enough has been printed. if (count == kMaxCount) { // Enough has been printed.
*os << " ..."; *os << " ...";
break; break;
} }
} }
*os << ' '; *os << ' ';
PrintTo(*it, os); // We cannot call PrintTo(*it, os) here as PrintTo() doesn't
// handle *it being a native array.
internal::UniversalPrint(*it, os);
} }
if (count > 0) { if (count > 0) {
*os << ' '; *os << ' ';
} }
*os << '}'; *os << '}';
} }
// Used to print a value when the user doesn't define PrintTo() for it. // Used to print a pointer that is neither a char pointer nor a member
// pointer, when the user doesn't define PrintTo() for it. (A member
// variable pointer or member function pointer doesn't really point to
// a location in the address space. Their representation is
// implementation-defined. Therefore they will be printed as raw
// bytes.)
template <typename T> template <typename T>
void DefaultPrintTo(IsNotContainer, const T& value, ::std::ostream* os) { void DefaultPrintTo(IsNotContainer /* dummy */,
// If T has its << operator defined in the global namespace, which true_type /* is a pointer */,
// is not recommended but sometimes unavoidable (as in T* p, ::std::ostream* os) {
// util/gtl/stl_logging-inl.h), the following statement makes it if (p == NULL) {
// visible in this function. *os << "NULL";
// } else {
// Without the statement, << in the global namespace would be hidden // We want to print p as a const void*. However, we cannot cast
// by the one in ::testing::internal2, due to the next using // it to const void* directly, even using reinterpret_cast, as
// statement. // earlier versions of gcc (e.g. 3.4.5) cannot compile the cast
using ::operator <<; // when p is a function pointer. Casting to UInt64 first solves
// the problem.
// When T doesn't come with a << operator, we want to fall back to *os << reinterpret_cast<const void*>(reinterpret_cast<internal::UInt64>
// the one defined in ::testing::internal2, which prints the bytes in (p));
// the value. }
using ::testing::internal2::operator <<; }
// Thanks to Koenig look-up, if type T has its own << operator // Used to print a non-container, non-pointer value when the user
// defined in its namespace, which is the recommended way, that // doesn't define PrintTo() for it.
// operator will be visible here. Since it is more specific than template <typename T>
// the generic one, it will be picked by the compiler in the void DefaultPrintTo(IsNotContainer /* dummy */,
// following statement - exactly what we want. false_type /* is not a pointer */,
*os << value; const T& value, ::std::ostream* os) {
::testing_internal::DefaultPrintNonContainerTo(value, os);
} }
// Prints the given value using the << operator if it has one; // Prints the given value using the << operator if it has one;
// otherwise prints the bytes in it. This is what // otherwise prints the bytes in it. This is what
// UniversalPrinter<T>::Print() does when PrintTo() is not specialized // UniversalPrinter<T>::Print() does when PrintTo() is not specialized
// or overloaded for type T. // or overloaded for type T.
// //
// A user can override this behavior for a class type Foo by defining // A user can override this behavior for a class type Foo by defining
// an overload of PrintTo() in the namespace where Foo is defined. We // an overload of PrintTo() in the namespace where Foo is defined. We
// give the user this option as sometimes defining a << operator for // give the user this option as sometimes defining a << operator for
// Foo is not desirable (e.g. the coding style may prevent doing it, // Foo is not desirable (e.g. the coding style may prevent doing it,
// or there is already a << operator but it doesn't do what the user // or there is already a << operator but it doesn't do what the user
// wants). // wants).
template <typename T> template <typename T>
void PrintTo(const T& value, ::std::ostream* os) { void PrintTo(const T& value, ::std::ostream* os) {
// DefaultPrintTo() is overloaded. The type of its first argument // DefaultPrintTo() is overloaded. The type of its first two
// determines which version will be picked. If T is an STL-style // arguments determine which version will be picked. If T is an
// container, the version for container will be called. Otherwise // STL-style container, the version for container will be called; if
// the generic version will be called. // T is a pointer, the pointer version will be called; otherwise the
// generic version will be called.
// //
// Note that we check for container types here, prior to we check // Note that we check for container types here, prior to we check
// for protocol message types in our operator<<. The rationale is: // for protocol message types in our operator<<. The rationale is:
// //
// For protocol messages, we want to give people a chance to // For protocol messages, we want to give people a chance to
// override Google Mock's format by defining a PrintTo() or // override Google Mock's format by defining a PrintTo() or
// operator<<. For STL containers, we believe the Google Mock's // operator<<. For STL containers, other formats can be
// format is superior to what util/gtl/stl-logging.h offers. // incompatible with Google Mock's format for the container
// Therefore we don't want it to be accidentally overridden by the // elements; therefore we check for container types here to ensure
// latter (even if the user includes stl-logging.h through other // that our format is used.
// headers indirectly, Google Mock's format will still be used). //
DefaultPrintTo(IsContainerTest<T>(0), value, os); // The second argument of DefaultPrintTo() is needed to bypass a bug
// in Symbian's C++ compiler that prevents it from picking the right
// overload between:
//
// PrintTo(const T& x, ...);
// PrintTo(T* x, ...);
DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);
} }
// The following list of PrintTo() overloads tells // The following list of PrintTo() overloads tells
// UniversalPrinter<T>::Print() how to print standard types (built-in // UniversalPrinter<T>::Print() how to print standard types (built-in
// types, strings, plain arrays, and pointers). // types, strings, plain arrays, and pointers).
// Overloads for various char types. // Overloads for various char types.
void PrintCharTo(char c, int char_code, ::std::ostream* os); void PrintCharTo(char c, int char_code, ::std::ostream* os);
inline void PrintTo(unsigned char c, ::std::ostream* os) { inline void PrintTo(unsigned char c, ::std::ostream* os) {
PrintCharTo(c, c, os); PrintCharTo(c, c, os);
skipping to change at line 290 skipping to change at line 377
// as a signed type and is printed as an unsigned integer when wchar_t // as a signed type and is printed as an unsigned integer when wchar_t
// is implemented as an unsigned type. // is implemented as an unsigned type.
void PrintTo(wchar_t wc, ::std::ostream* os); void PrintTo(wchar_t wc, ::std::ostream* os);
// Overloads for C strings. // Overloads for C strings.
void PrintTo(const char* s, ::std::ostream* os); void PrintTo(const char* s, ::std::ostream* os);
inline void PrintTo(char* s, ::std::ostream* os) { inline void PrintTo(char* s, ::std::ostream* os) {
PrintTo(implicit_cast<const char*>(s), os); PrintTo(implicit_cast<const char*>(s), os);
} }
// MSVC compiler can be configured to define whar_t as a typedef // MSVC can be configured to define wchar_t as a typedef of unsigned
// of unsigned short. Defining an overload for const wchar_t* in that case // short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
// would cause pointers to unsigned shorts be printed as wide strings, // type. When wchar_t is a typedef, defining an overload for const
// possibly accessing more memory than intended and causing invalid // wchar_t* would cause unsigned short* be printed as a wide string,
// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when // possibly causing invalid memory accesses.
// wchar_t is implemented as a native type.
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
// Overloads for wide C strings // Overloads for wide C strings
void PrintTo(const wchar_t* s, ::std::ostream* os); void PrintTo(const wchar_t* s, ::std::ostream* os);
inline void PrintTo(wchar_t* s, ::std::ostream* os) { inline void PrintTo(wchar_t* s, ::std::ostream* os) {
PrintTo(implicit_cast<const wchar_t*>(s), os); PrintTo(implicit_cast<const wchar_t*>(s), os);
} }
#endif #endif
// Overload for pointers that are neither char pointers nor member
// pointers. (A member variable pointer or member function pointer
// doesn't really points to a location in the address space. Their
// representation is implementation-defined. Therefore they will be
// printed as raw bytes.)
template <typename T>
void PrintTo(T* p, ::std::ostream* os) {
if (p == NULL) {
*os << "NULL";
} else {
// We cannot use implicit_cast or static_cast here, as they don't
// work when p is a function pointer.
*os << reinterpret_cast<const void*>(p);
}
}
// Overload for C arrays. Multi-dimensional arrays are printed // Overload for C arrays. Multi-dimensional arrays are printed
// properly. // properly.
// Prints the given number of elements in an array, without printing // Prints the given number of elements in an array, without printing
// the curly braces. // the curly braces.
template <typename T> template <typename T>
void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) { void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
UniversalPrinter<T>::Print(a[0], os); UniversalPrinter<T>::Print(a[0], os);
for (size_t i = 1; i != count; i++) { for (size_t i = 1; i != count; i++) {
*os << ", "; *os << ", ";
skipping to change at line 546 skipping to change at line 616
::std::stringstream ss; ::std::stringstream ss;
Print(value, &ss); Print(value, &ss);
return ss.str(); return ss.str();
} }
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#endif // _MSC_VER #endif // _MSC_VER
}; };
// UniversalPrintArray(begin, len, os) prints an array of 'len'
// elements, starting at address 'begin'.
template <typename T>
void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
if (len == 0) {
*os << "{}";
} else {
*os << "{ ";
const size_t kThreshold = 18;
const size_t kChunkSize = 8;
// If the array has more than kThreshold elements, we'll have to
// omit some details by printing only the first and the last
// kChunkSize elements.
// TODO(wan@google.com): let the user control the threshold using a fla
g.
if (len <= kThreshold) {
PrintRawArrayTo(begin, len, os);
} else {
PrintRawArrayTo(begin, kChunkSize, os);
*os << ", ..., ";
PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
}
*os << " }";
}
}
// This overload prints a (const) char array compactly.
void UniversalPrintArray(const char* begin, size_t len, ::std::ostream* os)
;
// Prints an array of 'len' elements, starting at address 'begin', to a str
ing.
template <typename T>
string UniversalPrintArrayToString(const T* begin, size_t len) {
::std::stringstream ss;
UniversalPrintArray(begin, len, &ss);
return ss.str();
}
// Implements printing an array type T[N]. // Implements printing an array type T[N].
template <typename T, size_t N> template <typename T, size_t N>
class UniversalPrinter<T[N]> { class UniversalPrinter<T[N]> {
public: public:
// Prints the given array, omitting some elements when there are too // Prints the given array, omitting some elements when there are too
// many. // many.
static void Print(const T (&a)[N], ::std::ostream* os) { static void Print(const T (&a)[N], ::std::ostream* os) {
// Prints a char array as a C string. Note that we compare 'const UniversalPrintArray(a, N, os);
// T' with 'const char' instead of comparing T with char, in case
// that T is already a const type.
if (internal::type_equals<const T, const char>::value) {
UniversalPrinter<const T*>::Print(a, os);
return;
}
if (N == 0) {
*os << "{}";
} else {
*os << "{ ";
const size_t kThreshold = 18;
const size_t kChunkSize = 8;
// If the array has more than kThreshold elements, we'll have to
// omit some details by printing only the first and the last
// kChunkSize elements.
// TODO(wan): let the user control the threshold using a flag.
if (N <= kThreshold) {
PrintRawArrayTo(a, N, os);
} else {
PrintRawArrayTo(a, kChunkSize, os);
*os << ", ..., ";
PrintRawArrayTo(a + N - kChunkSize, kChunkSize, os);
}
*os << " }";
}
} }
// A convenient wrapper for Print() that returns the print-out as a // A convenient wrapper for Print() that returns the print-out as a
// string. // string.
static string PrintToString(const T (&a)[N]) { static string PrintToString(const T (&a)[N]) {
::std::stringstream ss; return UniversalPrintArrayToString(a, N);
Print(a, &ss);
return ss.str();
} }
}; };
// Implements printing a reference type T&. // Implements printing a reference type T&.
template <typename T> template <typename T>
class UniversalPrinter<T&> { class UniversalPrinter<T&> {
public: public:
// MSVC warns about adding const to a function type, so we want to // MSVC warns about adding const to a function type, so we want to
// disable the warning. // disable the warning.
#ifdef _MSC_VER #ifdef _MSC_VER
skipping to change at line 642 skipping to change at line 719
if (str == NULL) { if (str == NULL) {
*os << "NULL"; *os << "NULL";
} else { } else {
UniversalPrinter<string>::Print(string(str), os); UniversalPrinter<string>::Print(string(str), os);
} }
} }
inline void UniversalTersePrint(char* str, ::std::ostream* os) { inline void UniversalTersePrint(char* str, ::std::ostream* os) {
UniversalTersePrint(static_cast<const char*>(str), os); UniversalTersePrint(static_cast<const char*>(str), os);
} }
// Prints a value using the type inferred by the compiler. The
// difference between this and UniversalTersePrint() is that for a
// (const) char pointer, this prints both the pointer and the
// NUL-terminated string.
template <typename T>
void UniversalPrint(const T& value, ::std::ostream* os) {
UniversalPrinter<T>::Print(value, os);
}
// Prints the fields of a tuple tersely to a string vector, one // Prints the fields of a tuple tersely to a string vector, one
// element for each field. See the comment before // element for each field. See the comment before
// UniversalTersePrint() for how we define "tersely". // UniversalTersePrint() for how we define "tersely".
template <typename Tuple> template <typename Tuple>
Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) { Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
Strings result; Strings result;
TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>:: TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
TersePrintPrefixToStrings(value, &result); TersePrintPrefixToStrings(value, &result);
return result; return result;
} }
 End of changes. 22 change blocks. 
101 lines changed or deleted 193 lines changed or added


 gmock-spec-builders.h   gmock-spec-builders.h 
skipping to change at line 40 skipping to change at line 40
// Author: wan@google.com (Zhanyong Wan) // Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements the ON_CALL() and EXPECT_CALL() macros. // This file implements the ON_CALL() and EXPECT_CALL() macros.
// //
// A user can use the ON_CALL() macro to specify the default action of // A user can use the ON_CALL() macro to specify the default action of
// a mock method. The syntax is: // a mock method. The syntax is:
// //
// ON_CALL(mock_object, Method(argument-matchers)) // ON_CALL(mock_object, Method(argument-matchers))
// .WithArguments(multi-argument-matcher) // .With(multi-argument-matcher)
// .WillByDefault(action); // .WillByDefault(action);
// //
// where the .WithArguments() clause is optional. // where the .With() clause is optional.
// //
// A user can use the EXPECT_CALL() macro to specify an expectation on // A user can use the EXPECT_CALL() macro to specify an expectation on
// a mock method. The syntax is: // a mock method. The syntax is:
// //
// EXPECT_CALL(mock_object, Method(argument-matchers)) // EXPECT_CALL(mock_object, Method(argument-matchers))
// .WithArguments(multi-argument-matchers) // .With(multi-argument-matchers)
// .Times(cardinality) // .Times(cardinality)
// .InSequence(sequences) // .InSequence(sequences)
// .After(expectations)
// .WillOnce(action) // .WillOnce(action)
// .WillRepeatedly(action) // .WillRepeatedly(action)
// .RetiresOnSaturation(); // .RetiresOnSaturation();
// //
// where all clauses are optional, .InSequence() and .WillOnce() can // where all clauses are optional, and .InSequence()/.After()/
// appear any number of times, and .Times() can be omitted only if // .WillOnce() can appear any number of times.
// .WillOnce() or .WillRepeatedly() is present.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#include <map> #include <map>
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <gmock/gmock-actions.h> #include <gmock/gmock-actions.h>
#include <gmock/gmock-cardinalities.h> #include <gmock/gmock-cardinalities.h>
#include <gmock/gmock-matchers.h> #include <gmock/gmock-matchers.h>
#include <gmock/gmock-printers.h> #include <gmock/gmock-printers.h>
#include <gmock/internal/gmock-internal-utils.h> #include <gmock/internal/gmock-internal-utils.h>
#include <gmock/internal/gmock-port.h> #include <gmock/internal/gmock-port.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace testing { namespace testing {
// An abstract handle of an expectation.
class Expectation;
// A set of expectation handles.
class ExpectationSet;
// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
// and MUST NOT BE USED IN USER CODE!!! // and MUST NOT BE USED IN USER CODE!!!
namespace internal { namespace internal {
template <typename F> // Implements a mock function.
class FunctionMocker; template <typename F> class FunctionMocker;
// Base class for expectations. // Base class for expectations.
class ExpectationBase; class ExpectationBase;
// Implements an expectation.
template <typename F> class TypedExpectation;
// Helper class for testing the Expectation class template. // Helper class for testing the Expectation class template.
class ExpectationTester; class ExpectationTester;
// Base class for function mockers. // Base class for function mockers.
template <typename F> template <typename F> class FunctionMockerBase;
class FunctionMockerBase;
// Helper class for implementing FunctionMockerBase<F>::InvokeWith().
template <typename Result, typename F>
class InvokeWithHelper;
// Protects the mock object registry (in class Mock), all function // Protects the mock object registry (in class Mock), all function
// mockers, and all expectations. // mockers, and all expectations.
// //
// The reason we don't use more fine-grained protection is: when a // The reason we don't use more fine-grained protection is: when a
// mock function Foo() is called, it needs to consult its expectations // mock function Foo() is called, it needs to consult its expectations
// to see which one should be picked. If another thread is allowed to // to see which one should be picked. If another thread is allowed to
// call a mock function (either Foo() or a different one) at the same // call a mock function (either Foo() or a different one) at the same
// time, it could affect the "retired" attributes of Foo()'s // time, it could affect the "retired" attributes of Foo()'s
// expectations when InSequence() is used, and thus affect which // expectations when InSequence() is used, and thus affect which
skipping to change at line 146 skipping to change at line 150
typedef typename Function<F>::ArgumentTuple ArgumentTuple; typedef typename Function<F>::ArgumentTuple ArgumentTuple;
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
// Constructs a DefaultActionSpec object from the information inside // Constructs a DefaultActionSpec object from the information inside
// the parenthesis of an ON_CALL() statement. // the parenthesis of an ON_CALL() statement.
DefaultActionSpec(const char* file, int line, DefaultActionSpec(const char* file, int line,
const ArgumentMatcherTuple& matchers) const ArgumentMatcherTuple& matchers)
: file_(file), : file_(file),
line_(line), line_(line),
matchers_(matchers), matchers_(matchers),
extra_matcher_(_), // By default, extra_matcher_ should match anything. However,
last_clause_(NONE) { // we cannot initialize it with _ as that triggers a compiler
// bug in Symbian's C++ compiler (cannot decide between two
// overloaded constructors of Matcher<const ArgumentTuple&>).
extra_matcher_(A<const ArgumentTuple&>()),
last_clause_(kNone) {
} }
// Where in the source file was the default action spec defined? // Where in the source file was the default action spec defined?
const char* file() const { return file_; } const char* file() const { return file_; }
int line() const { return line_; } int line() const { return line_; }
// Implements the .WithArguments() clause. // Implements the .With() clause.
DefaultActionSpec& WithArguments(const Matcher<const ArgumentTuple&>& m) DefaultActionSpec& With(const Matcher<const ArgumentTuple&>& m) {
{
// Makes sure this is called at most once. // Makes sure this is called at most once.
ExpectSpecProperty(last_clause_ < WITH_ARGUMENTS, ExpectSpecProperty(last_clause_ < kWith,
".WithArguments() cannot appear " ".With() cannot appear "
"more than once in an ON_CALL()."); "more than once in an ON_CALL().");
last_clause_ = WITH_ARGUMENTS; last_clause_ = kWith;
extra_matcher_ = m; extra_matcher_ = m;
return *this; return *this;
} }
// Implements the .WillByDefault() clause. // Implements the .WillByDefault() clause.
DefaultActionSpec& WillByDefault(const Action<F>& action) { DefaultActionSpec& WillByDefault(const Action<F>& action) {
ExpectSpecProperty(last_clause_ < WILL_BY_DEFAULT, ExpectSpecProperty(last_clause_ < kWillByDefault,
".WillByDefault() must appear " ".WillByDefault() must appear "
"exactly once in an ON_CALL()."); "exactly once in an ON_CALL().");
last_clause_ = WILL_BY_DEFAULT; last_clause_ = kWillByDefault;
ExpectSpecProperty(!action.IsDoDefault(), ExpectSpecProperty(!action.IsDoDefault(),
"DoDefault() cannot be used in ON_CALL()."); "DoDefault() cannot be used in ON_CALL().");
action_ = action; action_ = action;
return *this; return *this;
} }
// Returns true iff the given arguments match the matchers. // Returns true iff the given arguments match the matchers.
bool Matches(const ArgumentTuple& args) const { bool Matches(const ArgumentTuple& args) const {
return TupleMatches(matchers_, args) && extra_matcher_.Matches(args); return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
} }
// Returns the action specified by the user. // Returns the action specified by the user.
const Action<F>& GetAction() const { const Action<F>& GetAction() const {
AssertSpecProperty(last_clause_ == WILL_BY_DEFAULT, AssertSpecProperty(last_clause_ == kWillByDefault,
".WillByDefault() must appear exactly " ".WillByDefault() must appear exactly "
"once in an ON_CALL()."); "once in an ON_CALL().");
return action_; return action_;
} }
private: private:
// Gives each clause in the ON_CALL() statement a name. // Gives each clause in the ON_CALL() statement a name.
enum Clause { enum Clause {
// Do not change the order of the enum members! The run-time // Do not change the order of the enum members! The run-time
// syntax checking relies on it. // syntax checking relies on it.
NONE, kNone,
WITH_ARGUMENTS, kWith,
WILL_BY_DEFAULT, kWillByDefault,
}; };
// Asserts that the ON_CALL() statement has a certain property. // Asserts that the ON_CALL() statement has a certain property.
void AssertSpecProperty(bool property, const string& failure_message) con st { void AssertSpecProperty(bool property, const string& failure_message) con st {
Assert(property, file_, line_, failure_message); Assert(property, file_, line_, failure_message);
} }
// Expects that the ON_CALL() statement has a certain property. // Expects that the ON_CALL() statement has a certain property.
void ExpectSpecProperty(bool property, const string& failure_message) con st { void ExpectSpecProperty(bool property, const string& failure_message) con st {
Expect(property, file_, line_, failure_message); Expect(property, file_, line_, failure_message);
} }
// The information in statement // The information in statement
// //
// ON_CALL(mock_object, Method(matchers)) // ON_CALL(mock_object, Method(matchers))
// .WithArguments(multi-argument-matcher) // .With(multi-argument-matcher)
// .WillByDefault(action); // .WillByDefault(action);
// //
// is recorded in the data members like this: // is recorded in the data members like this:
// //
// source file that contains the statement => file_ // source file that contains the statement => file_
// line number of the statement => line_ // line number of the statement => line_
// matchers => matchers_ // matchers => matchers_
// multi-argument-matcher => extra_matcher_ // multi-argument-matcher => extra_matcher_
// action => action_ // action => action_
const char* file_; const char* file_;
int line_; int line_;
ArgumentMatcherTuple matchers_; ArgumentMatcherTuple matchers_;
Matcher<const ArgumentTuple&> extra_matcher_; Matcher<const ArgumentTuple&> extra_matcher_;
Action<F> action_; Action<F> action_;
// The last clause in the ON_CALL() statement as seen so far. // The last clause in the ON_CALL() statement as seen so far.
// Initially NONE and changes as the statement is parsed. // Initially kNone and changes as the statement is parsed.
Clause last_clause_; Clause last_clause_;
}; // class DefaultActionSpec }; // class DefaultActionSpec
// Possible reactions on uninteresting calls. // Possible reactions on uninteresting calls. TODO(wan@google.com):
// rename the enum values to the kFoo style.
enum CallReaction { enum CallReaction {
ALLOW, ALLOW,
WARN, WARN,
FAIL, FAIL,
}; };
} // namespace internal } // namespace internal
// Utilities for manipulating mock objects. // Utilities for manipulating mock objects.
class Mock { class Mock {
public: public:
// The following public methods can be called concurrently. // The following public methods can be called concurrently.
// Tells Google Mock to ignore mock_obj when checking for leaked
// mock objects.
static void AllowLeak(const void* mock_obj);
// Verifies and clears all expectations on the given mock object. // Verifies and clears all expectations on the given mock object.
// If the expectations aren't satisfied, generates one or more // If the expectations aren't satisfied, generates one or more
// Google Test non-fatal failures and returns false. // Google Test non-fatal failures and returns false.
static bool VerifyAndClearExpectations(void* mock_obj); static bool VerifyAndClearExpectations(void* mock_obj);
// Verifies all expectations on the given mock object and clears its // Verifies all expectations on the given mock object and clears its
// default actions and expectations. Returns true iff the // default actions and expectations. Returns true iff the
// verification was successful. // verification was successful.
static bool VerifyAndClear(void* mock_obj); static bool VerifyAndClear(void* mock_obj);
private: private:
// Needed for a function mocker to register itself (so that we know // Needed for a function mocker to register itself (so that we know
// how to clear a mock object). // how to clear a mock object).
template <typename F> template <typename F>
friend class internal::FunctionMockerBase; friend class internal::FunctionMockerBase;
template <typename R, typename Args>
friend class internal::InvokeWithHelper;
template <typename M> template <typename M>
friend class NiceMock; friend class NiceMock;
template <typename M> template <typename M>
friend class StrictMock; friend class StrictMock;
// Tells Google Mock to allow uninteresting calls on the given mock // Tells Google Mock to allow uninteresting calls on the given mock
// object. // object.
// L < g_gmock_mutex // L < g_gmock_mutex
static void AllowUninterestingCalls(const void* mock_obj); static void AllowUninterestingCalls(const void* mock_obj);
skipping to change at line 314 skipping to change at line 324
// Clears all ON_CALL()s set on the given mock object. // Clears all ON_CALL()s set on the given mock object.
// L >= g_gmock_mutex // L >= g_gmock_mutex
static void ClearDefaultActionsLocked(void* mock_obj); static void ClearDefaultActionsLocked(void* mock_obj);
// Registers a mock object and a mock method it owns. // Registers a mock object and a mock method it owns.
// L < g_gmock_mutex // L < g_gmock_mutex
static void Register(const void* mock_obj, static void Register(const void* mock_obj,
internal::UntypedFunctionMockerBase* mocker); internal::UntypedFunctionMockerBase* mocker);
// Tells Google Mock where in the source code mock_obj is used in an
// ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
// information helps the user identify which object it is.
// L < g_gmock_mutex
static void RegisterUseByOnCallOrExpectCall(
const void* mock_obj, const char* file, int line);
// Unregisters a mock method; removes the owning mock object from // Unregisters a mock method; removes the owning mock object from
// the registry when the last mock method associated with it has // the registry when the last mock method associated with it has
// been unregistered. This is called only in the destructor of // been unregistered. This is called only in the destructor of
// FunctionMockerBase. // FunctionMockerBase.
// L >= g_gmock_mutex // L >= g_gmock_mutex
static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker) ; static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker) ;
}; // class Mock }; // class Mock
// An abstract handle of an expectation. Useful in the .After()
// clause of EXPECT_CALL() for setting the (partial) order of
// expectations. The syntax:
//
// Expectation e1 = EXPECT_CALL(...)...;
// EXPECT_CALL(...).After(e1)...;
//
// sets two expectations where the latter can only be matched after
// the former has been satisfied.
//
// Notes:
// - This class is copyable and has value semantics.
// - Constness is shallow: a const Expectation object itself cannot
// be modified, but the mutable methods of the ExpectationBase
// object it references can be called via expectation_base().
// - The constructors and destructor are defined out-of-line because
// the Symbian WINSCW compiler wants to otherwise instantiate them
// when it sees this class definition, at which point it doesn't have
// ExpectationBase available yet, leading to incorrect destruction
// in the linked_ptr (or compilation errors if using a checking
// linked_ptr).
class Expectation {
public:
// Constructs a null object that doesn't reference any expectation.
Expectation();
~Expectation();
// This single-argument ctor must not be explicit, in order to support th
e
// Expectation e = EXPECT_CALL(...);
// syntax.
//
// A TypedExpectation object stores its pre-requisites as
// Expectation objects, and needs to call the non-const Retire()
// method on the ExpectationBase objects they reference. Therefore
// Expectation must receive a *non-const* reference to the
// ExpectationBase object.
Expectation(internal::ExpectationBase& exp); // NOLINT
// The compiler-generated copy ctor and operator= work exactly as
// intended, so we don't need to define our own.
// Returns true iff rhs references the same expectation as this object do
es.
bool operator==(const Expectation& rhs) const {
return expectation_base_ == rhs.expectation_base_;
}
bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }
private:
friend class ExpectationSet;
friend class Sequence;
friend class ::testing::internal::ExpectationBase;
template <typename F>
friend class ::testing::internal::FunctionMockerBase;
template <typename F>
friend class ::testing::internal::TypedExpectation;
// This comparator is needed for putting Expectation objects into a set.
class Less {
public:
bool operator()(const Expectation& lhs, const Expectation& rhs) const {
return lhs.expectation_base_.get() < rhs.expectation_base_.get();
}
};
typedef ::std::set<Expectation, Less> Set;
Expectation(
const internal::linked_ptr<internal::ExpectationBase>& expectation_ba
se);
// Returns the expectation this object references.
const internal::linked_ptr<internal::ExpectationBase>&
expectation_base() const {
return expectation_base_;
}
// A linked_ptr that co-owns the expectation this handle references.
internal::linked_ptr<internal::ExpectationBase> expectation_base_;
};
// A set of expectation handles. Useful in the .After() clause of
// EXPECT_CALL() for setting the (partial) order of expectations. The
// syntax:
//
// ExpectationSet es;
// es += EXPECT_CALL(...)...;
// es += EXPECT_CALL(...)...;
// EXPECT_CALL(...).After(es)...;
//
// sets three expectations where the last one can only be matched
// after the first two have both been satisfied.
//
// This class is copyable and has value semantics.
class ExpectationSet {
public:
// A bidirectional iterator that can read a const element in the set.
typedef Expectation::Set::const_iterator const_iterator;
// An object stored in the set. This is an alias of Expectation.
typedef Expectation::Set::value_type value_type;
// Constructs an empty set.
ExpectationSet() {}
// This single-argument ctor must not be explicit, in order to support th
e
// ExpectationSet es = EXPECT_CALL(...);
// syntax.
ExpectationSet(internal::ExpectationBase& exp) { // NOLINT
*this += Expectation(exp);
}
// This single-argument ctor implements implicit conversion from
// Expectation and thus must not be explicit. This allows either an
// Expectation or an ExpectationSet to be used in .After().
ExpectationSet(const Expectation& e) { // NOLINT
*this += e;
}
// The compiler-generator ctor and operator= works exactly as
// intended, so we don't need to define our own.
// Returns true iff rhs contains the same set of Expectation objects
// as this does.
bool operator==(const ExpectationSet& rhs) const {
return expectations_ == rhs.expectations_;
}
bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs)
; }
// Implements the syntax
// expectation_set += EXPECT_CALL(...);
ExpectationSet& operator+=(const Expectation& e) {
expectations_.insert(e);
return *this;
}
int size() const { return static_cast<int>(expectations_.size()); }
const_iterator begin() const { return expectations_.begin(); }
const_iterator end() const { return expectations_.end(); }
private:
Expectation::Set expectations_;
};
// Sequence objects are used by a user to specify the relative order // Sequence objects are used by a user to specify the relative order
// in which the expectations should match. They are copyable (we rely // in which the expectations should match. They are copyable (we rely
// on the compiler-defined copy constructor and assignment operator). // on the compiler-defined copy constructor and assignment operator).
class Sequence { class Sequence {
public: public:
// Constructs an empty sequence. // Constructs an empty sequence.
Sequence() Sequence() : last_expectation_(new Expectation) {}
: last_expectation_(
new internal::linked_ptr<internal::ExpectationBase>(NULL)) {}
// Adds an expectation to this sequence. The caller must ensure // Adds an expectation to this sequence. The caller must ensure
// that no other thread is accessing this Sequence object. // that no other thread is accessing this Sequence object.
void AddExpectation( void AddExpectation(const Expectation& expectation) const;
const internal::linked_ptr<internal::ExpectationBase>& expectation) c
onst;
private: private:
// The last expectation in this sequence. We use a nested // The last expectation in this sequence. We use a linked_ptr here
// linked_ptr here because: // because Sequence objects are copyable and we want the copies to
// - Sequence objects are copyable, and we want the copies to act // be aliases. The linked_ptr allows the copies to co-own and share
// as aliases. The outer linked_ptr allows the copies to co-own // the same Expectation object.
// and share the same state. internal::linked_ptr<Expectation> last_expectation_;
// - An Expectation object is co-owned (via linked_ptr) by its
// FunctionMocker and its successors (other Expectation objects).
// Hence the inner linked_ptr.
internal::linked_ptr<internal::linked_ptr<internal::ExpectationBase> >
last_expectation_;
}; // class Sequence }; // class Sequence
// An object of this type causes all EXPECT_CALL() statements // An object of this type causes all EXPECT_CALL() statements
// encountered in its scope to be put in an anonymous sequence. The // encountered in its scope to be put in an anonymous sequence. The
// work is done in the constructor and destructor. You should only // work is done in the constructor and destructor. You should only
// create an InSequence object on the stack. // create an InSequence object on the stack.
// //
// The sole purpose for this class is to support easy definition of // The sole purpose for this class is to support easy definition of
// sequential expectations, e.g. // sequential expectations, e.g.
// //
skipping to change at line 426 skipping to change at line 584
// Describes the source file location of this expectation. // Describes the source file location of this expectation.
void DescribeLocationTo(::std::ostream* os) const { void DescribeLocationTo(::std::ostream* os) const {
*os << file() << ":" << line() << ": "; *os << file() << ":" << line() << ": ";
} }
// Describes how many times a function call matching this // Describes how many times a function call matching this
// expectation has occurred. // expectation has occurred.
// L >= g_gmock_mutex // L >= g_gmock_mutex
virtual void DescribeCallCountTo(::std::ostream* os) const = 0; virtual void DescribeCallCountTo(::std::ostream* os) const = 0;
protected: protected:
typedef std::set<linked_ptr<ExpectationBase>, friend class ::testing::Expectation;
LinkedPtrLessThan<ExpectationBase> >
ExpectationBaseSet;
enum Clause { enum Clause {
// Don't change the order of the enum members! // Don't change the order of the enum members!
NONE, kNone,
WITH_ARGUMENTS, kWith,
TIMES, kTimes,
IN_SEQUENCE, kInSequence,
WILL_ONCE, kAfter,
WILL_REPEATEDLY, kWillOnce,
RETIRES_ON_SATURATION, kWillRepeatedly,
kRetiresOnSaturation,
}; };
// Returns an Expectation object that references and co-owns this
// expectation.
virtual Expectation GetHandle() = 0;
// Asserts that the EXPECT_CALL() statement has the given property. // Asserts that the EXPECT_CALL() statement has the given property.
void AssertSpecProperty(bool property, const string& failure_message) con st { void AssertSpecProperty(bool property, const string& failure_message) con st {
Assert(property, file_, line_, failure_message); Assert(property, file_, line_, failure_message);
} }
// Expects that the EXPECT_CALL() statement has the given property. // Expects that the EXPECT_CALL() statement has the given property.
void ExpectSpecProperty(bool property, const string& failure_message) con st { void ExpectSpecProperty(bool property, const string& failure_message) con st {
Expect(property, file_, line_, failure_message); Expect(property, file_, line_, failure_message);
} }
skipping to change at line 513 skipping to change at line 674
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return cardinality().IsOverSaturatedByCallCount(call_count_); return cardinality().IsOverSaturatedByCallCount(call_count_);
} }
// Returns true iff all pre-requisites of this expectation are satisfied. // Returns true iff all pre-requisites of this expectation are satisfied.
// L >= g_gmock_mutex // L >= g_gmock_mutex
bool AllPrerequisitesAreSatisfied() const; bool AllPrerequisitesAreSatisfied() const;
// Adds unsatisfied pre-requisites of this expectation to 'result'. // Adds unsatisfied pre-requisites of this expectation to 'result'.
// L >= g_gmock_mutex // L >= g_gmock_mutex
void FindUnsatisfiedPrerequisites(ExpectationBaseSet* result) const; void FindUnsatisfiedPrerequisites(ExpectationSet* result) const;
// Returns the number this expectation has been invoked. // Returns the number this expectation has been invoked.
// L >= g_gmock_mutex // L >= g_gmock_mutex
int call_count() const { int call_count() const {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return call_count_; return call_count_;
} }
// Increments the number this expectation has been invoked. // Increments the number this expectation has been invoked.
// L >= g_gmock_mutex // L >= g_gmock_mutex
void IncrementCallCount() { void IncrementCallCount() {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
call_count_++; call_count_++;
} }
private: private:
friend class ::testing::Sequence; friend class ::testing::Sequence;
friend class ::testing::internal::ExpectationTester; friend class ::testing::internal::ExpectationTester;
template <typename Function> template <typename Function>
friend class Expectation; friend class TypedExpectation;
// This group of fields are part of the spec and won't change after // This group of fields are part of the spec and won't change after
// an EXPECT_CALL() statement finishes. // an EXPECT_CALL() statement finishes.
const char* file_; // The file that contains the expectation. const char* file_; // The file that contains the expectation.
int line_; // The line number of the expectation. int line_; // The line number of the expectation.
// True iff the cardinality is specified explicitly. // True iff the cardinality is specified explicitly.
bool cardinality_specified_; bool cardinality_specified_;
Cardinality cardinality_; // The cardinality of the expectatio n. Cardinality cardinality_; // The cardinality of the expectatio n.
// The immediate pre-requisites of this expectation. We use // The immediate pre-requisites (i.e. expectations that must be
// linked_ptr in the set because we want an Expectation object to be // satisfied before this expectation can be matched) of this
// co-owned by its FunctionMocker and its successors. This allows // expectation. We use linked_ptr in the set because we want an
// multiple mock objects to be deleted at different times. // Expectation object to be co-owned by its FunctionMocker and its
ExpectationBaseSet immediate_prerequisites_; // successors. This allows multiple mock objects to be deleted at
// different times.
ExpectationSet immediate_prerequisites_;
// This group of fields are the current state of the expectation, // This group of fields are the current state of the expectation,
// and can change as the mock function is called. // and can change as the mock function is called.
int call_count_; // How many times this expectation has been invoked. int call_count_; // How many times this expectation has been invoked.
bool retired_; // True iff this expectation has retired. bool retired_; // True iff this expectation has retired.
}; // class ExpectationBase }; // class ExpectationBase
// Impements an expectation for the given function type. // Impements an expectation for the given function type.
template <typename F> template <typename F>
class Expectation : public ExpectationBase { class TypedExpectation : public ExpectationBase {
public: public:
typedef typename Function<F>::ArgumentTuple ArgumentTuple; typedef typename Function<F>::ArgumentTuple ArgumentTuple;
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
typedef typename Function<F>::Result Result; typedef typename Function<F>::Result Result;
Expectation(FunctionMockerBase<F>* owner, const char* file, int line, TypedExpectation(FunctionMockerBase<F>* owner, const char* file, int line
const ArgumentMatcherTuple& m) ,
const ArgumentMatcherTuple& m)
: ExpectationBase(file, line), : ExpectationBase(file, line),
owner_(owner), owner_(owner),
matchers_(m), matchers_(m),
extra_matcher_(_), // By default, extra_matcher_ should match anything. However,
// we cannot initialize it with _ as that triggers a compiler
// bug in Symbian's C++ compiler (cannot decide between two
// overloaded constructors of Matcher<const ArgumentTuple&>).
extra_matcher_(A<const ArgumentTuple&>()),
repeated_action_specified_(false), repeated_action_specified_(false),
repeated_action_(DoDefault()), repeated_action_(DoDefault()),
retires_on_saturation_(false), retires_on_saturation_(false),
last_clause_(NONE), last_clause_(kNone),
action_count_checked_(false) {} action_count_checked_(false) {}
virtual ~Expectation() { virtual ~TypedExpectation() {
// Check the validity of the action count if it hasn't been done // Check the validity of the action count if it hasn't been done
// yet (for example, if the expectation was never used). // yet (for example, if the expectation was never used).
CheckActionCountIfNotDone(); CheckActionCountIfNotDone();
} }
// Implements the .WithArguments() clause. // Implements the .With() clause.
Expectation& WithArguments(const Matcher<const ArgumentTuple&>& m) { TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {
if (last_clause_ == WITH_ARGUMENTS) { if (last_clause_ == kWith) {
ExpectSpecProperty(false, ExpectSpecProperty(false,
".WithArguments() cannot appear " ".With() cannot appear "
"more than once in an EXPECT_CALL()."); "more than once in an EXPECT_CALL().");
} else { } else {
ExpectSpecProperty(last_clause_ < WITH_ARGUMENTS, ExpectSpecProperty(last_clause_ < kWith,
".WithArguments() must be the first " ".With() must be the first "
"clause in an EXPECT_CALL()."); "clause in an EXPECT_CALL().");
} }
last_clause_ = WITH_ARGUMENTS; last_clause_ = kWith;
extra_matcher_ = m; extra_matcher_ = m;
return *this; return *this;
} }
// Implements the .Times() clause. // Implements the .Times() clause.
Expectation& Times(const Cardinality& cardinality) { TypedExpectation& Times(const Cardinality& cardinality) {
if (last_clause_ ==TIMES) { if (last_clause_ ==kTimes) {
ExpectSpecProperty(false, ExpectSpecProperty(false,
".Times() cannot appear " ".Times() cannot appear "
"more than once in an EXPECT_CALL()."); "more than once in an EXPECT_CALL().");
} else { } else {
ExpectSpecProperty(last_clause_ < TIMES, ExpectSpecProperty(last_clause_ < kTimes,
".Times() cannot appear after " ".Times() cannot appear after "
".InSequence(), .WillOnce(), .WillRepeatedly(), " ".InSequence(), .WillOnce(), .WillRepeatedly(), "
"or .RetiresOnSaturation()."); "or .RetiresOnSaturation().");
} }
last_clause_ = TIMES; last_clause_ = kTimes;
ExpectationBase::SpecifyCardinality(cardinality); ExpectationBase::SpecifyCardinality(cardinality);
return *this; return *this;
} }
// Implements the .Times() clause. // Implements the .Times() clause.
Expectation& Times(int n) { TypedExpectation& Times(int n) {
return Times(Exactly(n)); return Times(Exactly(n));
} }
// Implements the .InSequence() clause. // Implements the .InSequence() clause.
Expectation& InSequence(const Sequence& s) { TypedExpectation& InSequence(const Sequence& s) {
ExpectSpecProperty(last_clause_ <= IN_SEQUENCE, ExpectSpecProperty(last_clause_ <= kInSequence,
".InSequence() cannot appear after .WillOnce()," ".InSequence() cannot appear after .After(),"
" .WillRepeatedly(), or " " .WillOnce(), .WillRepeatedly(), or "
".RetiresOnSaturation()."); ".RetiresOnSaturation().");
last_clause_ = IN_SEQUENCE; last_clause_ = kInSequence;
s.AddExpectation(owner_->GetLinkedExpectationBase(this)); s.AddExpectation(GetHandle());
return *this; return *this;
} }
Expectation& InSequence(const Sequence& s1, const Sequence& s2) { TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {
return InSequence(s1).InSequence(s2); return InSequence(s1).InSequence(s2);
} }
Expectation& InSequence(const Sequence& s1, const Sequence& s2, TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
const Sequence& s3) { const Sequence& s3) {
return InSequence(s1, s2).InSequence(s3); return InSequence(s1, s2).InSequence(s3);
} }
Expectation& InSequence(const Sequence& s1, const Sequence& s2, TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
const Sequence& s3, const Sequence& s4) { const Sequence& s3, const Sequence& s4) {
return InSequence(s1, s2, s3).InSequence(s4); return InSequence(s1, s2, s3).InSequence(s4);
} }
Expectation& InSequence(const Sequence& s1, const Sequence& s2, TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
const Sequence& s3, const Sequence& s4, const Sequence& s3, const Sequence& s4,
const Sequence& s5) { const Sequence& s5) {
return InSequence(s1, s2, s3, s4).InSequence(s5); return InSequence(s1, s2, s3, s4).InSequence(s5);
} }
// Implements that .After() clause.
TypedExpectation& After(const ExpectationSet& s) {
ExpectSpecProperty(last_clause_ <= kAfter,
".After() cannot appear after .WillOnce(),"
" .WillRepeatedly(), or "
".RetiresOnSaturation().");
last_clause_ = kAfter;
for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it
) {
immediate_prerequisites_ += *it;
}
return *this;
}
TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s
2) {
return After(s1).After(s2);
}
TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s
2,
const ExpectationSet& s3) {
return After(s1, s2).After(s3);
}
TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s
2,
const ExpectationSet& s3, const ExpectationSet& s
4) {
return After(s1, s2, s3).After(s4);
}
TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s
2,
const ExpectationSet& s3, const ExpectationSet& s
4,
const ExpectationSet& s5) {
return After(s1, s2, s3, s4).After(s5);
}
// Implements the .WillOnce() clause. // Implements the .WillOnce() clause.
Expectation& WillOnce(const Action<F>& action) { TypedExpectation& WillOnce(const Action<F>& action) {
ExpectSpecProperty(last_clause_ <= WILL_ONCE, ExpectSpecProperty(last_clause_ <= kWillOnce,
".WillOnce() cannot appear after " ".WillOnce() cannot appear after "
".WillRepeatedly() or .RetiresOnSaturation()."); ".WillRepeatedly() or .RetiresOnSaturation().");
last_clause_ = WILL_ONCE; last_clause_ = kWillOnce;
actions_.push_back(action); actions_.push_back(action);
if (!cardinality_specified()) { if (!cardinality_specified()) {
set_cardinality(Exactly(static_cast<int>(actions_.size()))); set_cardinality(Exactly(static_cast<int>(actions_.size())));
} }
return *this; return *this;
} }
// Implements the .WillRepeatedly() clause. // Implements the .WillRepeatedly() clause.
Expectation& WillRepeatedly(const Action<F>& action) { TypedExpectation& WillRepeatedly(const Action<F>& action) {
if (last_clause_ == WILL_REPEATEDLY) { if (last_clause_ == kWillRepeatedly) {
ExpectSpecProperty(false, ExpectSpecProperty(false,
".WillRepeatedly() cannot appear " ".WillRepeatedly() cannot appear "
"more than once in an EXPECT_CALL()."); "more than once in an EXPECT_CALL().");
} else { } else {
ExpectSpecProperty(last_clause_ < WILL_REPEATEDLY, ExpectSpecProperty(last_clause_ < kWillRepeatedly,
".WillRepeatedly() cannot appear " ".WillRepeatedly() cannot appear "
"after .RetiresOnSaturation()."); "after .RetiresOnSaturation().");
} }
last_clause_ = WILL_REPEATEDLY; last_clause_ = kWillRepeatedly;
repeated_action_specified_ = true; repeated_action_specified_ = true;
repeated_action_ = action; repeated_action_ = action;
if (!cardinality_specified()) { if (!cardinality_specified()) {
set_cardinality(AtLeast(static_cast<int>(actions_.size()))); set_cardinality(AtLeast(static_cast<int>(actions_.size())));
} }
// Now that no more action clauses can be specified, we check // Now that no more action clauses can be specified, we check
// whether their count makes sense. // whether their count makes sense.
CheckActionCountIfNotDone(); CheckActionCountIfNotDone();
return *this; return *this;
} }
// Implements the .RetiresOnSaturation() clause. // Implements the .RetiresOnSaturation() clause.
Expectation& RetiresOnSaturation() { TypedExpectation& RetiresOnSaturation() {
ExpectSpecProperty(last_clause_ < RETIRES_ON_SATURATION, ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
".RetiresOnSaturation() cannot appear " ".RetiresOnSaturation() cannot appear "
"more than once."); "more than once.");
last_clause_ = RETIRES_ON_SATURATION; last_clause_ = kRetiresOnSaturation;
retires_on_saturation_ = true; retires_on_saturation_ = true;
// Now that no more action clauses can be specified, we check // Now that no more action clauses can be specified, we check
// whether their count makes sense. // whether their count makes sense.
CheckActionCountIfNotDone(); CheckActionCountIfNotDone();
return *this; return *this;
} }
// Returns the matchers for the arguments as specified inside the // Returns the matchers for the arguments as specified inside the
// EXPECT_CALL() macro. // EXPECT_CALL() macro.
const ArgumentMatcherTuple& matchers() const { const ArgumentMatcherTuple& matchers() const {
return matchers_; return matchers_;
} }
// Returns the matcher specified by the .WithArguments() clause. // Returns the matcher specified by the .With() clause.
const Matcher<const ArgumentTuple&>& extra_matcher() const { const Matcher<const ArgumentTuple&>& extra_matcher() const {
return extra_matcher_; return extra_matcher_;
} }
// Returns the sequence of actions specified by the .WillOnce() clause. // Returns the sequence of actions specified by the .WillOnce() clause.
const std::vector<Action<F> >& actions() const { return actions_; } const std::vector<Action<F> >& actions() const { return actions_; }
// Returns the action specified by the .WillRepeatedly() clause. // Returns the action specified by the .WillRepeatedly() clause.
const Action<F>& repeated_action() const { return repeated_action_; } const Action<F>& repeated_action() const { return repeated_action_; }
skipping to change at line 747 skipping to change at line 944
*os << " - " << (IsOverSaturated() ? "over-saturated" : *os << " - " << (IsOverSaturated() ? "over-saturated" :
IsSaturated() ? "saturated" : IsSaturated() ? "saturated" :
IsSatisfied() ? "satisfied" : "unsatisfied") IsSatisfied() ? "satisfied" : "unsatisfied")
<< " and " << " and "
<< (is_retired() ? "retired" : "active"); << (is_retired() ? "retired" : "active");
} }
private: private:
template <typename Function> template <typename Function>
friend class FunctionMockerBase; friend class FunctionMockerBase;
template <typename R, typename Function> // Returns an Expectation object that references and co-owns this
friend class InvokeWithHelper; // expectation.
virtual Expectation GetHandle() {
return owner_->GetHandleOf(this);
}
// The following methods will be called only after the EXPECT_CALL() // The following methods will be called only after the EXPECT_CALL()
// statement finishes and when the current thread holds // statement finishes and when the current thread holds
// g_gmock_mutex. // g_gmock_mutex.
// Returns true iff this expectation matches the given arguments. // Returns true iff this expectation matches the given arguments.
// L >= g_gmock_mutex // L >= g_gmock_mutex
bool Matches(const ArgumentTuple& args) const { bool Matches(const ArgumentTuple& args) const {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return TupleMatches(matchers_, args) && extra_matcher_.Matches(args); return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
skipping to change at line 789 skipping to change at line 989
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
if (is_retired()) { if (is_retired()) {
*os << " Expected: the expectation is active\n" *os << " Expected: the expectation is active\n"
<< " Actual: it is retired\n"; << " Actual: it is retired\n";
} else if (!Matches(args)) { } else if (!Matches(args)) {
if (!TupleMatches(matchers_, args)) { if (!TupleMatches(matchers_, args)) {
DescribeMatchFailureTupleTo(matchers_, args, os); DescribeMatchFailureTupleTo(matchers_, args, os);
} }
if (!extra_matcher_.Matches(args)) { if (!extra_matcher_.Matches(args)) {
*os << " Expected: "; *os << " Expected args: ";
extra_matcher_.DescribeTo(os); extra_matcher_.DescribeTo(os);
*os << "\n Actual: false"; *os << "\n Actual: don't match";
internal::ExplainMatchResultAsNeededTo<const ArgumentTuple&>( internal::ExplainMatchResultAsNeededTo<const ArgumentTuple&>(
extra_matcher_, args, os); extra_matcher_, args, os);
*os << "\n"; *os << "\n";
} }
} else if (!AllPrerequisitesAreSatisfied()) { } else if (!AllPrerequisitesAreSatisfied()) {
*os << " Expected: all pre-requisites are satisfied\n" *os << " Expected: all pre-requisites are satisfied\n"
<< " Actual: the following immediate pre-requisites " << " Actual: the following immediate pre-requisites "
<< "are not satisfied:\n"; << "are not satisfied:\n";
ExpectationBaseSet unsatisfied_prereqs; ExpectationSet unsatisfied_prereqs;
FindUnsatisfiedPrerequisites(&unsatisfied_prereqs); FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
int i = 0; int i = 0;
for (ExpectationBaseSet::const_iterator it = unsatisfied_prereqs.begi n(); for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();
it != unsatisfied_prereqs.end(); ++it) { it != unsatisfied_prereqs.end(); ++it) {
(*it)->DescribeLocationTo(os); it->expectation_base()->DescribeLocationTo(os);
*os << "pre-requisite #" << i++ << "\n"; *os << "pre-requisite #" << i++ << "\n";
} }
*os << " (end of pre-requisites)\n"; *os << " (end of pre-requisites)\n";
} else { } else {
// This line is here just for completeness' sake. It will never // This line is here just for completeness' sake. It will never
// be executed as currently the DescribeMatchResultTo() function // be executed as currently the DescribeMatchResultTo() function
// is called only when the mock function call does NOT match the // is called only when the mock function call does NOT match the
// expectation. // expectation.
*os << "The call matches the expectation.\n"; *os << "The call matches the expectation.\n";
} }
skipping to change at line 951 skipping to change at line 1151
FunctionMockerBase<F>* const owner_; FunctionMockerBase<F>* const owner_;
ArgumentMatcherTuple matchers_; ArgumentMatcherTuple matchers_;
Matcher<const ArgumentTuple&> extra_matcher_; Matcher<const ArgumentTuple&> extra_matcher_;
std::vector<Action<F> > actions_; std::vector<Action<F> > actions_;
bool repeated_action_specified_; // True if a WillRepeatedly() was speci fied. bool repeated_action_specified_; // True if a WillRepeatedly() was speci fied.
Action<F> repeated_action_; Action<F> repeated_action_;
bool retires_on_saturation_; bool retires_on_saturation_;
Clause last_clause_; Clause last_clause_;
mutable bool action_count_checked_; // Under mutex_. mutable bool action_count_checked_; // Under mutex_.
mutable Mutex mutex_; // Protects action_count_checked_. mutable Mutex mutex_; // Protects action_count_checked_.
}; // class Expectation }; // class TypedExpectation
// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for // A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
// specifying the default behavior of, or expectation on, a mock // specifying the default behavior of, or expectation on, a mock
// function. // function.
// Note: class MockSpec really belongs to the ::testing namespace. // Note: class MockSpec really belongs to the ::testing namespace.
// However if we define it in ::testing, MSVC will complain when // However if we define it in ::testing, MSVC will complain when
// classes in ::testing::internal declare it as a friend class // classes in ::testing::internal declare it as a friend class
// template. To workaround this compiler bug, we define MockSpec in // template. To workaround this compiler bug, we define MockSpec in
// ::testing::internal and import it into ::testing. // ::testing::internal and import it into ::testing.
skipping to change at line 986 skipping to change at line 1186
// the newly created spec. // the newly created spec.
internal::DefaultActionSpec<F>& InternalDefaultActionSetAt( internal::DefaultActionSpec<F>& InternalDefaultActionSetAt(
const char* file, int line, const char* obj, const char* call) { const char* file, int line, const char* obj, const char* call) {
LogWithLocation(internal::INFO, file, line, LogWithLocation(internal::INFO, file, line,
string("ON_CALL(") + obj + ", " + call + ") invoked"); string("ON_CALL(") + obj + ", " + call + ") invoked");
return function_mocker_->AddNewDefaultActionSpec(file, line, matchers_) ; return function_mocker_->AddNewDefaultActionSpec(file, line, matchers_) ;
} }
// Adds a new expectation spec to the function mocker and returns // Adds a new expectation spec to the function mocker and returns
// the newly created spec. // the newly created spec.
internal::Expectation<F>& InternalExpectedAt( internal::TypedExpectation<F>& InternalExpectedAt(
const char* file, int line, const char* obj, const char* call) { const char* file, int line, const char* obj, const char* call) {
LogWithLocation(internal::INFO, file, line, LogWithLocation(internal::INFO, file, line,
string("EXPECT_CALL(") + obj + ", " + call + ") invoked"); string("EXPECT_CALL(") + obj + ", " + call + ") invoked");
return function_mocker_->AddNewExpectation(file, line, matchers_); return function_mocker_->AddNewExpectation(file, line, matchers_);
} }
private: private:
template <typename Function> template <typename Function>
friend class internal::FunctionMocker; friend class internal::FunctionMocker;
skipping to change at line 1026 skipping to change at line 1226
// MSVC warns about using 'this' in base member initializer list, so // MSVC warns about using 'this' in base member initializer list, so
// we need to temporarily disable the warning. We have to do it for // we need to temporarily disable the warning. We have to do it for
// the entire class to suppress the warning, even though it's about // the entire class to suppress the warning, even though it's about
// the constructor only. // the constructor only.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4355) // Temporarily disables warning 4355. #pragma warning(disable:4355) // Temporarily disables warning 4355.
#endif // _MSV_VER #endif // _MSV_VER
// C++ treats the void type specially. For example, you cannot define
// a void-typed variable or pass a void value to a function.
// ActionResultHolder<T> holds a value of type T, where T must be a
// copyable type or void (T doesn't need to be default-constructable).
// It hides the syntactic difference between void and other types, and
// is used to unify the code for invoking both void-returning and
// non-void-returning mock functions. This generic definition is used
// when T is not void.
template <typename T>
class ActionResultHolder {
public:
explicit ActionResultHolder(T value) : value_(value) {}
// The compiler-generated copy constructor and assignment operator
// are exactly what we need, so we don't need to define them.
T value() const { return value_; }
// Prints the held value as an action's result to os.
void PrintAsActionResult(::std::ostream* os) const {
*os << "\n Returns: ";
UniversalPrinter<T>::Print(value_, os);
}
// Performs the given mock function's default action and returns the
// result in a ActionResultHolder.
template <typename Function, typename Arguments>
static ActionResultHolder PerformDefaultAction(
const FunctionMockerBase<Function>* func_mocker,
const Arguments& args,
const string& call_description) {
return ActionResultHolder(
func_mocker->PerformDefaultAction(args, call_description));
}
// Performs the given action and returns the result in a
// ActionResultHolder.
template <typename Function, typename Arguments>
static ActionResultHolder PerformAction(const Action<Function>& action,
const Arguments& args) {
return ActionResultHolder(action.Perform(args));
}
private:
T value_;
};
// Specialization for T = void.
template <>
class ActionResultHolder<void> {
public:
ActionResultHolder() {}
void value() const {}
void PrintAsActionResult(::std::ostream* /* os */) const {}
template <typename Function, typename Arguments>
static ActionResultHolder PerformDefaultAction(
const FunctionMockerBase<Function>* func_mocker,
const Arguments& args,
const string& call_description) {
func_mocker->PerformDefaultAction(args, call_description);
return ActionResultHolder();
}
template <typename Function, typename Arguments>
static ActionResultHolder PerformAction(const Action<Function>& action,
const Arguments& args) {
action.Perform(args);
return ActionResultHolder();
}
};
// The base of the function mocker class for the given function type. // The base of the function mocker class for the given function type.
// We put the methods in this class instead of its child to avoid code // We put the methods in this class instead of its child to avoid code
// bloat. // bloat.
template <typename F> template <typename F>
class FunctionMockerBase : public UntypedFunctionMockerBase { class FunctionMockerBase : public UntypedFunctionMockerBase {
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;
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
skipping to change at line 1084 skipping to change at line 1356
} }
Assert(DefaultValue<Result>::Exists(), "", -1, Assert(DefaultValue<Result>::Exists(), "", -1,
call_description + "\n The mock function has no default actio n " call_description + "\n The mock function has no default actio n "
"set, and its return type has no default value set."); "set, and its return type has no default value set.");
return DefaultValue<Result>::Get(); return DefaultValue<Result>::Get();
} }
// Registers this function mocker and the mock object owning it; // Registers this function mocker and the mock object owning it;
// returns a reference to the function mocker object. This is only // returns a reference to the function mocker object. This is only
// called by the ON_CALL() and EXPECT_CALL() macros. // called by the ON_CALL() and EXPECT_CALL() macros.
// L < g_gmock_mutex
FunctionMocker<F>& RegisterOwner(const void* mock_obj) { FunctionMocker<F>& RegisterOwner(const void* mock_obj) {
{
MutexLock l(&g_gmock_mutex);
mock_obj_ = mock_obj;
}
Mock::Register(mock_obj, this); Mock::Register(mock_obj, this);
return *down_cast<FunctionMocker<F>*>(this); return *::testing::internal::down_cast<FunctionMocker<F>*>(this);
} }
// The following two functions are from UntypedFunctionMockerBase. // The following two functions are from UntypedFunctionMockerBase.
// Verifies that all expectations on this mock function have been // Verifies that all expectations on this mock function have been
// satisfied. Reports one or more Google Test non-fatal failures // satisfied. Reports one or more Google Test non-fatal failures
// and returns false if not. // and returns false if not.
// L >= g_gmock_mutex // L >= g_gmock_mutex
virtual bool VerifyAndClearExpectationsLocked(); virtual bool VerifyAndClearExpectationsLocked();
skipping to change at line 1146 skipping to change at line 1423
// function is called from two threads concurrently. // function is called from two threads concurrently.
MutexLock l(&g_gmock_mutex); MutexLock l(&g_gmock_mutex);
name = name_; name = name_;
} }
return name; return name;
} }
protected: protected:
template <typename Function> template <typename Function>
friend class MockSpec; friend class MockSpec;
template <typename R, typename Function>
friend class InvokeWithHelper;
// Returns the result of invoking this mock function with the given // Returns the result of invoking this mock function with the given
// arguments. This function can be safely called from multiple // arguments. This function can be safely called from multiple
// threads concurrently. // threads concurrently.
// L < g_gmock_mutex // L < g_gmock_mutex
Result InvokeWith(const ArgumentTuple& args) { Result InvokeWith(const ArgumentTuple& args);
return InvokeWithHelper<Result, F>::InvokeAndPrintResult(this, args);
}
// Adds and returns a default action spec for this mock function. // Adds and returns a default action spec for this mock function.
// L < g_gmock_mutex
DefaultActionSpec<F>& AddNewDefaultActionSpec( DefaultActionSpec<F>& AddNewDefaultActionSpec(
const char* file, int line, const char* file, int line,
const ArgumentMatcherTuple& m) { const ArgumentMatcherTuple& m) {
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
default_actions_.push_back(DefaultActionSpec<F>(file, line, m)); default_actions_.push_back(DefaultActionSpec<F>(file, line, m));
return default_actions_.back(); return default_actions_.back();
} }
// Adds and returns an expectation spec for this mock function. // Adds and returns an expectation spec for this mock function.
Expectation<F>& AddNewExpectation( // L < g_gmock_mutex
TypedExpectation<F>& AddNewExpectation(
const char* file, int line, const char* file, int line,
const ArgumentMatcherTuple& m) { const ArgumentMatcherTuple& m) {
const linked_ptr<Expectation<F> > expectation( Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
new Expectation<F>(this, file, line, m)); const linked_ptr<TypedExpectation<F> > expectation(
new TypedExpectation<F>(this, file, line, m));
expectations_.push_back(expectation); expectations_.push_back(expectation);
// Adds this expectation into the implicit sequence if there is one. // Adds this expectation into the implicit sequence if there is one.
Sequence* const implicit_sequence = g_gmock_implicit_sequence.get(); Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();
if (implicit_sequence != NULL) { if (implicit_sequence != NULL) {
implicit_sequence->AddExpectation(expectation); implicit_sequence->AddExpectation(Expectation(expectation));
} }
return *expectation; return *expectation;
} }
// The current spec (either default action spec or expectation spec) // The current spec (either default action spec or expectation spec)
// being described on this function mocker. // being described on this function mocker.
MockSpec<F>& current_spec() { return current_spec_; } MockSpec<F>& current_spec() { return current_spec_; }
private: private:
template <typename Func> friend class Expectation; template <typename Func> friend class TypedExpectation;
typedef std::vector<internal::linked_ptr<Expectation<F> > > Expectations; typedef std::vector<internal::linked_ptr<TypedExpectation<F> > >
TypedExpectations;
// Gets the internal::linked_ptr<ExpectationBase> object that co-owns 'ex // Returns an Expectation object that references and co-owns exp,
p'. // which must be an expectation on this mock function.
internal::linked_ptr<ExpectationBase> GetLinkedExpectationBase( Expectation GetHandleOf(TypedExpectation<F>* exp) {
Expectation<F>* exp) { for (typename TypedExpectations::const_iterator it = expectations_.begi
for (typename Expectations::const_iterator it = expectations_.begin(); n();
it != expectations_.end(); ++it) { it != expectations_.end(); ++it) {
if (it->get() == exp) { if (it->get() == exp) {
return *it; return Expectation(*it);
} }
} }
Assert(false, __FILE__, __LINE__, "Cannot find expectation."); Assert(false, __FILE__, __LINE__, "Cannot find expectation.");
return internal::linked_ptr<ExpectationBase>(NULL); return Expectation();
// The above statement is just to make the code compile, and will // The above statement is just to make the code compile, and will
// never be executed. // never be executed.
} }
// Some utilities needed for implementing InvokeWith(). // Some utilities needed for implementing InvokeWith().
// Describes what default action will be performed for the given // Describes what default action will be performed for the given
// arguments. // arguments.
// L = * // L = *
void DescribeDefaultActionTo(const ArgumentTuple& args, void DescribeDefaultActionTo(const ArgumentTuple& args,
skipping to change at line 1248 skipping to change at line 1525
// corresponding action that needs to be taken in an ATOMIC // corresponding action that needs to be taken in an ATOMIC
// transaction. Otherwise another thread may call this mock // transaction. Otherwise another thread may call this mock
// method in the middle and mess up the state. // method in the middle and mess up the state.
// //
// However, performing the action has to be left out of the critical // However, performing the action has to be left out of the critical
// section. The reason is that we have no control on what the // section. The reason is that we have no control on what the
// action does (it can invoke an arbitrary user function or even a // action does (it can invoke an arbitrary user function or even a
// mock function) and excessive locking could cause a dead lock. // mock function) and excessive locking could cause a dead lock.
// L < g_gmock_mutex // L < g_gmock_mutex
bool FindMatchingExpectationAndAction( bool FindMatchingExpectationAndAction(
const ArgumentTuple& args, Expectation<F>** exp, Action<F>* action, const ArgumentTuple& args, TypedExpectation<F>** exp, Action<F>* acti on,
bool* is_excessive, ::std::ostream* what, ::std::ostream* why) { bool* is_excessive, ::std::ostream* what, ::std::ostream* why) {
MutexLock l(&g_gmock_mutex); MutexLock l(&g_gmock_mutex);
*exp = this->FindMatchingExpectationLocked(args); *exp = this->FindMatchingExpectationLocked(args);
if (*exp == NULL) { // A match wasn't found. if (*exp == NULL) { // A match wasn't found.
*action = DoDefault(); *action = DoDefault();
this->FormatUnexpectedCallMessageLocked(args, what, why); this->FormatUnexpectedCallMessageLocked(args, what, why);
return false; return false;
} }
// This line must be done before calling GetActionForArguments(), // This line must be done before calling GetActionForArguments(),
// which will increment the call count for *exp and thus affect // which will increment the call count for *exp and thus affect
// its saturation status. // its saturation status.
*is_excessive = (*exp)->IsSaturated(); *is_excessive = (*exp)->IsSaturated();
*action = (*exp)->GetActionForArguments(this, args, what, why); *action = (*exp)->GetActionForArguments(this, args, what, why);
return true; return true;
} }
// Returns the expectation that matches the arguments, or NULL if no // Returns the expectation that matches the arguments, or NULL if no
// expectation matches them. // expectation matches them.
// L >= g_gmock_mutex // L >= g_gmock_mutex
Expectation<F>* FindMatchingExpectationLocked( TypedExpectation<F>* FindMatchingExpectationLocked(
const ArgumentTuple& args) const { const ArgumentTuple& args) const {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
for (typename Expectations::const_reverse_iterator it = for (typename TypedExpectations::const_reverse_iterator it =
expectations_.rbegin(); expectations_.rbegin();
it != expectations_.rend(); ++it) { it != expectations_.rend(); ++it) {
Expectation<F>* const exp = it->get(); TypedExpectation<F>* const exp = it->get();
if (exp->ShouldHandleArguments(args)) { if (exp->ShouldHandleArguments(args)) {
return exp; return exp;
} }
} }
return NULL; return NULL;
} }
// Returns a message that the arguments don't match any expectation. // Returns a message that the arguments don't match any expectation.
// L >= g_gmock_mutex // L >= g_gmock_mutex
void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args, void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args,
skipping to change at line 1317 skipping to change at line 1594
expectations_[i]->DescribeLocationTo(why); expectations_[i]->DescribeLocationTo(why);
if (count > 1) { if (count > 1) {
*why << "tried expectation #" << i; *why << "tried expectation #" << i;
} }
*why << "\n"; *why << "\n";
expectations_[i]->DescribeMatchResultTo(args, why); expectations_[i]->DescribeMatchResultTo(args, why);
expectations_[i]->DescribeCallCountTo(why); expectations_[i]->DescribeCallCountTo(why);
} }
} }
// Address of the mock object this mock method belongs to. // Address of the mock object this mock method belongs to. Only
// valid after this mock method has been called or
// ON_CALL/EXPECT_CALL has been invoked on it.
const void* mock_obj_; // Protected by g_gmock_mutex. const void* mock_obj_; // Protected by g_gmock_mutex.
// Name of the function being mocked. // Name of the function being mocked. Only valid after this mock
// method has been called.
const char* name_; // Protected by g_gmock_mutex. const char* name_; // Protected by g_gmock_mutex.
// The current spec (either default action spec or expectation spec) // The current spec (either default action spec or expectation spec)
// being described on this function mocker. // being described on this function mocker.
MockSpec<F> current_spec_; MockSpec<F> current_spec_;
// All default action specs for this function mocker. // All default action specs for this function mocker.
std::vector<DefaultActionSpec<F> > default_actions_; std::vector<DefaultActionSpec<F> > default_actions_;
// All expectations for this function mocker. // All expectations for this function mocker.
Expectations expectations_; TypedExpectations expectations_;
// There is no generally useful and implementable semantics of
// copying a mock object, so copying a mock is usually a user error.
// Thus we disallow copying function mockers. If the user really
// wants to copy a mock object, he should implement his own copy
// operation, for example:
//
// class MockFoo : public Foo {
// public:
// // Defines a copy constructor explicitly.
// MockFoo(const MockFoo& src) {}
// ...
// };
GTEST_DISALLOW_COPY_AND_ASSIGN_(FunctionMockerBase);
}; // class FunctionMockerBase }; // class FunctionMockerBase
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#endif // _MSV_VER #endif // _MSV_VER
// Implements methods of FunctionMockerBase. // Implements methods of FunctionMockerBase.
// Verifies that all expectations on this mock function have been // Verifies that all expectations on this mock function have been
// satisfied. Reports one or more Google Test non-fatal failures and // satisfied. Reports one or more Google Test non-fatal failures and
// returns false if not. // returns false if not.
// L >= g_gmock_mutex // L >= g_gmock_mutex
template <typename F> template <typename F>
bool FunctionMockerBase<F>::VerifyAndClearExpectationsLocked() { bool FunctionMockerBase<F>::VerifyAndClearExpectationsLocked() {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
bool expectations_met = true; bool expectations_met = true;
for (typename Expectations::const_iterator it = expectations_.begin(); for (typename TypedExpectations::const_iterator it = expectations_.begin( );
it != expectations_.end(); ++it) { it != expectations_.end(); ++it) {
Expectation<F>* const exp = it->get(); TypedExpectation<F>* const exp = it->get();
if (exp->IsOverSaturated()) { if (exp->IsOverSaturated()) {
// There was an upper-bound violation. Since the error was // There was an upper-bound violation. Since the error was
// already reported when it occurred, there is no need to do // already reported when it occurred, there is no need to do
// anything here. // anything here.
expectations_met = false; expectations_met = false;
} else if (!exp->IsSatisfied()) { } else if (!exp->IsSatisfied()) {
expectations_met = false; expectations_met = false;
::std::stringstream ss; ::std::stringstream ss;
ss << "Actual function call count doesn't match this expectation.\n"; ss << "Actual function call count doesn't match this expectation.\n";
skipping to change at line 1375 skipping to change at line 1669
} }
} }
expectations_.clear(); expectations_.clear();
return expectations_met; return expectations_met;
} }
// Reports an uninteresting call (whose description is in msg) in the // Reports an uninteresting call (whose description is in msg) in the
// manner specified by 'reaction'. // manner specified by 'reaction'.
void ReportUninterestingCall(CallReaction reaction, const string& msg); void ReportUninterestingCall(CallReaction reaction, const string& msg);
// When an uninteresting or unexpected mock function is called, we // Calculates the result of invoking this mock function with the given
// want to print its return value to assist the user debugging. Since // arguments, prints it, and returns it.
// there's nothing to print when the function returns void, we need to // L < g_gmock_mutex
// specialize the logic of FunctionMockerBase<F>::InvokeWith() for template <typename F>
// void return values. typename Function<F>::Result FunctionMockerBase<F>::InvokeWith(
// const typename Function<F>::ArgumentTuple& args) {
// C++ doesn't allow us to specialize a member function template typedef ActionResultHolder<Result> ResultHolder;
// unless we also specialize its enclosing class, so we had to let
// InvokeWith() delegate its work to a helper class InvokeWithHelper,
// which can then be specialized.
//
// Note that InvokeWithHelper must be a class template (as opposed to
// a function template), as only class templates can be partially
// specialized.
template <typename Result, typename F>
class InvokeWithHelper {
public:
typedef typename Function<F>::ArgumentTuple ArgumentTuple;
// Calculates the result of invoking the function mocked by mocker
// with the given arguments, prints it, and returns it.
// L < g_gmock_mutex
static Result InvokeAndPrintResult(
FunctionMockerBase<F>* mocker,
const ArgumentTuple& args) {
if (mocker->expectations_.size() == 0) {
// No expectation is set on this mock method - we have an
// uninteresting call.
// Warns about the uninteresting call.
::std::stringstream ss;
mocker->DescribeUninterestingCall(args, &ss);
// We must get Google Mock's reaction on uninteresting calls if (expectations_.size() == 0) {
// made on this mock object BEFORE performing the action, // No expectation is set on this mock method - we have an
// because the action may DELETE the mock object and make the // uninteresting call.
// following expression meaningless.
const CallReaction reaction =
Mock::GetReactionOnUninterestingCalls(mocker->MockObject());
// Calculates the function result. // We must get Google Mock's reaction on uninteresting calls
Result result = mocker->PerformDefaultAction(args, ss.str()); // made on this mock object BEFORE performing the action,
// because the action may DELETE the mock object and make the
// following expression meaningless.
const CallReaction reaction =
Mock::GetReactionOnUninterestingCalls(MockObject());
// Prints the function result. // True iff we need to print this call's arguments and return
ss << "\n Returns: "; // value. This definition must be kept in sync with
UniversalPrinter<Result>::Print(result, &ss); // the behavior of ReportUninterestingCall().
ReportUninterestingCall(reaction, ss.str()); const bool need_to_report_uninteresting_call =
// If the user allows this uninteresting call, we print it
// only when he wants informational messages.
reaction == ALLOW ? LogIsVisible(INFO) :
// If the user wants this to be a warning, we print it only
// when he wants to see warnings.
reaction == WARN ? LogIsVisible(WARNING) :
// Otherwise, the user wants this to be an error, and we
// should always print detailed information in the error.
true;
return result; if (!need_to_report_uninteresting_call) {
// Perform the action without printing the call information.
return PerformDefaultAction(args, "");
} }
bool is_excessive = false; // Warns about the uninteresting call.
::std::stringstream ss; ::std::stringstream ss;
::std::stringstream why; DescribeUninterestingCall(args, &ss);
::std::stringstream loc;
Action<F> action;
Expectation<F>* exp;
// The FindMatchingExpectationAndAction() function acquires and // Calculates the function result.
// releases g_gmock_mutex. const ResultHolder result =
const bool found = mocker->FindMatchingExpectationAndAction( ResultHolder::PerformDefaultAction(this, args, ss.str());
args, &exp, &action, &is_excessive, &ss, &why);
ss << " Function call: " << mocker->Name();
UniversalPrinter<ArgumentTuple>::Print(args, &ss);
// In case the action deletes a piece of the expectation, we
// generate the message beforehand.
if (found && !is_excessive) {
exp->DescribeLocationTo(&loc);
}
Result result = action.IsDoDefault() ?
mocker->PerformDefaultAction(args, ss.str())
: action.Perform(args);
ss << "\n Returns: ";
UniversalPrinter<Result>::Print(result, &ss);
ss << "\n" << why.str();
if (found) { // Prints the function result.
if (is_excessive) { result.PrintAsActionResult(&ss);
// We had an upper-bound violation and the failure message is in ss
. ReportUninterestingCall(reaction, ss.str());
Expect(false, exp->file(), exp->line(), ss.str()); return result.value();
} else {
// We had an expected call and the matching expectation is
// described in ss.
Log(INFO, loc.str() + ss.str(), 3);
}
} else {
// No expectation matches this call - reports a failure.
Expect(false, NULL, -1, ss.str());
}
return result;
} }
}; // class InvokeWithHelper
// This specialization helps to implement bool is_excessive = false;
// FunctionMockerBase<F>::InvokeWith() for void-returning functions. ::std::stringstream ss;
template <typename F> ::std::stringstream why;
class InvokeWithHelper<void, F> { ::std::stringstream loc;
public: Action<F> action;
typedef typename Function<F>::ArgumentTuple ArgumentTuple; TypedExpectation<F>* exp;
// Invokes the function mocked by mocker with the given arguments. // The FindMatchingExpectationAndAction() function acquires and
// L < g_gmock_mutex // releases g_gmock_mutex.
static void InvokeAndPrintResult(FunctionMockerBase<F>* mocker, const bool found = FindMatchingExpectationAndAction(
const ArgumentTuple& args) { args, &exp, &action, &is_excessive, &ss, &why);
const int count = static_cast<int>(mocker->expectations_.size());
if (count == 0) {
// No expectation is set on this mock method - we have an
// uninteresting call.
::std::stringstream ss;
mocker->DescribeUninterestingCall(args, &ss);
// We must get Google Mock's reaction on uninteresting calls // True iff we need to print the call's arguments and return value.
// made on this mock object BEFORE performing the action, // This definition must be kept in sync with the uses of Expect()
// because the action may DELETE the mock object and make the // and Log() in this function.
// following expression meaningless. const bool need_to_report_call = !found || is_excessive || LogIsVisible(I
const CallReaction reaction = NFO);
Mock::GetReactionOnUninterestingCalls(mocker->MockObject()); if (!need_to_report_call) {
// Perform the action without printing the call information.
return action.IsDoDefault() ? PerformDefaultAction(args, "") :
action.Perform(args);
}
mocker->PerformDefaultAction(args, ss.str()); ss << " Function call: " << Name();
ReportUninterestingCall(reaction, ss.str()); UniversalPrinter<ArgumentTuple>::Print(args, &ss);
return;
}
bool is_excessive = false; // In case the action deletes a piece of the expectation, we
::std::stringstream ss; // generate the message beforehand.
::std::stringstream why; if (found && !is_excessive) {
::std::stringstream loc; exp->DescribeLocationTo(&loc);
Action<F> action; }
Expectation<F>* exp;
// The FindMatchingExpectationAndAction() function acquires and const ResultHolder result = action.IsDoDefault() ?
// releases g_gmock_mutex. ResultHolder::PerformDefaultAction(this, args, ss.str()) :
const bool found = mocker->FindMatchingExpectationAndAction( ResultHolder::PerformAction(action, args);
args, &exp, &action, &is_excessive, &ss, &why); result.PrintAsActionResult(&ss);
ss << " Function call: " << mocker->Name(); ss << "\n" << why.str();
UniversalPrinter<ArgumentTuple>::Print(args, &ss);
ss << "\n" << why.str();
// In case the action deletes a piece of the expectation, we
// generate the message beforehand.
if (found && !is_excessive) {
exp->DescribeLocationTo(&loc);
}
if (action.IsDoDefault()) {
mocker->PerformDefaultAction(args, ss.str());
} else {
action.Perform(args);
}
if (found) { if (!found) {
// A matching expectation and corresponding action were found. // No expectation matches this call - reports a failure.
if (is_excessive) { Expect(false, NULL, -1, ss.str());
// We had an upper-bound violation and the failure message is in ss } else if (is_excessive) {
. // We had an upper-bound violation and the failure message is in ss.
Expect(false, exp->file(), exp->line(), ss.str()); Expect(false, exp->file(), exp->line(), ss.str());
} else { } else {
// We had an expected call and the matching expectation is // We had an expected call and the matching expectation is
// described in ss. // described in ss.
Log(INFO, loc.str() + ss.str(), 3); Log(INFO, loc.str() + ss.str(), 2);
}
} else {
// No matching expectation was found - reports an error.
Expect(false, NULL, -1, ss.str());
}
} }
}; // class InvokeWithHelper<void, F> return result.value();
}
} // namespace internal } // namespace internal
// 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 MockSpec class template is // inside a header file. However, the MockSpec class template is
// meant to be defined in the ::testing namespace. The following line // 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 cannot // is just a trick for working around a bug in MSVC 8.0, which cannot
// handle it if we define MockSpec in ::testing. // handle it if we define MockSpec in ::testing.
using internal::MockSpec; using internal::MockSpec;
skipping to change at line 1567 skipping to change at line 1800
// }; // };
// //
// MockFoo foo; // MockFoo foo;
// // Expects a call to non-const MockFoo::Bar(). // // Expects a call to non-const MockFoo::Bar().
// EXPECT_CALL(foo, Bar()); // EXPECT_CALL(foo, Bar());
// // Expects a call to const MockFoo::Bar(). // // Expects a call to const MockFoo::Bar().
// EXPECT_CALL(Const(foo), Bar()); // EXPECT_CALL(Const(foo), Bar());
template <typename T> template <typename T>
inline const T& Const(const T& x) { return x; } inline const T& Const(const T& x) { return x; }
// Constructs an Expectation object that references and co-owns exp.
inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
: expectation_base_(exp.GetHandle().expectation_base()) {}
} // namespace testing } // namespace testing
// A separate macro is required to avoid compile errors when the name // A separate macro is required to avoid compile errors when the name
// of the method used in call is a result of macro expansion. // of the method used in call is a result of macro expansion.
// See CompilesWithMethodNameExpandedFromMacro tests in // See CompilesWithMethodNameExpandedFromMacro tests in
// internal/gmock-spec-builders_test.cc for more details. // internal/gmock-spec-builders_test.cc for more details.
#define GMOCK_ON_CALL_IMPL_(obj, call) \ #define GMOCK_ON_CALL_IMPL_(obj, call) \
((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \ ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
#obj, #call) #obj, #call)
#define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call) #define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
 End of changes. 114 change blocks. 
296 lines changed or deleted 543 lines changed or added


 gmock.h   gmock.h 
skipping to change at line 42 skipping to change at line 42
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This is the main header file a user should include. // This is the main header file a user should include.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_H_
// This file implements the following syntax: // This file implements the following syntax:
// //
// ON_CALL(mock_object.Method(...)) // ON_CALL(mock_object.Method(...))
// .WithArguments(...) ? // .With(...) ?
// .WillByDefault(...); // .WillByDefault(...);
// //
// where WithArguments() is optional and WillByDefault() must appear // where With() is optional and WillByDefault() must appear exactly
// exactly once. // once.
// //
// EXPECT_CALL(mock_object.Method(...)) // EXPECT_CALL(mock_object.Method(...))
// .WithArguments(...) ? // .With(...) ?
// .Times(...) ? // .Times(...) ?
// .InSequence(...) * // .InSequence(...) *
// .WillOnce(...) * // .WillOnce(...) *
// .WillRepeatedly(...) ? // .WillRepeatedly(...) ?
// .RetiresOnSaturation() ? ; // .RetiresOnSaturation() ? ;
// //
// where all clauses are optional and WillOnce() can be repeated. // where all clauses are optional and WillOnce() can be repeated.
#include <gmock/gmock-actions.h> #include <gmock/gmock-actions.h>
#include <gmock/gmock-cardinalities.h> #include <gmock/gmock-cardinalities.h>
#include <gmock/gmock-generated-actions.h> #include <gmock/gmock-generated-actions.h>
#include <gmock/gmock-generated-function-mockers.h> #include <gmock/gmock-generated-function-mockers.h>
#include <gmock/gmock-generated-matchers.h> #include <gmock/gmock-generated-matchers.h>
#include <gmock/gmock-more-actions.h>
#include <gmock/gmock-generated-nice-strict.h> #include <gmock/gmock-generated-nice-strict.h>
#include <gmock/gmock-matchers.h> #include <gmock/gmock-matchers.h>
#include <gmock/gmock-printers.h> #include <gmock/gmock-printers.h>
#include <gmock/internal/gmock-internal-utils.h> #include <gmock/internal/gmock-internal-utils.h>
namespace testing { namespace testing {
// Declares Google Mock flags that we want a user to use programmatically. // Declares Google Mock flags that we want a user to use programmatically.
GMOCK_DECLARE_bool_(catch_leaked_mocks);
GMOCK_DECLARE_string_(verbose); GMOCK_DECLARE_string_(verbose);
// Initializes Google Mock. This must be called before running the // Initializes Google Mock. This must be called before running the
// tests. In particular, it parses the command line for the flags // tests. In particular, it parses the command line for the flags
// that Google Mock recognizes. Whenever a Google Mock flag is seen, // that Google Mock recognizes. Whenever a Google Mock flag is seen,
// it is removed from argv, and *argc is decremented. // it is removed from argv, and *argc is decremented.
// //
// No value is returned. Instead, the Google Mock flag variables are // No value is returned. Instead, the Google Mock flag variables are
// updated. // updated.
// //
 End of changes. 5 change blocks. 
4 lines changed or deleted 6 lines changed or added


 gtest-death-test-internal.h   gtest-death-test-internal.h 
skipping to change at line 42 skipping to change at line 42
// The Google C++ Testing Framework (Google Test) // The Google C++ Testing Framework (Google Test)
// //
// This header file defines internal utilities needed for implementing // This header file defines internal utilities needed for implementing
// death tests. They are subject to change without notice. // death tests. They are subject to change without notice.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#if GTEST_HAS_DEATH_TEST && GTEST_OS_WINDOWS
#include <io.h>
#endif // GTEST_HAS_DEATH_TEST && GTEST_OS_WINDOWS
namespace testing { namespace testing {
namespace internal { namespace internal {
GTEST_DECLARE_string_(internal_run_death_test); GTEST_DECLARE_string_(internal_run_death_test);
// Names of the flags (needed for parsing Google Test flags). // Names of the flags (needed for parsing Google Test flags).
const char kDeathTestStyleFlag[] = "death_test_style"; const char kDeathTestStyleFlag[] = "death_test_style";
const char kDeathTestUseFork[] = "death_test_use_fork"; const char kDeathTestUseFork[] = "death_test_use_fork";
const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
skipping to change at line 160 skipping to change at line 156
}; };
// Returns true if exit_status describes a process that was terminated // Returns true if exit_status describes a process that was terminated
// by a signal, or exited normally with a nonzero exit code. // by a signal, or exited normally with a nonzero exit code.
bool ExitedUnsuccessfully(int exit_status); bool ExitedUnsuccessfully(int exit_status);
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*, // This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
// ASSERT_EXIT*, and EXPECT_EXIT*. // ASSERT_EXIT*, and EXPECT_EXIT*.
#define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \ #define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (true) { \ if (::testing::internal::AlwaysTrue()) { \
const ::testing::internal::RE& gtest_regex = (regex); \ const ::testing::internal::RE& gtest_regex = (regex); \
::testing::internal::DeathTest* gtest_dt; \ ::testing::internal::DeathTest* gtest_dt; \
if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \ if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \
__FILE__, __LINE__, &gtest_dt)) { \ __FILE__, __LINE__, &gtest_dt)) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
} \ } \
if (gtest_dt != NULL) { \ if (gtest_dt != NULL) { \
::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \ ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
gtest_dt_ptr(gtest_dt); \ gtest_dt_ptr(gtest_dt); \
switch (gtest_dt->AssumeRole()) { \ switch (gtest_dt->AssumeRole()) { \
case ::testing::internal::DeathTest::OVERSEE_TEST: \ case ::testing::internal::DeathTest::OVERSEE_TEST: \
if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \ if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
} \ } \
break; \ break; \
case ::testing::internal::DeathTest::EXECUTE_TEST: { \ case ::testing::internal::DeathTest::EXECUTE_TEST: { \
::testing::internal::DeathTest::ReturnSentinel \ ::testing::internal::DeathTest::ReturnSentinel \
gtest_sentinel(gtest_dt); \ gtest_sentinel(gtest_dt); \
GTEST_HIDE_UNREACHABLE_CODE_(statement); \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE) ; \ gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE) ; \
break; \ break; \
} \ } \
} \ } \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
fail(::testing::internal::DeathTest::LastMessage()) fail(::testing::internal::DeathTest::LastMessage())
// The symbol "fail" here expands to something into which a message // The symbol "fail" here expands to something into which a message
// can be streamed. // can be streamed.
// A class representing the parsed contents of the // A class representing the parsed contents of the
// --gtest_internal_run_death_test flag, as it existed when // --gtest_internal_run_death_test flag, as it existed when
// RUN_ALL_TESTS was called. // RUN_ALL_TESTS was called.
class InternalRunDeathTestFlag { class InternalRunDeathTestFlag {
public: public:
InternalRunDeathTestFlag(const String& file, InternalRunDeathTestFlag(const String& file,
int line, int line,
int index, int index,
int status_fd) int write_fd)
: file_(file), line_(line), index_(index), status_fd_(status_fd) {} : file_(file), line_(line), index_(index), write_fd_(write_fd) {}
~InternalRunDeathTestFlag() { ~InternalRunDeathTestFlag() {
if (status_fd_ >= 0) if (write_fd_ >= 0)
// Suppress MSVC complaints about POSIX functions. posix::Close(write_fd_);
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4996)
#endif // _MSC_VER
close(status_fd_);
#ifdef _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER
} }
String file() const { return file_; } String file() const { return file_; }
int line() const { return line_; } int line() const { return line_; }
int index() const { return index_; } int index() const { return index_; }
int status_fd() const { return status_fd_; } int write_fd() const { return write_fd_; }
private: private:
String file_; String file_;
int line_; int line_;
int index_; int index_;
int status_fd_; int write_fd_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag); GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
}; };
// Returns a newly created InternalRunDeathTestFlag object with fields // Returns a newly created InternalRunDeathTestFlag object with fields
// initialized from the GTEST_FLAG(internal_run_death_test) flag if // initialized from the GTEST_FLAG(internal_run_death_test) flag if
// the flag is specified; otherwise returns NULL. // the flag is specified; otherwise returns NULL.
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag(); InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
#else // GTEST_HAS_DEATH_TEST
// This macro is used for implementing macros such as
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
// death tests are not supported. Those macros must compile on such systems
// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
// systems that support death tests. This allows one to write such a macro
// on a system that does not support death tests and be sure that it will
// compile on a death-test supporting system.
//
// Parameters:
// statement - A statement that a macro such as EXPECT_DEATH would test
// for program termination. This macro has to make sure this
// statement is compiled but not executed, to ensure that
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
// parameter iff EXPECT_DEATH compiles with it.
// regex - A regex that a macro such as EXPECT_DEATH would use to te
st
// the output of statement. This parameter has to be
// compiled but not evaluated by this macro, to ensure that
// this macro only accepts expressions that a macro such as
// EXPECT_DEATH would accept.
// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
// and a return statement for ASSERT_DEATH_IF_SUPPORTED.
// This ensures that ASSERT_DEATH_IF_SUPPORTED will not
// compile inside functions where ASSERT_DEATH doesn't
// compile.
//
// The branch that has an always false condition is used to ensure that
// statement and regex are compiled (and thus syntactically correct) but
// never executed. The unreachable code macro protects the terminator
// statement from generating an 'unreachable code' warning in case
// statement unconditionally returns or throws. The Message constructor at
// the end allows the syntax of streaming additional messages into the
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
#define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AlwaysTrue()) { \
GTEST_LOG_(WARNING) \
<< "Death tests are not supported on this platform.\n" \
<< "Statement '" #statement "' cannot be verified."; \
} else if (::testing::internal::AlwaysFalse()) { \
::testing::internal::RE::PartialMatch(".*", (regex)); \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
terminator; \
} else \
::testing::Message()
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
 End of changes. 8 change blocks. 
20 lines changed or deleted 56 lines changed or added


 gtest-death-test.h   gtest-death-test.h 
skipping to change at line 184 skipping to change at line 184
EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
// Tests that an exit code describes a normal exit with a given exit code. // Tests that an exit code describes a normal exit with a given exit code.
class ExitedWithCode { class ExitedWithCode {
public: public:
explicit ExitedWithCode(int exit_code); explicit ExitedWithCode(int exit_code);
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
private: private:
// No implementation - assignment is unsupported.
void operator=(const ExitedWithCode& other);
const int exit_code_; const int exit_code_;
}; };
#if !GTEST_OS_WINDOWS #if !GTEST_OS_WINDOWS
// Tests that an exit code describes an exit due to termination by a // Tests that an exit code describes an exit due to termination by a
// given signal. // given signal.
class KilledBySignal { class KilledBySignal {
public: public:
explicit KilledBySignal(int signum); explicit KilledBySignal(int signum);
bool operator()(int exit_status) const; bool operator()(int exit_status) const;
skipping to change at line 245 skipping to change at line 248
// //
// EXPECT_DEBUG_DEATH({ // EXPECT_DEBUG_DEATH({
// // Side-effects here will have an effect after this statement in // // Side-effects here will have an effect after this statement in
// // opt mode, but none in debug mode. // // opt mode, but none in debug mode.
// EXPECT_EQ(12, DieInDebugOr12(&sideeffect)); // EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
// }, "death"); // }, "death");
// //
#ifdef NDEBUG #ifdef NDEBUG
#define EXPECT_DEBUG_DEATH(statement, regex) \ #define EXPECT_DEBUG_DEATH(statement, regex) \
do { statement; } while (false) do { statement; } while (::testing::internal::AlwaysFalse())
#define ASSERT_DEBUG_DEATH(statement, regex) \ #define ASSERT_DEBUG_DEATH(statement, regex) \
do { statement; } while (false) do { statement; } while (::testing::internal::AlwaysFalse())
#else #else
#define EXPECT_DEBUG_DEATH(statement, regex) \ #define EXPECT_DEBUG_DEATH(statement, regex) \
EXPECT_DEATH(statement, regex) EXPECT_DEATH(statement, regex)
#define ASSERT_DEBUG_DEATH(statement, regex) \ #define ASSERT_DEBUG_DEATH(statement, regex) \
ASSERT_DEATH(statement, regex) ASSERT_DEATH(statement, regex)
#endif // NDEBUG for EXPECT_DEBUG_DEATH #endif // NDEBUG for EXPECT_DEBUG_DEATH
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests i
f
// death tests are supported; otherwise they just issue a warning. This is
// useful when you are combining death test assertions with normal test
// assertions in one test.
#if GTEST_HAS_DEATH_TEST
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
EXPECT_DEATH(statement, regex)
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
ASSERT_DEATH(statement, regex)
#else
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
#endif
} // namespace testing } // namespace testing
#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ #endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
 End of changes. 4 change blocks. 
2 lines changed or deleted 24 lines changed or added


 gtest-internal.h   gtest-internal.h 
skipping to change at line 104 skipping to change at line 104
// compile with MSVC. // compile with MSVC.
template <typename T> template <typename T>
inline void GTestStreamToHelper(std::ostream* os, const T& val) { inline void GTestStreamToHelper(std::ostream* os, const T& val) {
*os << val; *os << val;
} }
namespace testing { namespace testing {
// Forward declaration of classes. // Forward declaration of classes.
class AssertionResult; // Result of an assertion.
class Message; // Represents a failure message. class Message; // Represents a failure message.
class Test; // Represents a test. class Test; // Represents a test.
class TestCase; // A collection of related tests.
class TestPartResult; // Result of a test part.
class TestInfo; // Information about a test. class TestInfo; // Information about a test.
class TestPartResult; // Result of a test part.
class UnitTest; // A collection of test cases. class UnitTest; // A collection of test cases.
class UnitTestEventListenerInterface; // Listens to Google Test events.
class AssertionResult; // Result of an assertion.
namespace internal { namespace internal {
struct TraceInfo; // Information about a trace point. struct TraceInfo; // Information about a trace point.
class ScopedTrace; // Implements scoped trace. class ScopedTrace; // Implements scoped trace.
class TestInfoImpl; // Opaque implementation of TestInfo class TestInfoImpl; // Opaque implementation of TestInfo
class TestResult; // Result of a single Test.
class UnitTestImpl; // Opaque implementation of UnitTest class UnitTestImpl; // Opaque implementation of UnitTest
template <typename E> class Vector; // A generic vector.
template <typename E> class List; // A generic list.
template <typename E> class ListNode; // A node in a generic list.
// How many times InitGoogleTest() has been called. // How many times InitGoogleTest() has been called.
extern int g_init_gtest_count; extern int g_init_gtest_count;
// The text used in failure messages to indicate the start of the // The text used in failure messages to indicate the start of the
// stack trace. // stack trace.
extern const char kStackTraceMarker[]; extern const char kStackTraceMarker[];
// A secret type that Google Test users don't know about. It has no // A secret type that Google Test users don't know about. It has no
// definition on purpose. Therefore it's impossible to create a // definition on purpose. Therefore it's impossible to create a
skipping to change at line 214 skipping to change at line 209
// These are needed as the Nokia Symbian and IBM XL C/C++ compilers // These are needed as the Nokia Symbian and IBM XL C/C++ compilers
// cannot decide between const T& and const T* in a function template. // cannot decide between const T& and const T* in a function template.
// These compilers _can_ decide between class template specializations // These compilers _can_ decide between class template specializations
// for T and T*, so a tr1::type_traits-like is_pointer works, and we // for T and T*, so a tr1::type_traits-like is_pointer works, and we
// can overload on that. // can overload on that.
// This overload makes sure that all pointers (including // This overload makes sure that all pointers (including
// those to char or wchar_t) are printed as raw pointers. // those to char or wchar_t) are printed as raw pointers.
template <typename T> template <typename T>
inline String FormatValueForFailureMessage(internal::true_type dummy, inline String FormatValueForFailureMessage(internal::true_type /*dummy*/,
T* pointer) { T* pointer) {
return StreamableToString(static_cast<const void*>(pointer)); return StreamableToString(static_cast<const void*>(pointer));
} }
template <typename T> template <typename T>
inline String FormatValueForFailureMessage(internal::false_type dummy, inline String FormatValueForFailureMessage(internal::false_type /*dummy*/,
const T& value) { const T& value) {
return StreamableToString(value); return StreamableToString(value);
} }
template <typename T> template <typename T>
inline String FormatForFailureMessage(const T& value) { inline String FormatForFailureMessage(const T& value) {
return FormatValueForFailureMessage( return FormatValueForFailureMessage(
typename internal::is_pointer<T>::type(), value); typename internal::is_pointer<T>::type(), value);
} }
skipping to change at line 385 skipping to change at line 380
// See the following article for more details on ULP: // See the following article for more details on ULP:
// http://www.cygnus-software.com/papers/comparingfloats/comparingfloats. htm. // http://www.cygnus-software.com/papers/comparingfloats/comparingfloats. htm.
static const size_t kMaxUlps = 4; static const size_t kMaxUlps = 4;
// Constructs a FloatingPoint from a raw floating-point number. // Constructs a FloatingPoint from a raw floating-point number.
// //
// On an Intel CPU, passing a non-normalized NAN (Not a Number) // On an Intel CPU, passing a non-normalized NAN (Not a Number)
// around may change its bits, although the new value is guaranteed // around may change its bits, although the new value is guaranteed
// to be also a NAN. Therefore, don't expect this constructor to // to be also a NAN. Therefore, don't expect this constructor to
// preserve the bits in x when x is a NAN. // preserve the bits in x when x is a NAN.
explicit FloatingPoint(const RawType& x) : value_(x) {} explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
// Static methods // Static methods
// Reinterprets a bit pattern as a floating-point number. // Reinterprets a bit pattern as a floating-point number.
// //
// This function is needed to test the AlmostEquals() method. // This function is needed to test the AlmostEquals() method.
static RawType ReinterpretBits(const Bits bits) { static RawType ReinterpretBits(const Bits bits) {
FloatingPoint fp(0); FloatingPoint fp(0);
fp.bits_ = bits; fp.u_.bits_ = bits;
return fp.value_; return fp.u_.value_;
} }
// Returns the floating-point number that represent positive infinity. // Returns the floating-point number that represent positive infinity.
static RawType Infinity() { static RawType Infinity() {
return ReinterpretBits(kExponentBitMask); return ReinterpretBits(kExponentBitMask);
} }
// Non-static methods // Non-static methods
// Returns the bits that represents this number. // Returns the bits that represents this number.
const Bits &bits() const { return bits_; } const Bits &bits() const { return u_.bits_; }
// Returns the exponent bits of this number. // Returns the exponent bits of this number.
Bits exponent_bits() const { return kExponentBitMask & bits_; } Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
// Returns the fraction bits of this number. // Returns the fraction bits of this number.
Bits fraction_bits() const { return kFractionBitMask & bits_; } Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
// Returns the sign bit of this number. // Returns the sign bit of this number.
Bits sign_bit() const { return kSignBitMask & bits_; } Bits sign_bit() const { return kSignBitMask & u_.bits_; }
// Returns true iff this is NAN (not a number). // Returns true iff this is NAN (not a number).
bool is_nan() const { bool is_nan() const {
// It's a NAN if the exponent bits are all ones and the fraction // It's a NAN if the exponent bits are all ones and the fraction
// bits are not entirely zeros. // bits are not entirely zeros.
return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0); return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
} }
// Returns true iff this number is at most kMaxUlps ULP's away from // Returns true iff this number is at most kMaxUlps ULP's away from
// rhs. In particular, this function: // rhs. In particular, this function:
// //
// - returns false if either number is (or both are) NAN. // - returns false if either number is (or both are) NAN.
// - treats really large numbers as almost equal to infinity. // - treats really large numbers as almost equal to infinity.
// - thinks +0.0 and -0.0 are 0 DLP's apart. // - thinks +0.0 and -0.0 are 0 DLP's apart.
bool AlmostEquals(const FloatingPoint& rhs) const { bool AlmostEquals(const FloatingPoint& rhs) const {
// The IEEE standard says that any comparison operation involving // The IEEE standard says that any comparison operation involving
// a NAN must return false. // a NAN must return false.
if (is_nan() || rhs.is_nan()) return false; if (is_nan() || rhs.is_nan()) return false;
return DistanceBetweenSignAndMagnitudeNumbers(bits_, rhs.bits_) <= kMax return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
Ulps; <= kMaxUlps;
} }
private: private:
// The data type used to store the actual floating-point number.
union FloatingPointUnion {
RawType value_; // The raw floating-point number.
Bits bits_; // The bits that represent the number.
};
// Converts an integer from the sign-and-magnitude representation to // Converts an integer from the sign-and-magnitude representation to
// the biased representation. More precisely, let N be 2 to the // the biased representation. More precisely, let N be 2 to the
// power of (kBitCount - 1), an integer x is represented by the // power of (kBitCount - 1), an integer x is represented by the
// unsigned number x + N. // unsigned number x + N.
// //
// For instance, // For instance,
// //
// -N + 1 (the most negative number representable using // -N + 1 (the most negative number representable using
// sign-and-magnitude) is represented by 1; // sign-and-magnitude) is represented by 1;
// 0 is represented by N; and // 0 is represented by N; and
skipping to change at line 473 skipping to change at line 475
// Given two numbers in the sign-and-magnitude representation, // Given two numbers in the sign-and-magnitude representation,
// returns the distance between them as an unsigned number. // returns the distance between them as an unsigned number.
static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1, static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
const Bits &sam2) { const Bits &sam2) {
const Bits biased1 = SignAndMagnitudeToBiased(sam1); const Bits biased1 = SignAndMagnitudeToBiased(sam1);
const Bits biased2 = SignAndMagnitudeToBiased(sam2); const Bits biased2 = SignAndMagnitudeToBiased(sam2);
return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1) ; return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1) ;
} }
union { FloatingPointUnion u_;
RawType value_; // The raw floating-point number.
Bits bits_; // The bits that represent the number.
};
}; };
// Typedefs the instances of the FloatingPoint template class that we // Typedefs the instances of the FloatingPoint template class that we
// care to use. // care to use.
typedef FloatingPoint<float> Float; typedef FloatingPoint<float> Float;
typedef FloatingPoint<double> Double; typedef FloatingPoint<double> Double;
// In order to catch the mistake of putting tests that use different // In order to catch the mistake of putting tests that use different
// test fixture classes in the same test case, we need to assign // test fixture classes in the same test case, we need to assign
// unique IDs to fixture classes and compare them. The TypeId type is // unique IDs to fixture classes and compare them. The TypeId type is
skipping to change at line 619 skipping to change at line 618
// Adds the given test name to defined_test_names_ and return true // Adds the given test name to defined_test_names_ and return true
// if the test case hasn't been registered; otherwise aborts the // if the test case hasn't been registered; otherwise aborts the
// program. // program.
bool AddTestName(const char* file, int line, const char* case_name, bool AddTestName(const char* file, int line, const char* case_name,
const char* test_name) { const char* test_name) {
if (registered_) { if (registered_) {
fprintf(stderr, "%s Test %s must be defined before " fprintf(stderr, "%s Test %s must be defined before "
"REGISTER_TYPED_TEST_CASE_P(%s, ...).\n", "REGISTER_TYPED_TEST_CASE_P(%s, ...).\n",
FormatFileLocation(file, line).c_str(), test_name, case_name) ; FormatFileLocation(file, line).c_str(), test_name, case_name) ;
fflush(stderr); fflush(stderr);
abort(); posix::Abort();
} }
defined_test_names_.insert(test_name); defined_test_names_.insert(test_name);
return true; return true;
} }
// Verifies that registered_tests match the test names in // Verifies that registered_tests match the test names in
// defined_test_names_; returns registered_tests if successful, or // defined_test_names_; returns registered_tests if successful, or
// aborts the program otherwise. // aborts the program otherwise.
const char* VerifyRegisteredTestNames( const char* VerifyRegisteredTestNames(
const char* file, int line, const char* registered_tests); const char* file, int line, const char* registered_tests);
skipping to change at line 728 skipping to change at line 727
// Next, recurses (at compile time) with the tail of the test list. // Next, recurses (at compile time) with the tail of the test list.
return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types> return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>
::Register(prefix, case_name, SkipComma(test_names)); ::Register(prefix, case_name, SkipComma(test_names));
} }
}; };
// The base case for the compile time recursion. // The base case for the compile time recursion.
template <GTEST_TEMPLATE_ Fixture, typename Types> template <GTEST_TEMPLATE_ Fixture, typename Types>
class TypeParameterizedTestCase<Fixture, Templates0, Types> { class TypeParameterizedTestCase<Fixture, Templates0, Types> {
public: public:
static bool Register(const char* prefix, const char* case_name, static bool Register(const char* /*prefix*/, const char* /*case_name*/,
const char* test_names) { const char* /*test_names*/) {
return true; return true;
} }
}; };
#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P #endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
// Returns the current OS stack trace as a String. // Returns the current OS stack trace as a String.
// //
// The maximum number of stack frames to be included is specified by // The maximum number of stack frames to be included is specified by
// the gtest_stack_trace_depth flag. The skip_count parameter // the gtest_stack_trace_depth flag. The skip_count parameter
// specifies the number of top frames to be skipped, which doesn't // specifies the number of top frames to be skipped, which doesn't
// count against the number of frames to be included. // count against the number of frames to be included.
// //
// For example, if Foo() calls Bar(), which in turn calls // For example, if Foo() calls Bar(), which in turn calls
// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count) ; String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count) ;
// Returns the number of failed test parts in the given test result object. // Helpers for suppressing warnings on unreachable code or constant
int GetFailedPartCount(const TestResult* result); // condition.
// A helper for suppressing warnings on unreachable code in some macros. // Always returns true.
bool AlwaysTrue(); bool AlwaysTrue();
// Always returns false.
inline bool AlwaysFalse() { return !AlwaysTrue(); }
// A simple Linear Congruential Generator for generating random
// numbers with a uniform distribution. Unlike rand() and srand(), it
// doesn't use global state (and therefore can't interfere with user
// code). Unlike rand_r(), it's portable. An LCG isn't very random,
// but it's good enough for our purposes.
class Random {
public:
static const UInt32 kMaxRange = 1u << 31;
explicit Random(UInt32 seed) : state_(seed) {}
void Reseed(UInt32 seed) { state_ = seed; }
// Generates a random number from [0, range). Crashes if 'range' is
// 0 or greater than kMaxRange.
UInt32 Generate(UInt32 range);
private:
UInt32 state_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
};
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#define GTEST_MESSAGE_(message, result_type) \ #define GTEST_MESSAGE_(message, result_type) \
::testing::internal::AssertHelper(result_type, __FILE__, __LINE__, messag e) \ ::testing::internal::AssertHelper(result_type, __FILE__, __LINE__, messag e) \
= ::testing::Message() = ::testing::Message()
#define GTEST_FATAL_FAILURE_(message) \ #define GTEST_FATAL_FAILURE_(message) \
return GTEST_MESSAGE_(message, ::testing::TPRT_FATAL_FAILURE) return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
#define GTEST_NONFATAL_FAILURE_(message) \ #define GTEST_NONFATAL_FAILURE_(message) \
GTEST_MESSAGE_(message, ::testing::TPRT_NONFATAL_FAILURE) GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
#define GTEST_SUCCESS_(message) \ #define GTEST_SUCCESS_(message) \
GTEST_MESSAGE_(message, ::testing::TPRT_SUCCESS) GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
// Suppresses MSVC warnings 4072 (unreachable code) for the code following // Suppresses MSVC warnings 4072 (unreachable code) for the code following
// statement if it returns or throws (or doesn't return or throw in some // statement if it returns or throws (or doesn't return or throw in some
// situations). // situations).
#define GTEST_HIDE_UNREACHABLE_CODE_(statement) \ #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
if (::testing::internal::AlwaysTrue()) { statement; } if (::testing::internal::AlwaysTrue()) { statement; }
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \ #define GTEST_TEST_THROW_(statement, expected_exception, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
bool gtest_caught_expected = false; \ bool gtest_caught_expected = false; \
try { \ try { \
GTEST_HIDE_UNREACHABLE_CODE_(statement); \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \ } \
catch (expected_exception const&) { \ catch (expected_exception const&) { \
gtest_caught_expected = true; \ gtest_caught_expected = true; \
} \ } \
catch (...) { \ catch (...) { \
gtest_msg = "Expected: " #statement " throws an exception of type " \ gtest_msg = "Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: it throws a different " \ #expected_exception ".\n Actual: it throws a different " \
"type."; \ "type."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \ } \
skipping to change at line 805 skipping to change at line 829
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(gtest_msg) fail(gtest_msg)
#define GTEST_TEST_NO_THROW_(statement, fail) \ #define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
try { \ try { \
GTEST_HIDE_UNREACHABLE_CODE_(statement); \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \ } \
catch (...) { \ catch (...) { \
gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \ gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws."; \ " Actual: it throws."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
fail(gtest_msg) fail(gtest_msg)
#define GTEST_TEST_ANY_THROW_(statement, fail) \ #define GTEST_TEST_ANY_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
bool gtest_caught_any = false; \ bool gtest_caught_any = false; \
try { \ try { \
GTEST_HIDE_UNREACHABLE_CODE_(statement); \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \ } \
catch (...) { \ catch (...) { \
gtest_caught_any = true; \ gtest_caught_any = true; \
} \ } \
if (!gtest_caught_any) { \ if (!gtest_caught_any) { \
gtest_msg = "Expected: " #statement " throws an exception.\n" \ gtest_msg = "Expected: " #statement " throws an exception.\n" \
" Actual: it doesn't."; \ " Actual: it doesn't."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
fail(gtest_msg) fail(gtest_msg)
#define GTEST_TEST_BOOLEAN_(boolexpr, booltext, actual, expected, fail) \ #define GTEST_TEST_BOOLEAN_(boolexpr, booltext, actual, expected, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (boolexpr) \ if (::testing::internal::IsTrue(boolexpr)) \
; \ ; \
else \ else \
fail("Value of: " booltext "\n Actual: " #actual "\nExpected: " #expec ted) fail("Value of: " booltext "\n Actual: " #actual "\nExpected: " #expec ted)
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \ if (const char* gtest_msg = "") { \
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_check er; \ ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_check er; \
GTEST_HIDE_UNREACHABLE_CODE_(statement); \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
gtest_msg = "Expected: " #statement " doesn't generate new fatal " \ gtest_msg = "Expected: " #statement " doesn't generate new fatal " \
"failures in the current thread.\n" \ "failures in the current thread.\n" \
" Actual: it does."; \ " Actual: it does."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \ goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
} \ } \
} else \ } else \
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \ GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
fail(gtest_msg) fail(gtest_msg)
 End of changes. 31 change blocks. 
38 lines changed or deleted 61 lines changed or added


 gtest-message.h   gtest-message.h 
skipping to change at line 196 skipping to change at line 196
return internal::StrStreamToString(ss_); return internal::StrStreamToString(ss_);
} }
private: private:
#if GTEST_OS_SYMBIAN #if GTEST_OS_SYMBIAN
// These are needed as the Nokia Symbian Compiler cannot decide between // These are needed as the Nokia Symbian Compiler cannot decide between
// const T& and const T* in a function template. The Nokia compiler _can_ // const T& and const T* in a function template. The Nokia compiler _can_
// decide between class template specializations for T and T*, so a // decide between class template specializations for T and T*, so a
// tr1::type_traits-like is_pointer works, and we can overload on that. // tr1::type_traits-like is_pointer works, and we can overload on that.
template <typename T> template <typename T>
inline void StreamHelper(internal::true_type dummy, T* pointer) { inline void StreamHelper(internal::true_type /*dummy*/, T* pointer) {
if (pointer == NULL) { if (pointer == NULL) {
*ss_ << "(null)"; *ss_ << "(null)";
} else { } else {
::GTestStreamToHelper(ss_, pointer); ::GTestStreamToHelper(ss_, pointer);
} }
} }
template <typename T> template <typename T>
inline void StreamHelper(internal::false_type dummy, const T& value) { inline void StreamHelper(internal::false_type /*dummy*/, const T& value) {
::GTestStreamToHelper(ss_, value); ::GTestStreamToHelper(ss_, value);
} }
#endif // GTEST_OS_SYMBIAN #endif // GTEST_OS_SYMBIAN
// We'll hold the text streamed to this object here. // We'll hold the text streamed to this object here.
internal::StrStream* const ss_; internal::StrStream* const ss_;
// We declare (but don't implement) this to prevent the compiler // We declare (but don't implement) this to prevent the compiler
// from implementing the assignment operator. // from implementing the assignment operator.
void operator=(const Message&); void operator=(const Message&);
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 gtest-param-test.h   gtest-param-test.h 
skipping to change at line 148 skipping to change at line 148
// //
// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc // You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
// for more examples. // for more examples.
// //
// In the future, we plan to publish the API for defining new parameter // In the future, we plan to publish the API for defining new parameter
// generators. But for now this interface remains part of the internal // generators. But for now this interface remains part of the internal
// implementation and is subject to change. // implementation and is subject to change.
#endif // 0 #endif // 0
#include <utility>
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#if !GTEST_OS_SYMBIAN
#include <utility>
#endif
#if GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-param-util.h> #include <gtest/internal/gtest-param-util.h>
#include <gtest/internal/gtest-param-util-generated.h> #include <gtest/internal/gtest-param-util-generated.h>
namespace testing { namespace testing {
// Functions producing parameter generators. // Functions producing parameter generators.
// //
 End of changes. 2 change blocks. 
2 lines changed or deleted 4 lines changed or added


 gtest-param-util-generated.h   gtest-param-util-generated.h 
skipping to change at line 66 skipping to change at line 66
// Used in the Values() function to provide polymorphic capabilities. // Used in the Values() function to provide polymorphic capabilities.
template <typename T1> template <typename T1>
class ValueArray1 { class ValueArray1 {
public: public:
explicit ValueArray1(T1 v1) : v1_(v1) {} explicit ValueArray1(T1 v1) : v1_(v1) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); } operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray1& other);
const T1 v1_; const T1 v1_;
}; };
template <typename T1, typename T2> template <typename T1, typename T2>
class ValueArray2 { class ValueArray2 {
public: public:
ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {} ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_}; const T array[] = {v1_, v2_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray2& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
}; };
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
class ValueArray3 { class ValueArray3 {
public: public:
ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {} ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_}; const T array[] = {v1_, v2_, v3_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray3& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
}; };
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
class ValueArray4 { class ValueArray4 {
public: public:
ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3), ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3),
v4_(v4) {} v4_(v4) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_}; const T array[] = {v1_, v2_, v3_, v4_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray4& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
}; };
template <typename T1, typename T2, typename T3, typename T4, typename T5> template <typename T1, typename T2, typename T3, typename T4, typename T5>
class ValueArray5 { class ValueArray5 {
public: public:
ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3 ), ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3 ),
v4_(v4), v5_(v5) {} v4_(v4), v5_(v5) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_}; const T array[] = {v1_, v2_, v3_, v4_, v5_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray5& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
}; };
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 ValueArray6 { class ValueArray6 {
skipping to change at line 155 skipping to change at line 170
ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2), ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2),
v3_(v3), v4_(v4), v5_(v5), v6_(v6) {} v3_(v3), v4_(v4), v5_(v5), v6_(v6) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_}; const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray6& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
}; };
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>
skipping to change at line 177 skipping to change at line 195
ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1), ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1),
v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {} v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_}; const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray7& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
}; };
template <typename T1, typename T2, typename T3, typename T4, typename T5, template <typename T1, typename T2, typename T3, typename T4, typename T5,
skipping to change at line 201 skipping to change at line 222
T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7 ), T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7 ),
v8_(v8) {} v8_(v8) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_}; const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray8& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
}; };
skipping to change at line 226 skipping to change at line 250
T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7 ), T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7 ),
v8_(v8), v9_(v9) {} v8_(v8), v9_(v9) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_}; const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray9& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
}; };
skipping to change at line 252 skipping to change at line 279
T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_( v7), T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_( v7),
v8_(v8), v9_(v9), v10_(v10) {} v8_(v8), v9_(v9), v10_(v10) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_}; const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray10& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 280 skipping to change at line 310
T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_( v6), T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_( v6),
v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {} v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_}; const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray11& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 310 skipping to change at line 343
v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) { } v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) { }
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_}; v12_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray12& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 342 skipping to change at line 378
v12_(v12), v13_(v13) {} v12_(v12), v13_(v13) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_}; v12_, v13_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray13& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 375 skipping to change at line 414
v11_(v11), v12_(v12), v13_(v13), v14_(v14) {} v11_(v11), v12_(v12), v13_(v13), v14_(v14) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_}; v12_, v13_, v14_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray14& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 409 skipping to change at line 451
v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {} v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_}; v12_, v13_, v14_, v15_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray15& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 446 skipping to change at line 491
v16_(v16) {} v16_(v16) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_}; v12_, v13_, v14_, v15_, v16_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray16& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 484 skipping to change at line 532
v15_(v15), v16_(v16), v17_(v17) {} v15_(v15), v16_(v16), v17_(v17) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_}; v12_, v13_, v14_, v15_, v16_, v17_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray17& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 523 skipping to change at line 574
v15_(v15), v16_(v16), v17_(v17), v18_(v18) {} v15_(v15), v16_(v16), v17_(v17), v18_(v18) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_}; v12_, v13_, v14_, v15_, v16_, v17_, v18_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray18& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 563 skipping to change at line 617
v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {} v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_}; v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray19& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 605 skipping to change at line 662
v19_(v19), v20_(v20) {} v19_(v19), v20_(v20) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_}; v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray20& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 649 skipping to change at line 709
v18_(v18), v19_(v19), v20_(v20), v21_(v21) {} v18_(v18), v19_(v19), v20_(v20), v21_(v21) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_}; v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray21& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 694 skipping to change at line 757
v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {} v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {}
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_}; v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray22& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 742 skipping to change at line 808
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_,
v23_}; v23_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray23& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 791 skipping to change at line 860
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_}; v24_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray24& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 841 skipping to change at line 913
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_}; v24_, v25_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray25& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 893 skipping to change at line 968
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_}; v24_, v25_, v26_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray26& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 947 skipping to change at line 1025
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_}; v24_, v25_, v26_, v27_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray27& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1002 skipping to change at line 1083
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_}; v24_, v25_, v26_, v27_, v28_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray28& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1058 skipping to change at line 1142
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_}; v24_, v25_, v26_, v27_, v28_, v29_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray29& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1116 skipping to change at line 1203
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_}; v24_, v25_, v26_, v27_, v28_, v29_, v30_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray30& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1176 skipping to change at line 1266
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_}; v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray31& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1237 skipping to change at line 1330
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_}; v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray32& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1300 skipping to change at line 1396
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_}; v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray33& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1364 skipping to change at line 1463
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_}; v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray34& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1430 skipping to change at line 1532
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_,
v35_}; v35_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray35& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1498 skipping to change at line 1603
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_}; v36_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray36& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1568 skipping to change at line 1676
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_}; v36_, v37_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray37& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1639 skipping to change at line 1750
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_}; v36_, v37_, v38_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray38& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1711 skipping to change at line 1825
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_}; v36_, v37_, v38_, v39_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray39& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1785 skipping to change at line 1902
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_}; v36_, v37_, v38_, v39_, v40_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray40& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1861 skipping to change at line 1981
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_}; v36_, v37_, v38_, v39_, v40_, v41_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray41& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 1938 skipping to change at line 2061
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_}; v36_, v37_, v38_, v39_, v40_, v41_, v42_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray42& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2016 skipping to change at line 2142
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_}; v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray43& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2096 skipping to change at line 2225
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_}; v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray44& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2177 skipping to change at line 2309
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_}; v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray45& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2260 skipping to change at line 2395
template <typename T> template <typename T>
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_}; v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray46& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2346 skipping to change at line 2484
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_,
v47_}; v47_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray47& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2433 skipping to change at line 2574
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v 47_, v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v 47_,
v48_}; v48_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray48& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2521 skipping to change at line 2665
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v 47_, v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v 47_,
v48_, v49_}; v48_, v49_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray49& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2610 skipping to change at line 2757
operator ParamGenerator<T>() const { operator ParamGenerator<T>() const {
const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_, const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v 11_,
v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_, v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v 23_,
v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_, v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v 35_,
v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v 47_, v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v 47_,
v48_, v49_, v50_}; v48_, v49_, v50_};
return ValuesIn(array); return ValuesIn(array);
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const ValueArray50& other);
const T1 v1_; const T1 v1_;
const T2 v2_; const T2 v2_;
const T3 v3_; const T3 v3_;
const T4 v4_; const T4 v4_;
const T5 v5_; const T5 v5_;
const T6 v6_; const T6 v6_;
const T7 v7_; const T7 v7_;
const T8 v8_; const T8 v8_;
const T9 v9_; const T9 v9_;
const T10 v10_; const T10 v10_;
skipping to change at line 2760 skipping to change at line 2910
current_value_ = ParamType(*current1_, *current2_); current_value_ = ParamType(*current1_, *current2_);
} }
bool AtEnd() const { bool AtEnd() const {
// We must report iterator past the end of the range when either of t he // We must report iterator past the end of the range when either of t he
// component iterators has reached the end of its range. // component iterators has reached the end of its range.
return return
current1_ == end1_ || current1_ == end1_ ||
current2_ == end2_; current2_ == end2_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator2::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator2& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
}; }; // class CartesianProductGenerator2
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
class CartesianProductGenerator3 class CartesianProductGenerator3
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3> > { : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3> ParamType; typedef ::std::tr1::tuple<T1, T2, T3> ParamType;
CartesianProductGenerator3(const ParamGenerator<T1>& g1, CartesianProductGenerator3(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3) const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)
: g1_(g1), g2_(g2), g3_(g3) {} : g1_(g1), g2_(g2), g3_(g3) {}
skipping to change at line 2881 skipping to change at line 3037
} }
bool AtEnd() const { bool AtEnd() const {
// We must report iterator past the end of the range when either of t he // We must report iterator past the end of the range when either of t he
// component iterators has reached the end of its range. // component iterators has reached the end of its range.
return return
current1_ == end1_ || current1_ == end1_ ||
current2_ == end2_ || current2_ == end2_ ||
current3_ == end3_; current3_ == end3_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
const typename ParamGenerator<T3>::iterator end3_; const typename ParamGenerator<T3>::iterator end3_;
typename ParamGenerator<T3>::iterator current3_; typename ParamGenerator<T3>::iterator current3_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator3::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator3& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
}; }; // class CartesianProductGenerator3
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
class CartesianProductGenerator4 class CartesianProductGenerator4
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4> > { : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3, T4> ParamType; typedef ::std::tr1::tuple<T1, T2, T3, T4> ParamType;
CartesianProductGenerator4(const ParamGenerator<T1>& g1, CartesianProductGenerator4(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
const ParamGenerator<T4>& g4) const ParamGenerator<T4>& g4)
skipping to change at line 3021 skipping to change at line 3183
bool AtEnd() const { bool AtEnd() const {
// We must report iterator past the end of the range when either of t he // We must report iterator past the end of the range when either of t he
// component iterators has reached the end of its range. // component iterators has reached the end of its range.
return return
current1_ == end1_ || current1_ == end1_ ||
current2_ == end2_ || current2_ == end2_ ||
current3_ == end3_ || current3_ == end3_ ||
current4_ == end4_; current4_ == end4_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
const typename ParamGenerator<T3>::iterator end3_; const typename ParamGenerator<T3>::iterator end3_;
typename ParamGenerator<T3>::iterator current3_; typename ParamGenerator<T3>::iterator current3_;
const typename ParamGenerator<T4>::iterator begin4_; const typename ParamGenerator<T4>::iterator begin4_;
const typename ParamGenerator<T4>::iterator end4_; const typename ParamGenerator<T4>::iterator end4_;
typename ParamGenerator<T4>::iterator current4_; typename ParamGenerator<T4>::iterator current4_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator4::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator4& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_; const ParamGenerator<T4> g4_;
}; }; // class CartesianProductGenerator4
template <typename T1, typename T2, typename T3, typename T4, typename T5> template <typename T1, typename T2, typename T3, typename T4, typename T5>
class CartesianProductGenerator5 class CartesianProductGenerator5
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5> > { : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3, T4, T5> ParamType; typedef ::std::tr1::tuple<T1, T2, T3, T4, T5> ParamType;
CartesianProductGenerator5(const ParamGenerator<T1>& g1, CartesianProductGenerator5(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5) const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5)
skipping to change at line 3177 skipping to change at line 3345
// We must report iterator past the end of the range when either of t he // We must report iterator past the end of the range when either of t he
// component iterators has reached the end of its range. // component iterators has reached the end of its range.
return return
current1_ == end1_ || current1_ == end1_ ||
current2_ == end2_ || current2_ == end2_ ||
current3_ == end3_ || current3_ == end3_ ||
current4_ == end4_ || current4_ == end4_ ||
current5_ == end5_; current5_ == end5_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
const typename ParamGenerator<T3>::iterator end3_; const typename ParamGenerator<T3>::iterator end3_;
typename ParamGenerator<T3>::iterator current3_; typename ParamGenerator<T3>::iterator current3_;
const typename ParamGenerator<T4>::iterator begin4_; const typename ParamGenerator<T4>::iterator begin4_;
const typename ParamGenerator<T4>::iterator end4_; const typename ParamGenerator<T4>::iterator end4_;
typename ParamGenerator<T4>::iterator current4_; typename ParamGenerator<T4>::iterator current4_;
const typename ParamGenerator<T5>::iterator begin5_; const typename ParamGenerator<T5>::iterator begin5_;
const typename ParamGenerator<T5>::iterator end5_; const typename ParamGenerator<T5>::iterator end5_;
typename ParamGenerator<T5>::iterator current5_; typename ParamGenerator<T5>::iterator current5_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator5::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator5& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_; const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_; const ParamGenerator<T5> g5_;
}; }; // class CartesianProductGenerator5
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 CartesianProductGenerator6 class CartesianProductGenerator6
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5,
T6> > { T6> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> ParamType; typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> ParamType;
CartesianProductGenerator6(const ParamGenerator<T1>& g1, CartesianProductGenerator6(const ParamGenerator<T1>& g1,
skipping to change at line 3352 skipping to change at line 3526
// component iterators has reached the end of its range. // component iterators has reached the end of its range.
return return
current1_ == end1_ || current1_ == end1_ ||
current2_ == end2_ || current2_ == end2_ ||
current3_ == end3_ || current3_ == end3_ ||
current4_ == end4_ || current4_ == end4_ ||
current5_ == end5_ || current5_ == end5_ ||
current6_ == end6_; current6_ == end6_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
skipping to change at line 3374 skipping to change at line 3551
const typename ParamGenerator<T4>::iterator begin4_; const typename ParamGenerator<T4>::iterator begin4_;
const typename ParamGenerator<T4>::iterator end4_; const typename ParamGenerator<T4>::iterator end4_;
typename ParamGenerator<T4>::iterator current4_; typename ParamGenerator<T4>::iterator current4_;
const typename ParamGenerator<T5>::iterator begin5_; const typename ParamGenerator<T5>::iterator begin5_;
const typename ParamGenerator<T5>::iterator end5_; const typename ParamGenerator<T5>::iterator end5_;
typename ParamGenerator<T5>::iterator current5_; typename ParamGenerator<T5>::iterator current5_;
const typename ParamGenerator<T6>::iterator begin6_; const typename ParamGenerator<T6>::iterator begin6_;
const typename ParamGenerator<T6>::iterator end6_; const typename ParamGenerator<T6>::iterator end6_;
typename ParamGenerator<T6>::iterator current6_; typename ParamGenerator<T6>::iterator current6_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator6::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator6& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_; const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_; const ParamGenerator<T5> g5_;
const ParamGenerator<T6> g6_; const ParamGenerator<T6> g6_;
}; }; // class CartesianProductGenerator6
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 CartesianProductGenerator7 class CartesianProductGenerator7
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
T7> > { T7> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType; typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;
CartesianProductGenerator7(const ParamGenerator<T1>& g1, CartesianProductGenerator7(const ParamGenerator<T1>& g1,
skipping to change at line 3544 skipping to change at line 3724
return return
current1_ == end1_ || current1_ == end1_ ||
current2_ == end2_ || current2_ == end2_ ||
current3_ == end3_ || current3_ == end3_ ||
current4_ == end4_ || current4_ == end4_ ||
current5_ == end5_ || current5_ == end5_ ||
current6_ == end6_ || current6_ == end6_ ||
current7_ == end7_; current7_ == end7_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
skipping to change at line 3569 skipping to change at line 3752
const typename ParamGenerator<T5>::iterator begin5_; const typename ParamGenerator<T5>::iterator begin5_;
const typename ParamGenerator<T5>::iterator end5_; const typename ParamGenerator<T5>::iterator end5_;
typename ParamGenerator<T5>::iterator current5_; typename ParamGenerator<T5>::iterator current5_;
const typename ParamGenerator<T6>::iterator begin6_; const typename ParamGenerator<T6>::iterator begin6_;
const typename ParamGenerator<T6>::iterator end6_; const typename ParamGenerator<T6>::iterator end6_;
typename ParamGenerator<T6>::iterator current6_; typename ParamGenerator<T6>::iterator current6_;
const typename ParamGenerator<T7>::iterator begin7_; const typename ParamGenerator<T7>::iterator begin7_;
const typename ParamGenerator<T7>::iterator end7_; const typename ParamGenerator<T7>::iterator end7_;
typename ParamGenerator<T7>::iterator current7_; typename ParamGenerator<T7>::iterator current7_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator7::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator7& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_; const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_; const ParamGenerator<T5> g5_;
const ParamGenerator<T6> g6_; const ParamGenerator<T6> g6_;
const ParamGenerator<T7> g7_; const ParamGenerator<T7> g7_;
}; }; // class CartesianProductGenerator7
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 CartesianProductGenerator8 class CartesianProductGenerator8
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
T7, T8> > { T7, T8> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType; typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;
CartesianProductGenerator8(const ParamGenerator<T1>& g1, CartesianProductGenerator8(const ParamGenerator<T1>& g1,
skipping to change at line 3755 skipping to change at line 3941
current1_ == end1_ || current1_ == end1_ ||
current2_ == end2_ || current2_ == end2_ ||
current3_ == end3_ || current3_ == end3_ ||
current4_ == end4_ || current4_ == end4_ ||
current5_ == end5_ || current5_ == end5_ ||
current6_ == end6_ || current6_ == end6_ ||
current7_ == end7_ || current7_ == end7_ ||
current8_ == end8_; current8_ == end8_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
skipping to change at line 3783 skipping to change at line 3972
const typename ParamGenerator<T6>::iterator begin6_; const typename ParamGenerator<T6>::iterator begin6_;
const typename ParamGenerator<T6>::iterator end6_; const typename ParamGenerator<T6>::iterator end6_;
typename ParamGenerator<T6>::iterator current6_; typename ParamGenerator<T6>::iterator current6_;
const typename ParamGenerator<T7>::iterator begin7_; const typename ParamGenerator<T7>::iterator begin7_;
const typename ParamGenerator<T7>::iterator end7_; const typename ParamGenerator<T7>::iterator end7_;
typename ParamGenerator<T7>::iterator current7_; typename ParamGenerator<T7>::iterator current7_;
const typename ParamGenerator<T8>::iterator begin8_; const typename ParamGenerator<T8>::iterator begin8_;
const typename ParamGenerator<T8>::iterator end8_; const typename ParamGenerator<T8>::iterator end8_;
typename ParamGenerator<T8>::iterator current8_; typename ParamGenerator<T8>::iterator current8_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator8::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator8& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_; const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_; const ParamGenerator<T5> g5_;
const ParamGenerator<T6> g6_; const ParamGenerator<T6> g6_;
const ParamGenerator<T7> g7_; const ParamGenerator<T7> g7_;
const ParamGenerator<T8> g8_; const ParamGenerator<T8> g8_;
}; }; // class CartesianProductGenerator8
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 T9> typename T6, typename T7, typename T8, typename T9>
class CartesianProductGenerator9 class CartesianProductGenerator9
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
T7, T8, T9> > { T7, T8, T9> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType; typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;
CartesianProductGenerator9(const ParamGenerator<T1>& g1, CartesianProductGenerator9(const ParamGenerator<T1>& g1,
skipping to change at line 3983 skipping to change at line 4175
current2_ == end2_ || current2_ == end2_ ||
current3_ == end3_ || current3_ == end3_ ||
current4_ == end4_ || current4_ == end4_ ||
current5_ == end5_ || current5_ == end5_ ||
current6_ == end6_ || current6_ == end6_ ||
current7_ == end7_ || current7_ == end7_ ||
current8_ == end8_ || current8_ == end8_ ||
current9_ == end9_; current9_ == end9_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
skipping to change at line 4014 skipping to change at line 4209
const typename ParamGenerator<T7>::iterator begin7_; const typename ParamGenerator<T7>::iterator begin7_;
const typename ParamGenerator<T7>::iterator end7_; const typename ParamGenerator<T7>::iterator end7_;
typename ParamGenerator<T7>::iterator current7_; typename ParamGenerator<T7>::iterator current7_;
const typename ParamGenerator<T8>::iterator begin8_; const typename ParamGenerator<T8>::iterator begin8_;
const typename ParamGenerator<T8>::iterator end8_; const typename ParamGenerator<T8>::iterator end8_;
typename ParamGenerator<T8>::iterator current8_; typename ParamGenerator<T8>::iterator current8_;
const typename ParamGenerator<T9>::iterator begin9_; const typename ParamGenerator<T9>::iterator begin9_;
const typename ParamGenerator<T9>::iterator end9_; const typename ParamGenerator<T9>::iterator end9_;
typename ParamGenerator<T9>::iterator current9_; typename ParamGenerator<T9>::iterator current9_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator9::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator9& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_; const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_; const ParamGenerator<T5> g5_;
const ParamGenerator<T6> g6_; const ParamGenerator<T6> g6_;
const ParamGenerator<T7> g7_; const ParamGenerator<T7> g7_;
const ParamGenerator<T8> g8_; const ParamGenerator<T8> g8_;
const ParamGenerator<T9> g9_; const ParamGenerator<T9> g9_;
}; }; // class CartesianProductGenerator9
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 T9, typename T10> typename T6, typename T7, typename T8, typename T9, typename T10>
class CartesianProductGenerator10 class CartesianProductGenerator10
: public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
T7, T8, T9, T10> > { T7, T8, T9, T10> > {
public: public:
typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamT ype; typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamT ype;
CartesianProductGenerator10(const ParamGenerator<T1>& g1, CartesianProductGenerator10(const ParamGenerator<T1>& g1,
skipping to change at line 4228 skipping to change at line 4426
current3_ == end3_ || current3_ == end3_ ||
current4_ == end4_ || current4_ == end4_ ||
current5_ == end5_ || current5_ == end5_ ||
current6_ == end6_ || current6_ == end6_ ||
current7_ == end7_ || current7_ == end7_ ||
current8_ == end8_ || current8_ == end8_ ||
current9_ == end9_ || current9_ == end9_ ||
current10_ == end10_; current10_ == end10_;
} }
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<ParamType>* const base_; const ParamGeneratorInterface<ParamType>* const base_;
// begin[i]_ and end[i]_ define the i-th range that Iterator traverses. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
// current[i]_ is the actual traversing iterator. // current[i]_ is the actual traversing iterator.
const typename ParamGenerator<T1>::iterator begin1_; const typename ParamGenerator<T1>::iterator begin1_;
const typename ParamGenerator<T1>::iterator end1_; const typename ParamGenerator<T1>::iterator end1_;
typename ParamGenerator<T1>::iterator current1_; typename ParamGenerator<T1>::iterator current1_;
const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator begin2_;
const typename ParamGenerator<T2>::iterator end2_; const typename ParamGenerator<T2>::iterator end2_;
typename ParamGenerator<T2>::iterator current2_; typename ParamGenerator<T2>::iterator current2_;
const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator begin3_;
skipping to change at line 4262 skipping to change at line 4463
const typename ParamGenerator<T8>::iterator begin8_; const typename ParamGenerator<T8>::iterator begin8_;
const typename ParamGenerator<T8>::iterator end8_; const typename ParamGenerator<T8>::iterator end8_;
typename ParamGenerator<T8>::iterator current8_; typename ParamGenerator<T8>::iterator current8_;
const typename ParamGenerator<T9>::iterator begin9_; const typename ParamGenerator<T9>::iterator begin9_;
const typename ParamGenerator<T9>::iterator end9_; const typename ParamGenerator<T9>::iterator end9_;
typename ParamGenerator<T9>::iterator current9_; typename ParamGenerator<T9>::iterator current9_;
const typename ParamGenerator<T10>::iterator begin10_; const typename ParamGenerator<T10>::iterator begin10_;
const typename ParamGenerator<T10>::iterator end10_; const typename ParamGenerator<T10>::iterator end10_;
typename ParamGenerator<T10>::iterator current10_; typename ParamGenerator<T10>::iterator current10_;
ParamType current_value_; ParamType current_value_;
}; }; // class CartesianProductGenerator10::Iterator
// No implementation - assignment is unsupported.
void operator=(const CartesianProductGenerator10& other);
const ParamGenerator<T1> g1_; const ParamGenerator<T1> g1_;
const ParamGenerator<T2> g2_; const ParamGenerator<T2> g2_;
const ParamGenerator<T3> g3_; const ParamGenerator<T3> g3_;
const ParamGenerator<T4> g4_; const ParamGenerator<T4> g4_;
const ParamGenerator<T5> g5_; const ParamGenerator<T5> g5_;
const ParamGenerator<T6> g6_; const ParamGenerator<T6> g6_;
const ParamGenerator<T7> g7_; const ParamGenerator<T7> g7_;
const ParamGenerator<T8> g8_; const ParamGenerator<T8> g8_;
const ParamGenerator<T9> g9_; const ParamGenerator<T9> g9_;
const ParamGenerator<T10> g10_; const ParamGenerator<T10> g10_;
}; }; // class CartesianProductGenerator10
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// //
// Helper classes providing Combine() with polymorphic features. They allow // Helper classes providing Combine() with polymorphic features. They allow
// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is // casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
// convertible to U. // convertible to U.
// //
template <class Generator1, class Generator2> template <class Generator1, class Generator2>
class CartesianProductHolder2 { class CartesianProductHolder2 {
public: public:
skipping to change at line 4296 skipping to change at line 4500
: g1_(g1), g2_(g2) {} : g1_(g1), g2_(g2) {}
template <typename T1, typename T2> template <typename T1, typename T2>
operator ParamGenerator< ::std::tr1::tuple<T1, T2> >() const { operator ParamGenerator< ::std::tr1::tuple<T1, T2> >() const {
return ParamGenerator< ::std::tr1::tuple<T1, T2> >( return ParamGenerator< ::std::tr1::tuple<T1, T2> >(
new CartesianProductGenerator2<T1, T2>( new CartesianProductGenerator2<T1, T2>(
static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_))); static_cast<ParamGenerator<T2> >(g2_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder2& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
}; }; // class CartesianProductHolder2
template <class Generator1, class Generator2, class Generator3> template <class Generator1, class Generator2, class Generator3>
class CartesianProductHolder3 { class CartesianProductHolder3 {
public: public:
CartesianProductHolder3(const Generator1& g1, const Generator2& g2, CartesianProductHolder3(const Generator1& g1, const Generator2& g2,
const Generator3& g3) const Generator3& g3)
: g1_(g1), g2_(g2), g3_(g3) {} : g1_(g1), g2_(g2), g3_(g3) {}
template <typename T1, typename T2, typename T3> template <typename T1, typename T2, typename T3>
operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >() const { operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >() const {
return ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >( return ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >(
new CartesianProductGenerator3<T1, T2, T3>( new CartesianProductGenerator3<T1, T2, T3>(
static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_), static_cast<ParamGenerator<T2> >(g2_),
static_cast<ParamGenerator<T3> >(g3_))); static_cast<ParamGenerator<T3> >(g3_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder3& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
}; }; // class CartesianProductHolder3
template <class Generator1, class Generator2, class Generator3, template <class Generator1, class Generator2, class Generator3,
class Generator4> class Generator4>
class CartesianProductHolder4 { class CartesianProductHolder4 {
public: public:
CartesianProductHolder4(const Generator1& g1, const Generator2& g2, CartesianProductHolder4(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4) const Generator3& g3, const Generator4& g4)
: g1_(g1), g2_(g2), g3_(g3), g4_(g4) {} : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
template <typename T1, typename T2, typename T3, typename T4> template <typename T1, typename T2, typename T3, typename T4>
operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >() const { operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >() const {
return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >( return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >(
new CartesianProductGenerator4<T1, T2, T3, T4>( new CartesianProductGenerator4<T1, T2, T3, T4>(
static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_), static_cast<ParamGenerator<T2> >(g2_),
static_cast<ParamGenerator<T3> >(g3_), static_cast<ParamGenerator<T3> >(g3_),
static_cast<ParamGenerator<T4> >(g4_))); static_cast<ParamGenerator<T4> >(g4_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder4& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
const Generator4 g4_; const Generator4 g4_;
}; }; // class CartesianProductHolder4
template <class Generator1, class Generator2, class Generator3, template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5> class Generator4, class Generator5>
class CartesianProductHolder5 { class CartesianProductHolder5 {
public: public:
CartesianProductHolder5(const Generator1& g1, const Generator2& g2, CartesianProductHolder5(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4, const Generator5& g5) const Generator3& g3, const Generator4& g4, const Generator5& g5)
: g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {} : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5 > template <typename T1, typename T2, typename T3, typename T4, typename T5 >
operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >() const { operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >() const {
return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >( return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >(
new CartesianProductGenerator5<T1, T2, T3, T4, T5>( new CartesianProductGenerator5<T1, T2, T3, T4, T5>(
static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_), static_cast<ParamGenerator<T2> >(g2_),
static_cast<ParamGenerator<T3> >(g3_), static_cast<ParamGenerator<T3> >(g3_),
static_cast<ParamGenerator<T4> >(g4_), static_cast<ParamGenerator<T4> >(g4_),
static_cast<ParamGenerator<T5> >(g5_))); static_cast<ParamGenerator<T5> >(g5_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder5& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
const Generator4 g4_; const Generator4 g4_;
const Generator5 g5_; const Generator5 g5_;
}; }; // class CartesianProductHolder5
template <class Generator1, class Generator2, class Generator3, template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6> class Generator4, class Generator5, class Generator6>
class CartesianProductHolder6 { class CartesianProductHolder6 {
public: public:
CartesianProductHolder6(const Generator1& g1, const Generator2& g2, CartesianProductHolder6(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4, const Generator5& g5, const Generator3& g3, const Generator4& g4, const Generator5& g5,
const Generator6& g6) const Generator6& g6)
: g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {} : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5 , template <typename T1, typename T2, typename T3, typename T4, typename T5 ,
skipping to change at line 4393 skipping to change at line 4609
new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>( new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(
static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_), static_cast<ParamGenerator<T2> >(g2_),
static_cast<ParamGenerator<T3> >(g3_), static_cast<ParamGenerator<T3> >(g3_),
static_cast<ParamGenerator<T4> >(g4_), static_cast<ParamGenerator<T4> >(g4_),
static_cast<ParamGenerator<T5> >(g5_), static_cast<ParamGenerator<T5> >(g5_),
static_cast<ParamGenerator<T6> >(g6_))); static_cast<ParamGenerator<T6> >(g6_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder6& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
const Generator4 g4_; const Generator4 g4_;
const Generator5 g5_; const Generator5 g5_;
const Generator6 g6_; const Generator6 g6_;
}; }; // class CartesianProductHolder6
template <class Generator1, class Generator2, class Generator3, template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7> class Generator4, class Generator5, class Generator6, class Generator7>
class CartesianProductHolder7 { class CartesianProductHolder7 {
public: public:
CartesianProductHolder7(const Generator1& g1, const Generator2& g2, CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4, const Generator5& g5, const Generator3& g3, const Generator4& g4, const Generator5& g5,
const Generator6& g6, const Generator7& g7) const Generator6& g6, const Generator7& g7)
: g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {} : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5 , template <typename T1, typename T2, typename T3, typename T4, typename T5 ,
skipping to change at line 4425 skipping to change at line 4644
static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_), static_cast<ParamGenerator<T2> >(g2_),
static_cast<ParamGenerator<T3> >(g3_), static_cast<ParamGenerator<T3> >(g3_),
static_cast<ParamGenerator<T4> >(g4_), static_cast<ParamGenerator<T4> >(g4_),
static_cast<ParamGenerator<T5> >(g5_), static_cast<ParamGenerator<T5> >(g5_),
static_cast<ParamGenerator<T6> >(g6_), static_cast<ParamGenerator<T6> >(g6_),
static_cast<ParamGenerator<T7> >(g7_))); static_cast<ParamGenerator<T7> >(g7_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder7& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
const Generator4 g4_; const Generator4 g4_;
const Generator5 g5_; const Generator5 g5_;
const Generator6 g6_; const Generator6 g6_;
const Generator7 g7_; const Generator7 g7_;
}; }; // class CartesianProductHolder7
template <class Generator1, class Generator2, class Generator3, template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7, class Generator4, class Generator5, class Generator6, class Generator7,
class Generator8> class Generator8>
class CartesianProductHolder8 { class CartesianProductHolder8 {
public: public:
CartesianProductHolder8(const Generator1& g1, const Generator2& g2, CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4, const Generator5& g5, const Generator3& g3, const Generator4& g4, const Generator5& g5,
const Generator6& g6, const Generator7& g7, const Generator8& g8) const Generator6& g6, const Generator7& g7, const Generator8& g8)
: g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
skipping to change at line 4461 skipping to change at line 4683
static_cast<ParamGenerator<T2> >(g2_), static_cast<ParamGenerator<T2> >(g2_),
static_cast<ParamGenerator<T3> >(g3_), static_cast<ParamGenerator<T3> >(g3_),
static_cast<ParamGenerator<T4> >(g4_), static_cast<ParamGenerator<T4> >(g4_),
static_cast<ParamGenerator<T5> >(g5_), static_cast<ParamGenerator<T5> >(g5_),
static_cast<ParamGenerator<T6> >(g6_), static_cast<ParamGenerator<T6> >(g6_),
static_cast<ParamGenerator<T7> >(g7_), static_cast<ParamGenerator<T7> >(g7_),
static_cast<ParamGenerator<T8> >(g8_))); static_cast<ParamGenerator<T8> >(g8_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder8& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
const Generator4 g4_; const Generator4 g4_;
const Generator5 g5_; const Generator5 g5_;
const Generator6 g6_; const Generator6 g6_;
const Generator7 g7_; const Generator7 g7_;
const Generator8 g8_; const Generator8 g8_;
}; }; // class CartesianProductHolder8
template <class Generator1, class Generator2, class Generator3, template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7, class Generator4, class Generator5, class Generator6, class Generator7,
class Generator8, class Generator9> class Generator8, class Generator9>
class CartesianProductHolder9 { class CartesianProductHolder9 {
public: public:
CartesianProductHolder9(const Generator1& g1, const Generator2& g2, CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4, const Generator5& g5, const Generator3& g3, const Generator4& g4, const Generator5& g5,
const Generator6& g6, const Generator7& g7, const Generator8& g8, const Generator6& g6, const Generator7& g7, const Generator8& g8,
const Generator9& g9) const Generator9& g9)
skipping to change at line 4501 skipping to change at line 4726
static_cast<ParamGenerator<T3> >(g3_), static_cast<ParamGenerator<T3> >(g3_),
static_cast<ParamGenerator<T4> >(g4_), static_cast<ParamGenerator<T4> >(g4_),
static_cast<ParamGenerator<T5> >(g5_), static_cast<ParamGenerator<T5> >(g5_),
static_cast<ParamGenerator<T6> >(g6_), static_cast<ParamGenerator<T6> >(g6_),
static_cast<ParamGenerator<T7> >(g7_), static_cast<ParamGenerator<T7> >(g7_),
static_cast<ParamGenerator<T8> >(g8_), static_cast<ParamGenerator<T8> >(g8_),
static_cast<ParamGenerator<T9> >(g9_))); static_cast<ParamGenerator<T9> >(g9_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder9& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
const Generator4 g4_; const Generator4 g4_;
const Generator5 g5_; const Generator5 g5_;
const Generator6 g6_; const Generator6 g6_;
const Generator7 g7_; const Generator7 g7_;
const Generator8 g8_; const Generator8 g8_;
const Generator9 g9_; const Generator9 g9_;
}; }; // class CartesianProductHolder9
template <class Generator1, class Generator2, class Generator3, template <class Generator1, class Generator2, class Generator3,
class Generator4, class Generator5, class Generator6, class Generator7, class Generator4, class Generator5, class Generator6, class Generator7,
class Generator8, class Generator9, class Generator10> class Generator8, class Generator9, class Generator10>
class CartesianProductHolder10 { class CartesianProductHolder10 {
public: public:
CartesianProductHolder10(const Generator1& g1, const Generator2& g2, CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4, const Generator5& g5, const Generator3& g3, const Generator4& g4, const Generator5& g5,
const Generator6& g6, const Generator7& g7, const Generator8& g8, const Generator6& g6, const Generator7& g7, const Generator8& g8,
const Generator9& g9, const Generator10& g10) const Generator9& g9, const Generator10& g10)
skipping to change at line 4544 skipping to change at line 4772
static_cast<ParamGenerator<T4> >(g4_), static_cast<ParamGenerator<T4> >(g4_),
static_cast<ParamGenerator<T5> >(g5_), static_cast<ParamGenerator<T5> >(g5_),
static_cast<ParamGenerator<T6> >(g6_), static_cast<ParamGenerator<T6> >(g6_),
static_cast<ParamGenerator<T7> >(g7_), static_cast<ParamGenerator<T7> >(g7_),
static_cast<ParamGenerator<T8> >(g8_), static_cast<ParamGenerator<T8> >(g8_),
static_cast<ParamGenerator<T9> >(g9_), static_cast<ParamGenerator<T9> >(g9_),
static_cast<ParamGenerator<T10> >(g10_))); static_cast<ParamGenerator<T10> >(g10_)));
} }
private: private:
// No implementation - assignment is unsupported.
void operator=(const CartesianProductHolder10& other);
const Generator1 g1_; const Generator1 g1_;
const Generator2 g2_; const Generator2 g2_;
const Generator3 g3_; const Generator3 g3_;
const Generator4 g4_; const Generator4 g4_;
const Generator5 g5_; const Generator5 g5_;
const Generator6 g6_; const Generator6 g6_;
const Generator7 g7_; const Generator7 g7_;
const Generator8 g8_; const Generator8 g8_;
const Generator9 g9_; const Generator9 g9_;
const Generator10 g10_; const Generator10 g10_;
}; }; // class CartesianProductHolder10
#endif // GTEST_HAS_COMBINE #endif // GTEST_HAS_COMBINE
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
 End of changes. 95 change blocks. 
27 lines changed or deleted 258 lines changed or added


 gtest-param-util.h   gtest-param-util.h 
skipping to change at line 251 skipping to change at line 251
const int other_index = const int other_index =
CheckedDowncastToActualType<const Iterator>(&other)->index_; CheckedDowncastToActualType<const Iterator>(&other)->index_;
return index_ == other_index; return index_ == other_index;
} }
private: private:
Iterator(const Iterator& other) Iterator(const Iterator& other)
: base_(other.base_), value_(other.value_), index_(other.index_), : base_(other.base_), value_(other.value_), index_(other.index_),
step_(other.step_) {} step_(other.step_) {}
// No implementation - assignment is unsupported.
void operator=(const Iterator& other);
const ParamGeneratorInterface<T>* const base_; const ParamGeneratorInterface<T>* const base_;
T value_; T value_;
int index_; int index_;
const IncrementT step_; const IncrementT step_;
}; // class RangeGenerator::Iterator }; // class RangeGenerator::Iterator
static int CalculateEndIndex(const T& begin, static int CalculateEndIndex(const T& begin,
const T& end, const T& end,
const IncrementT& step) { const IncrementT& step) {
int end_index = 0; int end_index = 0;
for (T i = begin; i < end; i = i + step) for (T i = begin; i < end; i = i + step)
end_index++; end_index++;
return end_index; return end_index;
} }
// No implementation - assignment is unsupported.
void operator=(const RangeGenerator& other);
const T begin_; const T begin_;
const T end_; const T end_;
const IncrementT step_; const IncrementT step_;
// The index for the end() iterator. All the elements in the generated // The index for the end() iterator. All the elements in the generated
// sequence are indexed (0-based) to aid iterator comparison. // sequence are indexed (0-based) to aid iterator comparison.
const int end_index_; const int end_index_;
}; // class RangeGenerator }; // class RangeGenerator
// Generates values from a pair of STL-style iterators. Used in the // Generates values from a pair of STL-style iterators. Used in the
// ValuesIn() function. The elements are copied from the source range // ValuesIn() function. The elements are copied from the source range
skipping to change at line 351 skipping to change at line 357
iterator_(other.iterator_) {} iterator_(other.iterator_) {}
const ParamGeneratorInterface<T>* const base_; const ParamGeneratorInterface<T>* const base_;
typename ContainerType::const_iterator iterator_; typename ContainerType::const_iterator iterator_;
// A cached value of *iterator_. We keep it here to allow access by // A cached value of *iterator_. We keep it here to allow access by
// pointer in the wrapping iterator's operator->(). // pointer in the wrapping iterator's operator->().
// value_ needs to be mutable to be accessed in Current(). // value_ needs to be mutable to be accessed in Current().
// Use of scoped_ptr helps manage cached value's lifetime, // Use of scoped_ptr helps manage cached value's lifetime,
// which is bound by the lifespan of the iterator itself. // which is bound by the lifespan of the iterator itself.
mutable scoped_ptr<const T> value_; mutable scoped_ptr<const T> value_;
}; }; // class ValuesInIteratorRangeGenerator::Iterator
// No implementation - assignment is unsupported.
void operator=(const ValuesInIteratorRangeGenerator& other);
const ContainerType container_; const ContainerType container_;
}; // class ValuesInIteratorRangeGenerator }; // class ValuesInIteratorRangeGenerator
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// //
// Stores a parameter value and later creates tests parameterized with that // Stores a parameter value and later creates tests parameterized with that
// value. // value.
template <class TestClass> template <class TestClass>
class ParameterizedTestFactory : public TestFactoryBase { class ParameterizedTestFactory : public TestFactoryBase {
skipping to change at line 485 skipping to change at line 494
const char* test_base_name, const char* test_base_name,
TestMetaFactoryBase<ParamType>* meta_factory) { TestMetaFactoryBase<ParamType>* meta_factory) {
tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name, tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,
test_base_name, test_base_name,
meta_factory))); meta_factory)));
} }
// INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record informatio n // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record informatio n
// about a generator. // about a generator.
int AddTestCaseInstantiation(const char* instantiation_name, int AddTestCaseInstantiation(const char* instantiation_name,
GeneratorCreationFunc* func, GeneratorCreationFunc* func,
const char* file, const char* /* file */,
int line) { int /* line */) {
instantiations_.push_back(::std::make_pair(instantiation_name, func)); instantiations_.push_back(::std::make_pair(instantiation_name, func));
return 0; // Return value used only to run this method in namespace sc ope. return 0; // Return value used only to run this method in namespace sc ope.
} }
// UnitTest class invokes this method to register tests in this test case // UnitTest class invokes this method to register tests in this test case
// test cases right before running tests in RUN_ALL_TESTS macro. // test cases right before running tests in RUN_ALL_TESTS macro.
// This method should not be called more then once on any single // This method should not be called more then once on any single
// instance of a ParameterizedTestCaseInfoBase derived class. // instance of a ParameterizedTestCaseInfoBase derived class.
// UnitTest has a guard to prevent from calling this method more then onc e. // UnitTest has a guard to prevent from calling this method more then onc e.
virtual void RegisterTests() { virtual void RegisterTests() {
for (typename TestInfoContainer::iterator test_it = tests_.begin(); for (typename TestInfoContainer::iterator test_it = tests_.begin();
 End of changes. 4 change blocks. 
3 lines changed or deleted 12 lines changed or added


 gtest-port.h   gtest-port.h 
skipping to change at line 61 skipping to change at line 61
// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread. h> // GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread. h>
// is/isn't available. // is/isn't available.
// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/i sn't // GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/i sn't
// enabled. // enabled.
// GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that // GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that
// 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 - Define it to 1/0 to indicate tr1::tuple
// is/isn't available. // is/isn't available.
// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the
// compiler supports Microsoft's "Structured
// Exception Handling".
// GTEST_USE_OWN_TR1_TUPLE - Define it to 1/0 to indicate whether Google
// Test's own tr1 tuple implementation should
be
// used. Unused when the user sets
// GTEST_HAS_TR1_TUPLE to 0.
// This header defines the following utilities: // This header defines the following utilities:
// //
// Macros indicating the current platform (defined to 1 if compiled on // Macros indicating the current platform (defined to 1 if compiled on
// the given platform; otherwise undefined): // the given platform; otherwise undefined):
// GTEST_OS_CYGWIN - Cygwin // GTEST_OS_CYGWIN - Cygwin
// GTEST_OS_LINUX - Linux // GTEST_OS_LINUX - Linux
// GTEST_OS_MAC - Mac OS X // GTEST_OS_MAC - Mac OS X
// GTEST_OS_SOLARIS - Sun Solaris // GTEST_OS_SOLARIS - Sun Solaris
// GTEST_OS_SYMBIAN - Symbian // GTEST_OS_SYMBIAN - Symbian
// GTEST_OS_WINDOWS - Windows // GTEST_OS_WINDOWS - Windows (Desktop, MinGW, or Mobile)
// GTEST_OS_WINDOWS_DESKTOP - Windows Desktop
// GTEST_OS_WINDOWS_MINGW - MinGW
// GTEST_OS_WINODWS_MOBILE - Windows Mobile
// GTEST_OS_ZOS - z/OS // GTEST_OS_ZOS - 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.
skipping to change at line 99 skipping to change at line 109
// GTEST_HAS_DEATH_TEST - death tests // GTEST_HAS_DEATH_TEST - death tests
// GTEST_HAS_PARAM_TEST - value-parameterized tests // GTEST_HAS_PARAM_TEST - value-parameterized tests
// GTEST_HAS_TYPED_TEST - typed tests // GTEST_HAS_TYPED_TEST - typed tests
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests // GTEST_HAS_TYPED_TEST_P - type-parameterized tests
// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. // GTEST_USES_POSIX_RE - enhanced POSIX regex is used.
// GTEST_USES_SIMPLE_RE - our own simple regex is used; // GTEST_USES_SIMPLE_RE - our own simple regex is used;
// the above two are mutually exclusive. // 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 // GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
to // variable 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()
// - synchronization primitives. // - synchronization primitives.
// GTEST_IS_THREADSAFE - defined to 1 to indicate that the above // GTEST_IS_THREADSAFE - defined to 1 to indicate that the above
// synchronization primitives have real implementat ions // synchronization primitives have real implementat ions
// and Google Test is thread-safe; or 0 otherwise. // and Google Test is thread-safe; or 0 otherwise.
// //
skipping to change at line 150 skipping to change at line 160
// GTEST_DECLARE_*() - declares a flag. // GTEST_DECLARE_*() - declares a flag.
// GTEST_DEFINE_*() - defines a flag. // GTEST_DEFINE_*() - defines a flag.
// GetArgvs() - returns the command line as a vector of strings. // GetArgvs() - returns the command line as a vector of strings.
// //
// 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 <stddef.h> // For ptrdiff_t
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <iostream> // Used for GTEST_CHECK_ #include <string.h>
#ifndef _WIN32_WCE
#include <sys/stat.h>
#endif // !_WIN32_WCE
#include <iostream> // NOLINT
#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com" #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_NAME_ "Google Test"
#define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/" #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 1 #define GTEST_OS_CYGWIN 1
#elif __SYMBIAN32__ #elif defined __SYMBIAN32__
#define GTEST_OS_SYMBIAN 1 #define GTEST_OS_SYMBIAN 1
#elif defined _MSC_VER #elif defined _WIN32
// TODO(kenton@google.com): GTEST_OS_WINDOWS is currently used to mean
// both "The OS is Windows" and "The compiler is MSVC". These
// meanings really should be separated in order to better support
// Windows compilers other than MSVC.
#define GTEST_OS_WINDOWS 1 #define GTEST_OS_WINDOWS 1
#ifdef _WIN32_WCE
#define GTEST_OS_WINDOWS_MOBILE 1
#elif defined(__MINGW__) || defined(__MINGW32__)
#define GTEST_OS_WINDOWS_MINGW 1
#else
#define GTEST_OS_WINDOWS_DESKTOP 1
#endif // _WIN32_WCE
#elif defined __APPLE__ #elif defined __APPLE__
#define GTEST_OS_MAC 1 #define GTEST_OS_MAC 1
#elif defined __linux__ #elif defined __linux__
#define GTEST_OS_LINUX 1 #define GTEST_OS_LINUX 1
#elif defined __MVS__ #elif defined __MVS__
#define GTEST_OS_ZOS 1 #define GTEST_OS_ZOS 1
#elif defined(__sun) && defined(__SVR4) #elif defined(__sun) && defined(__SVR4)
#define GTEST_OS_SOLARIS 1 #define GTEST_OS_SOLARIS 1
#endif // _MSC_VER #endif // __CYGWIN__
#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC #if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_SYMBIAN |
| \
GTEST_OS_SOLARIS
// On some platforms, <regex.h> needs someone to define size_t, and // On some platforms, <regex.h> needs someone to define size_t, and
// won't compile otherwise. We can #include it here as we already // won't compile otherwise. We can #include it here as we already
// included <stdlib.h>, which is guaranteed to define size_t through // included <stdlib.h>, which is guaranteed to define size_t through
// <stddef.h>. // <stddef.h>.
#include <regex.h> // NOLINT #include <regex.h> // NOLINT
#include <strings.h> // NOLINT
#include <sys/types.h> // NOLINT
#include <unistd.h> // NOLINT
#define GTEST_USES_POSIX_RE 1 #define GTEST_USES_POSIX_RE 1
#elif GTEST_OS_WINDOWS
#if !GTEST_OS_WINDOWS_MOBILE
#include <direct.h> // NOLINT
#include <io.h> // NOLINT
#endif
// <regex.h> is not available on Windows. Use our own simple regex
// implementation instead.
#define GTEST_USES_SIMPLE_RE 1
#else #else
// <regex.h> may not be available on this platform. Use our own // <regex.h> may not be available on this platform. Use our own
// simple regex implementation instead. // simple regex implementation instead.
#define GTEST_USES_SIMPLE_RE 1 #define GTEST_USES_SIMPLE_RE 1
#endif // GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC #endif // GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC ||
// GTEST_OS_SYMBIAN || GTEST_OS_SOLARIS
// Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0 // Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0
// otherwise. // otherwise.
#ifdef _MSC_VER // Compiled by MSVC? #if defined(_MSC_VER) || defined(__BORLANDC__)
// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIO
NS
// macro to enable exceptions, so we'll do the same.
// Assumes that exceptions are enabled by default. // Assumes that exceptions are enabled by default.
#ifndef _HAS_EXCEPTIONS // MSVC uses this macro to enable exceptions. #ifndef _HAS_EXCEPTIONS
#define _HAS_EXCEPTIONS 1 #define _HAS_EXCEPTIONS 1
#endif // _HAS_EXCEPTIONS #endif // _HAS_EXCEPTIONS
#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS #define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
#else // The compiler is not MSVC. #else // The compiler is not MSVC or C++Builder.
// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled. For // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled. For
// other compilers, we assume exceptions are disabled to be // other compilers, we assume exceptions are disabled to be
// conservative. // conservative.
#if defined(__GNUC__) && __EXCEPTIONS #if defined(__GNUC__) && __EXCEPTIONS
#define GTEST_HAS_EXCEPTIONS 1 #define GTEST_HAS_EXCEPTIONS 1
#else #else
#define GTEST_HAS_EXCEPTIONS 0 #define GTEST_HAS_EXCEPTIONS 0
#endif // defined(__GNUC__) && __EXCEPTIONS #endif // defined(__GNUC__) && __EXCEPTIONS
#endif // _MSC_VER #endif // defined(_MSC_VER) || defined(__BORLANDC__)
// Determines whether ::std::string and ::string are available. // Determines whether ::std::string and ::string are available.
#ifndef GTEST_HAS_STD_STRING #ifndef GTEST_HAS_STD_STRING
// The user didn't tell us whether ::std::string is available, so we // The user didn't tell us whether ::std::string is available, so we
// need to figure it out. The only environment that we know // need to figure it out. The only environment that we know
// ::std::string is not available is MSVC 7.1 or lower with exceptions // ::std::string is not available is MSVC 7.1 or lower with exceptions
// disabled. // disabled.
#if defined(_MSC_VER) && (_MSC_VER < 1400) && !GTEST_HAS_EXCEPTIONS #if defined(_MSC_VER) && (_MSC_VER < 1400) && !GTEST_HAS_EXCEPTIONS
#define GTEST_HAS_STD_STRING 0 #define GTEST_HAS_STD_STRING 0
skipping to change at line 325 skipping to change at line 363
#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) #define GTEST_HAS_PTHREAD (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 Google Test can use tr1/tuple. You can define
// on your platform, define GTEST_HAS_TR1_TUPLE=1 for both the Google // this macro to 0 to prevent Google Test from using tuple (any
// Test project and your tests. If you would like Google Test to detect // feature depending on tuple with be disabled in this mode).
// tr1/tuple on your platform automatically, please open an issue
// ticket at http://code.google.com/p/googletest.
#ifndef GTEST_HAS_TR1_TUPLE #ifndef GTEST_HAS_TR1_TUPLE
// The user didn't tell us not to do it, so we assume it's OK.
#define GTEST_HAS_TR1_TUPLE 1
#endif // GTEST_HAS_TR1_TUPLE
// Determines whether Google Test's own tr1 tuple implementation
// should be used.
#ifndef GTEST_USE_OWN_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.
// GCC provides <tr1/tuple> since 4.0.0. // We use our own tr1 tuple if we aren't sure the user has an
// implementation of it already. At this time, GCC 4.0.0+ is the only
// mainstream compiler that comes with a TR1 tuple implementation.
// MSVC 2008 (9.0) provides TR1 tuple in a 323 MB Feature Pack
// download, which we cannot assume the user has. MSVC 2010 isn't
// released yet.
#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000) #if defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
#define GTEST_HAS_TR1_TUPLE 1 #define GTEST_USE_OWN_TR1_TUPLE 0
#else #else
#define GTEST_HAS_TR1_TUPLE 0 #define GTEST_USE_OWN_TR1_TUPLE 1
#endif // __GNUC__ #endif // defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
#endif // GTEST_HAS_TR1_TUPLE
#endif // GTEST_USE_OWN_TR1_TUPLE
// To avoid conditional compilation everywhere, we make it // To avoid conditional compilation everywhere, we make it
// gtest-port.h's responsibility to #include the header implementing // gtest-port.h's responsibility to #include the header implementing
// tr1/tuple. // tr1/tuple.
#if GTEST_HAS_TR1_TUPLE #if GTEST_HAS_TR1_TUPLE
#if defined(__GNUC__)
// GCC implements tr1/tuple in the <tr1/tuple> header. This does not #if GTEST_USE_OWN_TR1_TUPLE
// conform to the TR1 spec, which requires the header to be <tuple>. #include <gtest/internal/gtest-tuple.h>
#elif GTEST_OS_SYMBIAN
// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
// use STLport's tuple implementation, which unfortunately doesn't
// work as the copy of STLport distributed with Symbian is incomplete.
// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to
// use its own tuple implementation.
#ifdef BOOST_HAS_TR1_TUPLE
#undef BOOST_HAS_TR1_TUPLE
#endif // BOOST_HAS_TR1_TUPLE
// This prevents <boost/tr1/detail/config.hpp>, which defines
// BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.
#define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
#include <tuple>
#elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
// GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header. This does
// not conform to the TR1 spec, which requires the header to be <tuple>.
#if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
// which is #included by <tr1/tuple>, to not compile when RTTI is
// disabled. _TR1_FUNCTIONAL is the header guard for
// <tr1/functional>. Hence the following #define is a hack to prevent
// <tr1/functional> from being included.
#define _TR1_FUNCTIONAL 1
#include <tr1/tuple> #include <tr1/tuple>
#undef _TR1_FUNCTIONAL // Allows the user to #include
// <tr1/functional> if he chooses to.
#else #else
// If the compiler is not GCC, we assume the user is using a #include <tr1/tuple>
#endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
#else
// If the compiler is not GCC 4.0+, we assume the user is using a
// spec-conforming TR1 implementation. // spec-conforming TR1 implementation.
#include <tuple> #include <tuple>
#endif // __GNUC__ #endif // GTEST_USE_OWN_TR1_TUPLE
#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 GTEST_OS_LINUX && !defined(__ia64__) #if GTEST_OS_LINUX && !defined(__ia64__)
skipping to change at line 379 skipping to change at line 462
#endif // GTEST_HAS_CLONE #endif // GTEST_HAS_CLONE
// Determines whether to support death tests. // Determines whether to support death tests.
// Google Test does not support death tests for VC 7.1 and earlier for // Google Test does not support death tests for VC 7.1 and earlier for
// these reasons: // these reasons:
// 1. std::vector does not build in VC 7.1 when exceptions are disabled. // 1. std::vector does not build in VC 7.1 when exceptions are disabled.
// 2. std::string does not build in VC 7.1 when exceptions are disabled // 2. std::string does not build in VC 7.1 when exceptions are disabled
// (this is covered by GTEST_HAS_STD_STRING guard). // (this is covered by GTEST_HAS_STD_STRING guard).
// 3. abort() in a VC 7.1 application compiled as GUI in debug config // 3. abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically. // pops up a dialog window that cannot be suppressed programmatically.
#if GTEST_HAS_STD_STRING && (GTEST_OS_LINUX || \ #if GTEST_HAS_STD_STRING && \
GTEST_OS_MAC || \ (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
GTEST_OS_CYGWIN || \ (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MIN
(GTEST_OS_WINDOWS && _MSC_VER >= 1400)) GW)
#define GTEST_HAS_DEATH_TEST 1 #define GTEST_HAS_DEATH_TEST 1
#include <vector> #include <vector> // NOLINT
#endif #endif
// 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 1 #define GTEST_HAS_PARAM_TEST 1
#endif // defined(__GNUC__) || (_MSC_VER >= 1400) #endif // defined(__GNUC__) || (_MSC_VER >= 1400)
skipping to change at line 430 skipping to change at line 512
// if (gate) // if (gate)
// ASSERT_*(condition) << "Some message"; // ASSERT_*(condition) << "Some message";
// //
// The "switch (0) case 0:" idiom is used to suppress this. // The "switch (0) case 0:" idiom is used to suppress this.
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ #define GTEST_AMBIGUOUS_ELSE_BLOCKER_
#else #else
#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: // NOLINT #define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: // NOLINT
#endif #endif
// Use this annotation at the end of a struct / class definition to // Use this annotation at the end of a struct/class definition to
// prevent the compiler from optimizing away instances that are never // prevent the compiler from optimizing away instances that are never
// used. This is useful when all interesting logic happens inside the // used. This is useful when all interesting logic happens inside the
// c'tor and / or d'tor. Example: // c'tor and / or d'tor. Example:
// //
// struct Foo { // struct Foo {
// Foo() { ... } // Foo() { ... }
// } GTEST_ATTRIBUTE_UNUSED_; // } GTEST_ATTRIBUTE_UNUSED_;
//
// Also use it after a variable or parameter declaration to tell the
// compiler the variable/parameter does not have to be used.
#if defined(__GNUC__) && !defined(COMPILER_ICC) #if defined(__GNUC__) && !defined(COMPILER_ICC)
#define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) #define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
#else #else
#define GTEST_ATTRIBUTE_UNUSED_ #define GTEST_ATTRIBUTE_UNUSED_
#endif #endif
// A macro to disallow the evil copy constructor and operator= functions // A macro to disallow the evil copy constructor and operator= functions
// This should be used in the private: declarations for a class. // This should be used in the private: declarations for a class.
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
type(const type &);\ type(const type &);\
skipping to change at line 461 skipping to change at line 546
// with this macro. The macro should be used on function declarations // with this macro. The macro should be used on function declarations
// following the argument list: // following the argument list:
// //
// Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_; // Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC ) #if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC )
#define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result)) #define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
#else #else
#define GTEST_MUST_USE_RESULT_ #define GTEST_MUST_USE_RESULT_
#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC #endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
// Determine whether the compiler supports Microsoft's Structured Exception
// Handling. This is supported by several Windows compilers but generally
// does not exist on any other system.
#ifndef GTEST_HAS_SEH
// The user didn't tell us, so we need to figure it out.
#if defined(_MSC_VER) || defined(__BORLANDC__)
// These two compilers are known to support SEH.
#define GTEST_HAS_SEH 1
#else
// Assume no SEH.
#define GTEST_HAS_SEH 0
#endif
#endif // GTEST_HAS_SEH
namespace testing { namespace testing {
class Message; class Message;
namespace internal { namespace internal {
class String; class String;
// std::strstream is deprecated. However, we have to use it on // std::strstream is deprecated. However, we have to use it on
// Windows as std::stringstream won't compile on Windows when // Windows as std::stringstream won't compile on Windows when
// exceptions are disabled. We use std::stringstream on other // exceptions are disabled. We use std::stringstream on other
// platforms to avoid compiler warnings there. // platforms to avoid compiler warnings there.
#if GTEST_HAS_STD_STRING #if GTEST_HAS_STD_STRING
typedef ::std::stringstream StrStream; typedef ::std::stringstream StrStream;
#else #else
typedef ::std::strstream StrStream; typedef ::std::strstream StrStream;
#endif // GTEST_HAS_STD_STRING #endif // GTEST_HAS_STD_STRING
// A helper for suppressing warnings on constant condition. It just
// returns 'condition'.
bool IsTrue(bool condition);
// Defines scoped_ptr. // Defines scoped_ptr.
// This implementation of scoped_ptr is PARTIAL - it only contains // This implementation of scoped_ptr is PARTIAL - it only contains
// enough stuff to satisfy Google Test's need. // enough stuff to satisfy Google Test's need.
template <typename T> template <typename T>
class scoped_ptr { class scoped_ptr {
public: public:
explicit scoped_ptr(T* p = NULL) : ptr_(p) {} explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
~scoped_ptr() { reset(); } ~scoped_ptr() { reset(); }
skipping to change at line 501 skipping to change at line 606
T* get() const { return ptr_; } T* get() const { return ptr_; }
T* release() { T* release() {
T* const ptr = ptr_; T* const ptr = ptr_;
ptr_ = NULL; ptr_ = NULL;
return ptr; return ptr;
} }
void reset(T* p = NULL) { void reset(T* p = NULL) {
if (p != ptr_) { if (p != ptr_) {
if (sizeof(T) > 0) { // Makes sure T is a complete type. if (IsTrue(sizeof(T) > 0)) { // Makes sure T is a complete type.
delete ptr_; delete ptr_;
} }
ptr_ = p; ptr_ = p;
} }
} }
private: private:
T* ptr_; T* ptr_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr); GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
}; };
skipping to change at line 582 skipping to change at line 687
regex_t full_regex_; // For FullMatch(). regex_t full_regex_; // For FullMatch().
regex_t partial_regex_; // For PartialMatch(). regex_t partial_regex_; // For PartialMatch().
#else // GTEST_USES_SIMPLE_RE #else // GTEST_USES_SIMPLE_RE
const char* full_pattern_; // For FullMatch(); const char* full_pattern_; // For FullMatch();
#endif #endif
GTEST_DISALLOW_COPY_AND_ASSIGN_(RE); GTEST_DISALLOW_COPY_AND_ASSIGN_(RE);
}; };
// Defines logging utilities: // Defines logging utilities:
// GTEST_LOG_() - logs messages at the specified severity level. // GTEST_LOG_(severity) - logs messages at the specified severity level.
The
// message itself is streamed into the macro.
// 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,
GTEST_FATAL GTEST_FATAL
}; };
void GTestLog(GTestLogSeverity severity, const char* file, // Formats log entry severity, provides a stream object for streaming the
int line, const char* msg); // log message, and terminates the message with a newline when going out of
// scope.
class GTestLog {
public:
GTestLog(GTestLogSeverity severity, const char* file, int line);
#define GTEST_LOG_(severity, msg)\ // Flushes the buffers and, if severity is GTEST_FATAL, aborts the progra
::testing::internal::GTestLog(\ m.
::testing::internal::GTEST_##severity, __FILE__, __LINE__, \ ~GTestLog();
(::testing::Message() << (msg)).GetString().c_str())
::std::ostream& GetStream() { return ::std::cerr; }
private:
const GTestLogSeverity severity_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
};
#define GTEST_LOG_(severity) \
::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
__FILE__, __LINE__).GetStream()
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.
#if GTEST_HAS_STD_STRING
void CaptureStderr(); void CaptureStderr();
::std::string GetCapturedStderr(); String GetCapturedStderr();
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_DEATH_TEST #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;
// GTEST_HAS_DEATH_TEST implies we have ::std::string. // GTEST_HAS_DEATH_TEST implies we have ::std::string.
const ::std::vector<String>& GetArgvs(); const ::std::vector<String>& GetArgvs();
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
skipping to change at line 661 skipping to change at line 779
ThreadLocal() : value_() {} ThreadLocal() : value_() {}
explicit ThreadLocal(const T& value) : value_(value) {} explicit ThreadLocal(const T& value) : value_(value) {}
T* pointer() { return &value_; } T* pointer() { return &value_; }
const T* pointer() const { return &value_; } const T* pointer() const { return &value_; }
const T& get() const { return value_; } const T& get() const { return value_; }
void set(const T& value) { value_ = value; } void set(const T& value) { value_ = value; }
private: private:
T value_; T value_;
}; };
// There's no portable way to detect the number of threads, so we just // Returns the number of threads running in the process, or 0 to indicate t
// return 0 to indicate that we cannot detect it. hat
inline size_t GetThreadCount() { return 0; } // we cannot detect it.
size_t GetThreadCount();
// The above synchronization primitives have dummy implementations. // The above synchronization primitives have dummy implementations.
// Therefore Google Test is not thread-safe. // Therefore Google Test is not thread-safe.
#define GTEST_IS_THREADSAFE 0 #define GTEST_IS_THREADSAFE 0
#if defined(__SYMBIAN32__) || defined(__IBMCPP__) #if defined(__SYMBIAN32__) || defined(__IBMCPP__)
// Passing non-POD classes through ellipsis (...) crashes the ARM // Passing non-POD classes through ellipsis (...) crashes the ARM
// compiler. The Nokia Symbian and the IBM XL C/C++ compiler try to // compiler. The Nokia Symbian and the IBM XL C/C++ compiler try to
// instantiate a copy constructor for objects passed through ellipsis // instantiate a copy constructor for objects passed through ellipsis
skipping to change at line 704 skipping to change at line 822
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 #if GTEST_OS_WINDOWS
#define GTEST_PATH_SEP_ "\\" #define GTEST_PATH_SEP_ "\\"
// The biggest signed integer type the compiler supports.
typedef __int64 BiggestInt;
#else #else
#define GTEST_PATH_SEP_ "/" #define GTEST_PATH_SEP_ "/"
typedef long long BiggestInt; // NOLINT
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
// Defines BiggestInt as the biggest signed integer type the compiler // The testing::internal::posix namespace holds wrappers for common
// supports. // POSIX functions. These wrappers hide the differences between
// Windows/MSVC and POSIX systems. Since some compilers define these
// standard functions as macros, the wrapper cannot have the same name
// as the wrapped function.
namespace posix {
// Functions with a different name on Windows.
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
typedef __int64 BiggestInt;
typedef struct _stat StatStruct;
#ifdef __BORLANDC__
inline int IsATTY(int fd) { return isatty(fd); }
inline int StrCaseCmp(const char* s1, const char* s2) {
return stricmp(s1, s2);
}
inline char* StrDup(const char* src) { return strdup(src); }
#else // !__BORLANDC__
#if GTEST_OS_WINDOWS_MOBILE
inline int IsATTY(int /* fd */) { return 0; }
#else #else
typedef long long BiggestInt; // NOLINT inline int IsATTY(int fd) { return _isatty(fd); }
#endif // GTEST_OS_WINDOWS_MOBILE
inline int StrCaseCmp(const char* s1, const char* s2) {
return _stricmp(s1, s2);
}
inline char* StrDup(const char* src) { return _strdup(src); }
#endif // __BORLANDC__
#if GTEST_OS_WINDOWS_MOBILE
inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file))
; }
// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
// time and thus not defined there.
#else
inline int FileNo(FILE* file) { return _fileno(file); }
inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf
); }
inline int RmDir(const char* dir) { return _rmdir(dir); }
inline bool IsDir(const StatStruct& st) {
return (_S_IFDIR & st.st_mode) != 0;
}
#endif // GTEST_OS_WINDOWS_MOBILE
#else
typedef struct stat StatStruct;
inline int FileNo(FILE* file) { return fileno(file); }
inline int IsATTY(int fd) { return isatty(fd); }
inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf)
; }
inline int StrCaseCmp(const char* s1, const char* s2) {
return strcasecmp(s1, s2);
}
inline char* StrDup(const char* src) { return strdup(src); }
inline int RmDir(const char* dir) { return rmdir(dir); }
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
// Functions deprecated by MSVC 8.0.
#ifdef _MSC_VER
// Temporarily disable warning 4996 (deprecated function).
#pragma warning(push)
#pragma warning(disable:4996)
#endif
inline const char* StrNCpy(char* dest, const char* src, size_t n) {
return strncpy(dest, src, n);
}
// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
// StrError() aren't needed on Windows CE at this time and thus not
// defined there.
#if !GTEST_OS_WINDOWS_MOBILE
inline int ChDir(const char* dir) { return chdir(dir); }
#endif
inline FILE* FOpen(const char* path, const char* mode) {
return fopen(path, mode);
}
#if !GTEST_OS_WINDOWS_MOBILE
inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
return freopen(path, mode, stream);
}
inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
#endif
inline int FClose(FILE* fp) { return fclose(fp); }
#if !GTEST_OS_WINDOWS_MOBILE
inline int Read(int fd, void* buf, unsigned int count) {
return static_cast<int>(read(fd, buf, count));
}
inline int Write(int fd, const void* buf, unsigned int count) {
return static_cast<int>(write(fd, buf, count));
}
inline int Close(int fd) { return close(fd); }
inline const char* StrError(int errnum) { return strerror(errnum); }
#endif
inline const char* GetEnv(const char* name) {
#if GTEST_OS_WINDOWS_MOBILE
// We are on Windows CE, which has no environment variables.
return NULL;
#elif defined(__BORLANDC__)
// Environment variables which we programmatically clear will be set to t
he
// empty string rather than unset (NULL). Handle that case.
const char* const env = getenv(name);
return (env != NULL && env[0] != '\0') ? env : NULL;
#else
return getenv(name);
#endif
}
#ifdef _MSC_VER
#pragma warning(pop) // Restores the warning state.
#endif
#if GTEST_OS_WINDOWS_MOBILE
// Windows CE has no C library. The abort() function is used in
// several places in Google Test. This implementation provides a reasonable
// imitation of standard behaviour.
void Abort();
#else
inline void Abort() { abort(); }
#endif // GTEST_OS_WINDOWS_MOBILE
} // namespace posix
// 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
// are not part of standard C++ and numeric_limits doesn't need to be // are not part of standard C++ and numeric_limits doesn't need to be
// defined for them. // defined for them.
const BiggestInt kMaxBiggestInt = const BiggestInt kMaxBiggestInt =
~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1)); ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
skipping to change at line 786 skipping to change at line 1028
// Integer types of known sizes. // Integer types of known sizes.
typedef TypeWithSize<4>::Int Int32; typedef TypeWithSize<4>::Int Int32;
typedef TypeWithSize<4>::UInt UInt32; typedef TypeWithSize<4>::UInt UInt32;
typedef TypeWithSize<8>::Int Int64; typedef TypeWithSize<8>::Int Int64;
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.
inline const char* GetEnv(const char* name) {
#ifdef _WIN32_WCE // We are on Windows CE.
// CE has no environment variables.
return NULL;
#elif GTEST_OS_WINDOWS // We are on Windows proper.
// MSVC 8 deprecates getenv(), so we want to suppress warning 4996
// (deprecated function) there.
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996.
return getenv(name);
#pragma warning(pop) // Restores the warning state.
#else // We are on Linux or Mac OS.
return getenv(name);
#endif
}
#ifdef _WIN32_WCE
// Windows CE has no C library. The abort() function is used in
// several places in Google Test. This implementation provides a reasonable
// imitation of standard behaviour.
void abort();
#else
inline void abort() { ::abort(); }
#endif // _WIN32_WCE
// INTERNAL IMPLEMENTATION - DO NOT USE. // INTERNAL IMPLEMENTATION - DO NOT USE.
// //
// GTEST_CHECK_ is an all-mode assert. It aborts the program if the conditi on // GTEST_CHECK_ is an all-mode assert. It aborts the program if the conditi on
// is not satisfied. // is not satisfied.
// Synopsys: // Synopsys:
// GTEST_CHECK_(boolean_condition); // GTEST_CHECK_(boolean_condition);
// or // or
// GTEST_CHECK_(boolean_condition) << "Additional message"; // GTEST_CHECK_(boolean_condition) << "Additional message";
// //
// This checks the condition and if the condition is not satisfied // This checks the condition and if the condition is not satisfied
// it prints message about the condition violation, including the // it prints message about the condition violation, including the
// condition itself, plus additional message streamed into it, if any, // condition itself, plus additional message streamed into it, if any,
// and then it aborts the program. It aborts the program irrespective of // and then it aborts the program. It aborts the program irrespective of
// whether it is built in the debug mode or not. // whether it is built in the debug mode or not.
class GTestCheckProvider {
public:
GTestCheckProvider(const char* condition, const char* file, int line) {
FormatFileLocation(file, line);
::std::cerr << " ERROR: Condition " << condition << " failed. ";
}
~GTestCheckProvider() {
::std::cerr << ::std::endl;
abort();
}
void FormatFileLocation(const char* file, int line) {
if (file == NULL)
file = "unknown file";
if (line < 0) {
::std::cerr << file << ":";
} else {
#if _MSC_VER
::std::cerr << file << "(" << line << "):";
#else
::std::cerr << file << ":" << line << ":";
#endif
}
}
::std::ostream& GetStream() { return ::std::cerr; }
};
#define GTEST_CHECK_(condition) \ #define GTEST_CHECK_(condition) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (condition) \ if (::testing::internal::IsTrue(condition)) \
; \ ; \
else \ else \
::testing::internal::GTestCheckProvider(\ GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
#condition, __FILE__, __LINE__).GetStream()
// Macro for referencing flags. // Macro for referencing flags.
#define GTEST_FLAG(name) FLAGS_gtest_##name #define GTEST_FLAG(name) FLAGS_gtest_##name
// Macros for declaring flags. // Macros for declaring flags.
#define GTEST_DECLARE_bool_(name) extern bool GTEST_FLAG(name) #define GTEST_DECLARE_bool_(name) extern bool GTEST_FLAG(name)
#define GTEST_DECLARE_int32_(name) \ #define GTEST_DECLARE_int32_(name) \
extern ::testing::internal::Int32 GTEST_FLAG(name) extern ::testing::internal::Int32 GTEST_FLAG(name)
#define GTEST_DECLARE_string_(name) \ #define GTEST_DECLARE_string_(name) \
extern ::testing::internal::String GTEST_FLAG(name) extern ::testing::internal::String GTEST_FLAG(name)
 End of changes. 50 change blocks. 
112 lines changed or deleted 312 lines changed or added


 gtest-spi.h   gtest-spi.h 
skipping to change at line 100 skipping to change at line 100
// A helper class for implementing EXPECT_FATAL_FAILURE() and // A helper class for implementing EXPECT_FATAL_FAILURE() and
// EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given // EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given
// TestPartResultArray contains exactly one failure that has the given // TestPartResultArray contains exactly one failure that has the given
// type and contains the given substring. If that's not the case, a // type and contains the given substring. If that's not the case, a
// non-fatal failure will be generated. // non-fatal failure will be generated.
class SingleFailureChecker { class SingleFailureChecker {
public: public:
// The constructor remembers the arguments. // The constructor remembers the arguments.
SingleFailureChecker(const TestPartResultArray* results, SingleFailureChecker(const TestPartResultArray* results,
TestPartResultType type, TestPartResult::Type type,
const char* substr); const char* substr);
~SingleFailureChecker(); ~SingleFailureChecker();
private: private:
const TestPartResultArray* const results_; const TestPartResultArray* const results_;
const TestPartResultType type_; const TestPartResult::Type type_;
const String substr_; const String substr_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker); GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
}; };
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
// A set of macros for testing Google Test assertions or code that's expect ed // A set of macros for testing Google Test assertions or code that's expect ed
skipping to change at line 146 skipping to change at line 146
// works. The AcceptsMacroThatExpandsToUnprotectedComma test in // works. The AcceptsMacroThatExpandsToUnprotectedComma test in
// gtest_unittest.cc will fail to compile if we do that. // gtest_unittest.cc will fail to compile if we do that.
#define EXPECT_FATAL_FAILURE(statement, substr) \ #define EXPECT_FATAL_FAILURE(statement, substr) \
do { \ do { \
class GTestExpectFatalFailureHelper {\ class GTestExpectFatalFailureHelper {\
public:\ public:\
static void Execute() { statement; }\ static void Execute() { statement; }\
};\ };\
::testing::TestPartResultArray gtest_failures;\ ::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\ ::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\ &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr) );\
{\ {\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \ ::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\ INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\ GTestExpectFatalFailureHelper::Execute();\
}\ }\
} while (false) } while (::testing::internal::AlwaysFalse())
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ #define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
do { \ do { \
class GTestExpectFatalFailureHelper {\ class GTestExpectFatalFailureHelper {\
public:\ public:\
static void Execute() { statement; }\ static void Execute() { statement; }\
};\ };\
::testing::TestPartResultArray gtest_failures;\ ::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\ ::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TPRT_FATAL_FAILURE, (substr));\ &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr) );\
{\ {\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \ ::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ALL_THREADS, &gtest_failures);\ INTERCEPT_ALL_THREADS, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\ GTestExpectFatalFailureHelper::Execute();\
}\ }\
} while (false) } while (::testing::internal::AlwaysFalse())
// A macro for testing Google Test assertions or code that's expected to // A macro for testing Google Test assertions or code that's expected to
// generate Google Test non-fatal failures. It asserts that the given // generate Google Test non-fatal failures. It asserts that the given
// statement will cause exactly one non-fatal Google Test failure with 'sub str' // statement will cause exactly one non-fatal Google Test failure with 'sub str'
// being part of the failure message. // being part of the failure message.
// //
// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only // There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
// affects and considers failures generated in the current thread and // affects and considers failures generated in the current thread and
// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads . // EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads .
// //
skipping to change at line 193 skipping to change at line 193
// //
// The verification of the assertion is done correctly even when the statem ent // The verification of the assertion is done correctly even when the statem ent
// throws an exception or aborts the current function. // throws an exception or aborts the current function.
// //
// Known restrictions: // Known restrictions:
// - You cannot stream a failure message to this macro. // - You cannot stream a failure message to this macro.
// //
// Note that even though the implementations of the following two // Note that even though the implementations of the following two
// macros are much alike, we cannot refactor them to use a common // macros are much alike, we cannot refactor them to use a common
// helper macro, due to some peculiarity in how the preprocessor // helper macro, due to some peculiarity in how the preprocessor
// works. The AcceptsMacroThatExpandsToUnprotectedComma test in // works. If we do that, the code won't compile when the user gives
// gtest_unittest.cc will fail to compile if we do that. // EXPECT_NONFATAL_FAILURE() a statement that contains a macro that
// expands to code containing an unprotected comma. The
// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc
// catches that.
//
// For the same reason, we have to write
// if (::testing::internal::AlwaysTrue()) { statement; }
// instead of
// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
// to avoid an MSVC warning on unreachable code.
#define EXPECT_NONFATAL_FAILURE(statement, substr) \ #define EXPECT_NONFATAL_FAILURE(statement, substr) \
do {\ do {\
::testing::TestPartResultArray gtest_failures;\ ::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\ ::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\ &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
(substr));\
{\ {\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \ ::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\ INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
statement;\ if (::testing::internal::AlwaysTrue()) { statement; }\
}\ }\
} while (false) } while (::testing::internal::AlwaysFalse())
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ #define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
do {\ do {\
::testing::TestPartResultArray gtest_failures;\ ::testing::TestPartResultArray gtest_failures;\
::testing::internal::SingleFailureChecker gtest_checker(\ ::testing::internal::SingleFailureChecker gtest_checker(\
&gtest_failures, ::testing::TPRT_NONFATAL_FAILURE, (substr));\ &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
(substr));\
{\ {\
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREAD S,\ ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREAD S,\
&gtest_failures);\ &gtest_failures);\
statement;\ if (::testing::internal::AlwaysTrue()) { statement; }\
}\ }\
} while (false) } while (::testing::internal::AlwaysFalse())
#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_ #endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_
 End of changes. 13 change blocks. 
14 lines changed or deleted 25 lines changed or added


 gtest-string.h   gtest-string.h 
skipping to change at line 83 skipping to change at line 83
// std::string on platforms where it cannot be used, we define a copy // std::string on platforms where it cannot be used, we define a copy
// constructor and assignment operators such that we don't need // constructor and assignment operators such that we don't need
// conditional compilation in a lot of places. // conditional compilation in a lot of places.
// //
// In order to make the representation efficient, the d'tor of String // In order to make the representation efficient, the d'tor of String
// is not virtual. Therefore DO NOT INHERIT FROM String. // is not virtual. Therefore DO NOT INHERIT FROM String.
class String { class String {
public: public:
// Static utility methods // Static utility methods
// Returns the input if it's not NULL, otherwise returns "(null)".
// This function serves two purposes:
//
// 1. ShowCString(NULL) has type 'const char *', instead of the
// type of NULL (which is int).
//
// 2. In MSVC, streaming a null char pointer to StrStream generates
// an access violation, so we need to convert NULL to "(null)"
// before streaming it.
static inline const char* ShowCString(const char* c_str) {
return c_str ? c_str : "(null)";
}
// Returns the input enclosed in double quotes if it's not NULL; // Returns the input enclosed in double quotes if it's not NULL;
// otherwise returns "(null)". For example, "\"Hello\"" is returned // otherwise returns "(null)". For example, "\"Hello\"" is returned
// for input "Hello". // for input "Hello".
// //
// This is useful for printing a C string in the syntax of a literal. // This is useful for printing a C string in the syntax of a literal.
// //
// Known issue: escape sequences are not handled yet. // Known issue: escape sequences are not handled yet.
static String ShowCStringQuoted(const char* c_str); static String ShowCStringQuoted(const char* c_str);
// Clones a 0-terminated C string, allocating memory using new. The // Clones a 0-terminated C string, allocating memory using new. The
// caller is responsible for deleting the return value using // caller is responsible for deleting the return value using
// delete[]. Returns the cloned string, or NULL if the input is // delete[]. Returns the cloned string, or NULL if the input is
// NULL. // NULL.
// //
// This is different from strdup() in string.h, which allocates // This is different from strdup() in string.h, which allocates
// memory using malloc(). // memory using malloc().
static const char* CloneCString(const char* c_str); static const char* CloneCString(const char* c_str);
#ifdef _WIN32_WCE #if GTEST_OS_WINDOWS_MOBILE
// Windows CE does not have the 'ANSI' versions of Win32 APIs. To be // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
// able to pass strings to Win32 APIs on CE we need to convert them // able to pass strings to Win32 APIs on CE we need to convert them
// to 'Unicode', UTF-16. // to 'Unicode', UTF-16.
// Creates a UTF-16 wide string from the given ANSI string, allocating // Creates a UTF-16 wide string from the given ANSI string, allocating
// memory using new. The caller is responsible for deleting the return // memory using new. The caller is responsible for deleting the return
// value using delete[]. Returns the wide string, or NULL if the // value using delete[]. Returns the wide string, or NULL if the
// input is NULL. // input is NULL.
// //
// The wide string is created using the ANSI codepage (CP_ACP) to // The wide string is created using the ANSI codepage (CP_ACP) to
skipping to change at line 203 skipping to change at line 190
// available. // available.
// //
// The result is limited to 4096 characters (including the tailing // The result is limited to 4096 characters (including the tailing
// 0). If 4096 characters are not enough to format the input, // 0). If 4096 characters are not enough to format the input,
// "<buffer exceeded>" is returned. // "<buffer exceeded>" is returned.
static String Format(const char* format, ...); static String Format(const char* format, ...);
// C'tors // C'tors
// The default c'tor constructs a NULL string. // The default c'tor constructs a NULL string.
String() : c_str_(NULL) {} String() : c_str_(NULL), length_(0) {}
// Constructs a String by cloning a 0-terminated C string. // Constructs a String by cloning a 0-terminated C string.
String(const char* c_str) : c_str_(NULL) { // NOLINT String(const char* c_str) { // NOLINT
*this = c_str; if (c_str == NULL) {
c_str_ = NULL;
length_ = 0;
} else {
ConstructNonNull(c_str, strlen(c_str));
}
} }
// Constructs a String by copying a given number of chars from a // Constructs a String by copying a given number of chars from a
// buffer. E.g. String("hello", 3) will create the string "hel". // buffer. E.g. String("hello", 3) creates the string "hel",
String(const char* buffer, size_t len); // String("a\0bcd", 4) creates "a\0bc", String(NULL, 0) creates "",
// and String(NULL, 1) results in access violation.
String(const char* buffer, size_t length) {
ConstructNonNull(buffer, length);
}
// The copy c'tor creates a new copy of the string. The two // The copy c'tor creates a new copy of the string. The two
// String objects do not share content. // String objects do not share content.
String(const String& str) : c_str_(NULL) { String(const String& str) : c_str_(NULL), length_(0) { *this = str; }
*this = str;
}
// D'tor. String is intended to be a final class, so the d'tor // D'tor. String is intended to be a final class, so the d'tor
// doesn't need to be virtual. // doesn't need to be virtual.
~String() { delete[] c_str_; } ~String() { delete[] c_str_; }
// Allows a String to be implicitly converted to an ::std::string or // Allows a String to be implicitly converted to an ::std::string or
// ::string, and vice versa. Converting a String containing a NULL // ::string, and vice versa. Converting a String containing a NULL
// pointer to ::std::string or ::string is undefined behavior. // pointer to ::std::string or ::string is undefined behavior.
// Converting a ::std::string or ::string containing an embedded NUL // Converting a ::std::string or ::string containing an embedded NUL
// character to a String will result in the prefix up to the first // character to a String will result in the prefix up to the first
// NUL character. // NUL character.
#if GTEST_HAS_STD_STRING #if GTEST_HAS_STD_STRING
String(const ::std::string& str) : c_str_(NULL) { *this = str.c_str(); } String(const ::std::string& str) {
ConstructNonNull(str.c_str(), str.length());
}
operator ::std::string() const { return ::std::string(c_str_); } operator ::std::string() const { return ::std::string(c_str(), length()); }
#endif // GTEST_HAS_STD_STRING #endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING #if GTEST_HAS_GLOBAL_STRING
String(const ::string& str) : c_str_(NULL) { *this = str.c_str(); } String(const ::string& str) {
ConstructNonNull(str.c_str(), str.length());
}
operator ::string() const { return ::string(c_str_); } operator ::string() const { return ::string(c_str(), length()); }
#endif // GTEST_HAS_GLOBAL_STRING #endif // GTEST_HAS_GLOBAL_STRING
// Returns true iff this is an empty string (i.e. ""). // Returns true iff this is an empty string (i.e. "").
bool empty() const { bool empty() const { return (c_str() != NULL) && (length() == 0); }
return (c_str_ != NULL) && (*c_str_ == '\0');
}
// Compares this with another String. // Compares this with another String.
// Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0 // Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0
// if this is greater than rhs. // if this is greater than rhs.
int Compare(const String& rhs) const; int Compare(const String& rhs) const;
// Returns true iff this String equals the given C string. A NULL // Returns true iff this String equals the given C string. A NULL
// string and a non-NULL string are considered not equal. // string and a non-NULL string are considered not equal.
bool operator==(const char* c_str) const { bool operator==(const char* c_str) const { return Compare(c_str) == 0; }
return CStringEquals(c_str_, c_str);
}
// Returns true iff this String is less than the given C string. A NULL // Returns true iff this String is less than the given String. A
// string is considered less than "". // NULL string is considered less than "".
bool operator<(const String& rhs) const { return Compare(rhs) < 0; } bool operator<(const String& rhs) const { return Compare(rhs) < 0; }
// Returns true iff this String doesn't equal the given C string. A NULL // Returns true iff this String doesn't equal the given C string. A NULL
// string and a non-NULL string are considered not equal. // string and a non-NULL string are considered not equal.
bool operator!=(const char* c_str) const { bool operator!=(const char* c_str) const { return !(*this == c_str); }
return !CStringEquals(c_str_, c_str);
}
// Returns true iff this String ends with the given suffix. *Any* // Returns true iff this String ends with the given suffix. *Any*
// String is considered to end with a NULL or empty suffix. // String is considered to end with a NULL or empty suffix.
bool EndsWith(const char* suffix) const; bool EndsWith(const char* suffix) const;
// Returns true iff this String ends with the given suffix, not consideri ng // Returns true iff this String ends with the given suffix, not consideri ng
// case. Any String is considered to end with a NULL or empty suffix. // case. Any String is considered to end with a NULL or empty suffix.
bool EndsWithCaseInsensitive(const char* suffix) const; bool EndsWithCaseInsensitive(const char* suffix) const;
// Returns the length of the encapsulated string, or -1 if the // Returns the length of the encapsulated string, or 0 if the
// string is NULL. // string is NULL.
int GetLength() const { size_t length() const { return length_; }
return c_str_ ? static_cast<int>(strlen(c_str_)) : -1;
}
// Gets the 0-terminated C string this String object represents. // Gets the 0-terminated C string this String object represents.
// The String object still owns the string. Therefore the caller // The String object still owns the string. Therefore the caller
// should NOT delete the return value. // should NOT delete the return value.
const char* c_str() const { return c_str_; } const char* c_str() const { return c_str_; }
// Sets the 0-terminated C string this String object represents.
// The old string in this object is deleted, and this object will
// own a clone of the input string. This function copies only up to
// length bytes (plus a terminating null byte), or until the first
// null byte, whichever comes first.
//
// This function works even when the c_str parameter has the same
// value as that of the c_str_ field.
void Set(const char* c_str, size_t length);
// Assigns a C string to this object. Self-assignment works. // Assigns a C string to this object. Self-assignment works.
const String& operator=(const char* c_str); const String& operator=(const char* c_str) { return *this = String(c_str) ; }
// Assigns a String object to this object. Self-assignment works. // Assigns a String object to this object. Self-assignment works.
const String& operator=(const String &rhs) { const String& operator=(const String& rhs) {
*this = rhs.c_str_; if (this != &rhs) {
delete[] c_str_;
if (rhs.c_str() == NULL) {
c_str_ = NULL;
length_ = 0;
} else {
ConstructNonNull(rhs.c_str(), rhs.length());
}
}
return *this; return *this;
} }
private: private:
// Constructs a non-NULL String from the given content. This
// function can only be called when data_ has not been allocated.
// ConstructNonNull(NULL, 0) results in an empty string ("").
// ConstructNonNull(NULL, non_zero) is undefined behavior.
void ConstructNonNull(const char* buffer, size_t length) {
char* const str = new char[length + 1];
memcpy(str, buffer, length);
str[length] = '\0';
c_str_ = str;
length_ = length;
}
const char* c_str_; const char* c_str_;
}; size_t length_;
}; // class String
// Streams a String to an ostream. // Streams a String to an ostream. Each '\0' character in the String
inline ::std::ostream& operator <<(::std::ostream& os, const String& str) { // is replaced with "\\0".
// We call String::ShowCString() to convert NULL to "(null)". inline ::std::ostream& operator<<(::std::ostream& os, const String& str) {
// Otherwise we'll get an access violation on Windows. if (str.c_str() == NULL) {
return os << String::ShowCString(str.c_str()); os << "(null)";
} else {
const char* const c_str = str.c_str();
for (size_t i = 0; i != str.length(); i++) {
if (c_str[i] == '\0') {
os << "\\0";
} else {
os << c_str[i];
}
}
}
return os;
} }
// Gets the content of the StrStream's buffer as a String. Each '\0' // Gets the content of the StrStream's buffer as a String. Each '\0'
// character in the buffer is replaced with "\\0". // character in the buffer is replaced with "\\0".
String StrStreamToString(StrStream* stream); String StrStreamToString(StrStream* stream);
// 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".
 End of changes. 22 change blocks. 
60 lines changed or deleted 73 lines changed or added


 gtest-test-part.h   gtest-test-part.h 
skipping to change at line 42 skipping to change at line 42
#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ #ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ #define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
#include <iosfwd> #include <iosfwd>
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
namespace testing { namespace testing {
// The possible outcomes of a test part (i.e. an assertion or an
// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
enum TestPartResultType {
TPRT_SUCCESS, // Succeeded.
TPRT_NONFATAL_FAILURE, // Failed but the test can continue.
TPRT_FATAL_FAILURE // Failed and the test should be terminated.
};
// A copyable object representing the result of a test part (i.e. an // A copyable object representing the result of a test part (i.e. an
// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()). // assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
// //
// Don't inherit from TestPartResult as its destructor is not virtual. // Don't inherit from TestPartResult as its destructor is not virtual.
class TestPartResult { class TestPartResult {
public: public:
// The possible outcomes of a test part (i.e. an assertion or an
// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
enum Type {
kSuccess, // Succeeded.
kNonFatalFailure, // Failed but the test can continue.
kFatalFailure // Failed and the test should be terminated.
};
// C'tor. TestPartResult does NOT have a default constructor. // C'tor. TestPartResult does NOT have a default constructor.
// Always use this constructor (with parameters) to create a // Always use this constructor (with parameters) to create a
// TestPartResult object. // TestPartResult object.
TestPartResult(TestPartResultType type, TestPartResult(Type type,
const char* file_name, const char* file_name,
int line_number, int line_number,
const char* message) const char* message)
: type_(type), : type_(type),
file_name_(file_name), file_name_(file_name),
line_number_(line_number), line_number_(line_number),
summary_(ExtractSummary(message)), summary_(ExtractSummary(message)),
message_(message) { message_(message) {
} }
// Gets the outcome of the test part. // Gets the outcome of the test part.
TestPartResultType type() const { return type_; } Type type() const { return type_; }
// Gets the name of the source file where the test part took place, or // Gets the name of the source file where the test part took place, or
// NULL if it's unknown. // NULL if it's unknown.
const char* file_name() const { return file_name_.c_str(); } const char* file_name() const { return file_name_.c_str(); }
// Gets the line in the source file where the test part took place, // Gets the line in the source file where the test part took place,
// or -1 if it's unknown. // or -1 if it's unknown.
int line_number() const { return line_number_; } int line_number() const { return line_number_; }
// Gets the summary of the failure message. // Gets the summary of the failure message.
const char* summary() const { return summary_.c_str(); } const char* summary() const { return summary_.c_str(); }
// Gets the message associated with the test part. // Gets the message associated with the test part.
const char* message() const { return message_.c_str(); } const char* message() const { return message_.c_str(); }
// Returns true iff the test part passed. // Returns true iff the test part passed.
bool passed() const { return type_ == TPRT_SUCCESS; } bool passed() const { return type_ == kSuccess; }
// Returns true iff the test part failed. // Returns true iff the test part failed.
bool failed() const { return type_ != TPRT_SUCCESS; } bool failed() const { return type_ != kSuccess; }
// Returns true iff the test part non-fatally failed. // Returns true iff the test part non-fatally failed.
bool nonfatally_failed() const { return type_ == TPRT_NONFATAL_FAILURE; } bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
// Returns true iff the test part fatally failed. // Returns true iff the test part fatally failed.
bool fatally_failed() const { return type_ == TPRT_FATAL_FAILURE; } bool fatally_failed() const { return type_ == kFatalFailure; }
private: private:
TestPartResultType type_; Type type_;
// Gets the summary of the failure message by omitting the stack // Gets the summary of the failure message by omitting the stack
// trace in it. // trace in it.
static internal::String ExtractSummary(const char* message); static internal::String ExtractSummary(const char* message);
// The name of the source file where the test part took place, or // The name of the source file where the test part took place, or
// NULL if the source file is unknown. // NULL if the source file is unknown.
internal::String file_name_; internal::String file_name_;
// The line in the source file where the test part took place, or -1 // The line in the source file where the test part took place, or -1
// if the line number is unknown. // if the line number is unknown.
skipping to change at line 139 skipping to change at line 139
// Appends the given TestPartResult to the array. // Appends the given TestPartResult to the array.
void Append(const TestPartResult& result); void Append(const TestPartResult& result);
// Returns the TestPartResult at the given index (0-based). // Returns the TestPartResult at the given index (0-based).
const TestPartResult& GetTestPartResult(int index) const; const TestPartResult& GetTestPartResult(int index) const;
// Returns the number of TestPartResult objects in the array. // Returns the number of TestPartResult objects in the array.
int size() const; int size() const;
private: private:
// Internally we use a list to simulate the array. Yes, this means // Internally we use a Vector to implement the array.
// that random access is O(N) in time, but it's OK for its purpose. internal::Vector<TestPartResult>* const array_;
internal::List<TestPartResult>* const list_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray); GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
}; };
// This interface knows how to report a test part result. // This interface knows how to report a test part result.
class TestPartResultReporterInterface { class TestPartResultReporterInterface {
public: public:
virtual ~TestPartResultReporterInterface() {} virtual ~TestPartResultReporterInterface() {}
virtual void ReportTestPartResult(const TestPartResult& result) = 0; virtual void ReportTestPartResult(const TestPartResult& result) = 0;
 End of changes. 10 change blocks. 
18 lines changed or deleted 17 lines changed or added


 gtest-type-util.h   gtest-type-util.h 
skipping to change at line 50 skipping to change at line 50
// more. // more.
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
#include <gtest/internal/gtest-port.h> #include <gtest/internal/gtest-port.h>
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
#ifdef __GNUC__ // #ifdef __GNUC__ is too general here. It is possible to use gcc without
using
// libstdc++ (which is where cxxabi.h comes from).
#ifdef __GLIBCXX__
#include <cxxabi.h> #include <cxxabi.h>
#endif // __GNUC__ #endif // __GLIBCXX__
#include <typeinfo> #include <typeinfo>
namespace testing { namespace testing {
namespace internal { namespace internal {
// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same // AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
// type. This can be used as a compile-time assertion to ensure that // type. This can be used as a compile-time assertion to ensure that
// two types are equal. // two types are equal.
skipping to change at line 77 skipping to change at line 79
struct AssertTypeEq<T, T> { struct AssertTypeEq<T, T> {
typedef bool type; typedef bool type;
}; };
// GetTypeName<T>() returns a human-readable name of type T. // GetTypeName<T>() returns a human-readable name of type T.
template <typename T> template <typename T>
String GetTypeName() { String GetTypeName() {
#if GTEST_HAS_RTTI #if GTEST_HAS_RTTI
const char* const name = typeid(T).name(); const char* const name = typeid(T).name();
#ifdef __GNUC__ #ifdef __GLIBCXX__
int status = 0; int status = 0;
// gcc's implementation of typeid(T).name() mangles the type name, // gcc's implementation of typeid(T).name() mangles the type name,
// so we have to demangle it. // so we have to demangle it.
char* const readable_name = abi::__cxa_demangle(name, 0, 0, &status); char* const readable_name = abi::__cxa_demangle(name, 0, 0, &status);
const String name_str(status == 0 ? readable_name : name); const String name_str(status == 0 ? readable_name : name);
free(readable_name); free(readable_name);
return name_str; return name_str;
#else #else
return name; return name;
#endif // __GNUC__ #endif // __GLIBCXX__
#else #else
return "<type>"; return "<type>";
#endif // GTEST_HAS_RTTI #endif // GTEST_HAS_RTTI
} }
// A unique type used as the default value for the arguments of class // A unique type used as the default value for the arguments of class
// template Types. This allows us to simulate variadic templates // template Types. This allows us to simulate variadic templates
// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't // (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
// support directly. // support directly.
 End of changes. 4 change blocks. 
4 lines changed or deleted 7 lines changed or added


 gtest.h   gtest.h 
skipping to change at line 54 skipping to change at line 54
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
// program! // program!
// //
// Acknowledgment: Google Test borrowed the idea of automatic test // Acknowledgment: Google Test borrowed the idea of automatic test
// registration from Barthelemy Dagenais' (barthelemy@prologique.com) // registration from Barthelemy Dagenais' (barthelemy@prologique.com)
// easyUnit framework. // easyUnit framework.
#ifndef GTEST_INCLUDE_GTEST_GTEST_H_ #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
#define GTEST_INCLUDE_GTEST_GTEST_H_ #define GTEST_INCLUDE_GTEST_GTEST_H_
// The following platform macros are used throughout Google Test:
// _WIN32_WCE Windows CE (set in project files)
//
// Note that even though _MSC_VER and _WIN32_WCE really indicate a compiler
// and a Win32 implementation, respectively, we use them to indicate the
// combination of compiler - Win 32 API - C library, since the code current
ly
// only supports:
// Windows proper with Visual C++ and MS C library (_MSC_VER && !_WIN32_WCE
) and
// Windows Mobile with Visual C++ and no C library (_WIN32_WCE).
#include <limits> #include <limits>
#include <gtest/internal/gtest-internal.h> #include <gtest/internal/gtest-internal.h>
#include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-string.h>
#include <gtest/gtest-death-test.h> #include <gtest/gtest-death-test.h>
#include <gtest/gtest-message.h> #include <gtest/gtest-message.h>
#include <gtest/gtest-param-test.h> #include <gtest/gtest-param-test.h>
#include <gtest/gtest_prod.h> #include <gtest/gtest_prod.h>
#include <gtest/gtest-test-part.h> #include <gtest/gtest-test-part.h>
#include <gtest/gtest-typed-test.h> #include <gtest/gtest-typed-test.h>
skipping to change at line 129 skipping to change at line 119
GTEST_DECLARE_bool_(list_tests); GTEST_DECLARE_bool_(list_tests);
// This flag controls whether Google Test emits a detailed XML report to a file // This flag controls whether Google Test emits a detailed XML report to a file
// in addition to its normal textual output. // in addition to its normal textual output.
GTEST_DECLARE_string_(output); GTEST_DECLARE_string_(output);
// This flags control whether Google Test prints the elapsed time for each // This flags control whether Google Test prints the elapsed time for each
// test. // test.
GTEST_DECLARE_bool_(print_time); GTEST_DECLARE_bool_(print_time);
// This flag specifies the random number seed.
GTEST_DECLARE_int32_(random_seed);
// This flag sets how many times the tests are repeated. The default value // 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. // is 1. If the value is -1 the tests are repeating forever.
GTEST_DECLARE_int32_(repeat); 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);
// When this flag is specified, tests' order is randomized on every iterati
on.
GTEST_DECLARE_bool_(shuffle);
// This flag specifies the maximum number of stack frames to be // This flag specifies the maximum number of stack frames to be
// printed in a failure message. // printed in a failure message.
GTEST_DECLARE_int32_(stack_trace_depth); GTEST_DECLARE_int32_(stack_trace_depth);
// When this flag is specified, a failed assertion will throw an // When this flag is specified, a failed assertion will throw an
// exception if exceptions are enabled, or exit the program with a // exception if exceptions are enabled, or exit the program with a
// non-zero code otherwise. // non-zero code otherwise.
GTEST_DECLARE_bool_(throw_on_failure); GTEST_DECLARE_bool_(throw_on_failure);
// The upper limit for valid stack trace depths. // The upper limit for valid stack trace depths.
const int kMaxStackTraceDepth = 100; const int kMaxStackTraceDepth = 100;
namespace internal { namespace internal {
class AssertHelper;
class DefaultGlobalTestPartResultReporter;
class ExecDeathTest;
class NoExecDeathTest;
class FinalSuccessChecker;
class GTestFlagSaver; class GTestFlagSaver;
class TestInfoImpl;
class TestResultAccessor;
class TestEventListenersAccessor;
class TestEventRepeater;
class WindowsDeathTest;
class UnitTestImpl* GetUnitTestImpl();
void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
const String& message);
class PrettyUnitTestResultPrinter;
class XmlUnitTestResultPrinter;
// 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
// compiler. // compiler.
template <typename T> template <typename T>
String StreamableToString(const T& streamable) { String StreamableToString(const T& streamable) {
skipping to change at line 282 skipping to change at line 293
// //
// Google Test will call Foo::TearDownTestCase() after running the last // Google Test will call Foo::TearDownTestCase() after running the last
// test in test case Foo. Hence a sub-class can define its own // test in test case Foo. Hence a sub-class can define its own
// TearDownTestCase() method to shadow the one defined in the super // TearDownTestCase() method to shadow the one defined in the super
// class. // class.
static void TearDownTestCase() {} static void TearDownTestCase() {}
// Returns true iff the current test has a fatal failure. // Returns true iff the current test has a fatal failure.
static bool HasFatalFailure(); static bool HasFatalFailure();
// Returns true iff the current test has a non-fatal failure.
static bool HasNonfatalFailure();
// Returns true iff the current test has a (either fatal or
// non-fatal) failure.
static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure
(); }
// Logs a property for the current test. Only the last value for a given // Logs a property for the current test. Only the last value for a given
// key is remembered. // key is remembered.
// These are public static so they can be called from utility functions // These are public static so they can be called from utility functions
// that are not members of the test fixture. // that are not members of the test fixture.
// The arguments are const char* instead strings, as Google Test is used // The arguments are const char* instead strings, as Google Test is used
// on platforms where string doesn't compile. // on platforms where string doesn't compile.
// //
// Note that a driving consideration for these RecordProperty methods // Note that a driving consideration for these RecordProperty methods
// was to produce xml output suited to the Greenspan charting utility, // was to produce xml output suited to the Greenspan charting utility,
// which at present will only chart values that fit in a 32-bit int. It // which at present will only chart values that fit in a 32-bit int. It
skipping to change at line 349 skipping to change at line 367
// //
// If you see an error about overriding the following function or // If you see an error about overriding the following function or
// about it being private, you have mis-spelled SetUp() as Setup(). // about it being private, you have mis-spelled SetUp() as Setup().
struct Setup_should_be_spelled_SetUp {}; struct Setup_should_be_spelled_SetUp {};
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; } virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
// We disallow copying Tests. // We disallow copying Tests.
GTEST_DISALLOW_COPY_AND_ASSIGN_(Test); GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
}; };
typedef internal::TimeInMillis TimeInMillis;
// A copyable object representing a user specified test property which can
be
// output as a key/value string pair.
//
// Don't inherit from TestProperty as its destructor is not virtual.
class TestProperty {
public:
// C'tor. TestProperty does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestProperty object.
TestProperty(const char* key, const char* value) :
key_(key), value_(value) {
}
// Gets the user supplied key.
const char* key() const {
return key_.c_str();
}
// Gets the user supplied value.
const char* value() const {
return value_.c_str();
}
// Sets a new value, overriding the one supplied in the constructor.
void SetValue(const char* new_value) {
value_ = new_value;
}
private:
// The key supplied by the user.
internal::String key_;
// The value supplied by the user.
internal::String value_;
};
// The result of a single Test. This includes a list of
// TestPartResults, a list of TestProperties, a count of how many
// death tests there are in the Test, and how much time it took to run
// the Test.
//
// TestResult is not copyable.
class TestResult {
public:
// Creates an empty TestResult.
TestResult();
// D'tor. Do not inherit from TestResult.
~TestResult();
// Gets the number of all test parts. This is the sum of the number
// of successful test parts and the number of failed test parts.
int total_part_count() const;
// Returns the number of the test properties.
int test_property_count() const;
// Returns true iff the test passed (i.e. no test part failed).
bool Passed() const { return !Failed(); }
// Returns true iff the test failed.
bool Failed() const;
// Returns true iff the test fatally failed.
bool HasFatalFailure() const;
// Returns true iff the test has a non-fatal failure.
bool HasNonfatalFailure() const;
// Returns the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const { return elapsed_time_; }
// Returns the i-th test part result among all the results. i can range
// from 0 to test_property_count() - 1. If i is not in that range, aborts
// the program.
const TestPartResult& GetTestPartResult(int i) const;
// Returns the i-th test property. i can range from 0 to
// test_property_count() - 1. If i is not in that range, aborts the
// program.
const TestProperty& GetTestProperty(int i) const;
private:
friend class TestInfo;
friend class UnitTest;
friend class internal::DefaultGlobalTestPartResultReporter;
friend class internal::ExecDeathTest;
friend class internal::TestInfoImpl;
friend class internal::TestResultAccessor;
friend class internal::UnitTestImpl;
friend class internal::WindowsDeathTest;
// Gets the vector of TestPartResults.
const internal::Vector<TestPartResult>& test_part_results() const {
return *test_part_results_;
}
// Gets the vector of TestProperties.
const internal::Vector<TestProperty>& test_properties() const {
return *test_properties_;
}
// Sets the elapsed time.
void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
// Adds a test property to the list. The property is validated and may ad
d
// a non-fatal failure if invalid (e.g., if it conflicts with reserved
// key names). If a property is already recorded for the same key, the
// value will be updated, rather than storing multiple values for the sam
e
// key.
void RecordProperty(const TestProperty& test_property);
// Adds a failure if the key is a reserved attribute of Google Test
// testcase tags. Returns true if the property is valid.
// TODO(russr): Validate attribute names are legal and human readable.
static bool ValidateTestProperty(const TestProperty& test_property);
// Adds a test part result to the list.
void AddTestPartResult(const TestPartResult& test_part_result);
// Returns the death test count.
int death_test_count() const { return death_test_count_; }
// Increments the death test count, returning the new count.
int increment_death_test_count() { return ++death_test_count_; }
// Clears the test part results.
void ClearTestPartResults();
// Clears the object.
void Clear();
// Protects mutable state of the property vector and of owned
// properties, whose values may be updated.
internal::Mutex test_properites_mutex_;
// The vector of TestPartResults
internal::scoped_ptr<internal::Vector<TestPartResult> > test_part_results
_;
// The vector of TestProperties
internal::scoped_ptr<internal::Vector<TestProperty> > test_properties_;
// Running count of death tests.
int death_test_count_;
// The elapsed time, in milliseconds.
TimeInMillis elapsed_time_;
// We disallow copying TestResult.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
}; // class TestResult
// A TestInfo object stores the following information about a test: // A TestInfo object stores the following information about a test:
// //
// Test case name // Test case name
// Test name // Test name
// Whether the test should be run // Whether the test should be run
// A function pointer that creates the test object when invoked // A function pointer that creates the test object when invoked
// Test result // Test result
// //
// The constructor of TestInfo registers itself with the UnitTest // The constructor of TestInfo registers itself with the UnitTest
// singleton such that the RUN_ALL_TESTS() macro knows which tests to // singleton such that the RUN_ALL_TESTS() macro knows which tests to
skipping to change at line 378 skipping to change at line 546
// Returns the test name. // Returns the test name.
const char* name() const; const char* name() const;
// Returns the test case comment. // Returns the test case comment.
const char* test_case_comment() const; const char* test_case_comment() const;
// Returns the test comment. // Returns the test comment.
const char* comment() const; const char* comment() const;
// Returns true if this test should run. // Returns true if this test should run, that is if the test is not disab
led
// (or it is disabled but the also_run_disabled_tests flag has been speci
fied)
// and its full name matches the user-specified filter.
// //
// Google Test allows the user to filter the tests by their full names. // Google Test allows the user to filter the tests by their full names.
// The full name of a test Bar in test case Foo is defined as // The full name of a test Bar in test case Foo is defined as
// "Foo.Bar". Only the tests that match the filter will run. // "Foo.Bar". Only the tests that match the filter will run.
// //
// A filter is a colon-separated list of glob (not regex) patterns, // A filter is a colon-separated list of glob (not regex) patterns,
// optionally followed by a '-' and a colon-separated list of // optionally followed by a '-' and a colon-separated list of
// negative patterns (tests to exclude). A test is run if it // negative patterns (tests to exclude). A test is run if it
// 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 TestResult* result() const;
private: private:
#if 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::UnitTestImpl;
friend class Test; friend class Test;
friend class TestCase; friend class TestCase;
friend class internal::TestInfoImpl;
friend class internal::UnitTestImpl;
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,
Test::SetUpTestCaseFunc set_up_tc, Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc, Test::TearDownTestCaseFunc tear_down_tc,
internal::TestFactoryBase* factory); internal::TestFactoryBase* factory);
// Returns true if this test matches the user-specified filter.
bool matches_filter() const;
// Increments the number of death tests encountered in this test so // Increments the number of death tests encountered in this test so
// far. // far.
int increment_death_test_count(); int increment_death_test_count();
// Accessors for the implementation object. // Accessors for the implementation object.
internal::TestInfoImpl* impl() { return impl_; } internal::TestInfoImpl* impl() { return impl_; }
const internal::TestInfoImpl* impl() const { return impl_; } const internal::TestInfoImpl* impl() const { return impl_; }
// Constructs a TestInfo object. The newly constructed instance assumes // Constructs a TestInfo object. The newly constructed instance assumes
// ownership of the factory object. // ownership of the factory object.
skipping to change at line 433 skipping to change at line 607
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,
internal::TestFactoryBase* factory); internal::TestFactoryBase* factory);
// An opaque implementation object. // An opaque implementation object.
internal::TestInfoImpl* impl_; internal::TestInfoImpl* impl_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo); GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
}; };
// A test case, which consists of a vector of TestInfos.
//
// TestCase is not copyable.
class TestCase {
public:
// Creates a TestCase with the given name.
//
// TestCase does NOT have a default constructor. Always use this
// constructor to create a TestCase object.
//
// Arguments:
//
// name: name of the test case
// set_up_tc: pointer to the function that sets up the test case
// tear_down_tc: pointer to the function that tears down the test case
TestCase(const char* name, const char* comment,
Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc);
// Destructor of TestCase.
virtual ~TestCase();
// Gets the name of the TestCase.
const char* name() const { return name_.c_str(); }
// Returns the test case comment.
const char* comment() const { return comment_.c_str(); }
// Returns true if any test in this test case should run.
bool should_run() const { return should_run_; }
// Gets the number of successful tests in this test case.
int successful_test_count() const;
// Gets the number of failed tests in this test case.
int failed_test_count() const;
// Gets the number of disabled tests in this test case.
int disabled_test_count() const;
// Get the number of tests in this test case that should run.
int test_to_run_count() const;
// Gets the number of all tests in this test case.
int total_test_count() const;
// Returns true iff the test case passed.
bool Passed() const { return !Failed(); }
// Returns true iff the test case failed.
bool Failed() const { return failed_test_count() > 0; }
// Returns the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const { return elapsed_time_; }
// Returns the i-th test among all the tests. i can range from 0 to
// total_test_count() - 1. If i is not in that range, returns NULL.
const TestInfo* GetTestInfo(int i) const;
private:
friend class Test;
friend class internal::UnitTestImpl;
// Gets the (mutable) vector of TestInfos in this TestCase.
internal::Vector<TestInfo*>& test_info_list() { return *test_info_list_;
}
// Gets the (immutable) vector of TestInfos in this TestCase.
const internal::Vector<TestInfo *> & test_info_list() const {
return *test_info_list_;
}
// Returns the i-th test among all the tests. i can range from 0 to
// total_test_count() - 1. If i is not in that range, returns NULL.
TestInfo* GetMutableTestInfo(int i);
// Sets the should_run member.
void set_should_run(bool should) { should_run_ = should; }
// Adds a TestInfo to this test case. Will delete the TestInfo upon
// destruction of the TestCase object.
void AddTestInfo(TestInfo * test_info);
// Clears the results of all tests in this test case.
void ClearResult();
// Clears the results of all tests in the given test case.
static void ClearTestCaseResult(TestCase* test_case) {
test_case->ClearResult();
}
// Runs every test in this TestCase.
void Run();
// Returns true iff test passed.
static bool TestPassed(const TestInfo * test_info);
// Returns true iff test failed.
static bool TestFailed(const TestInfo * test_info);
// Returns true iff test is disabled.
static bool TestDisabled(const TestInfo * test_info);
// Returns true if the given test should run.
static bool ShouldRunTest(const TestInfo *test_info);
// Shuffles the tests in this test case.
void ShuffleTests(internal::Random* random);
// Restores the test order to before the first shuffle.
void UnshuffleTests();
// Name of the test case.
internal::String name_;
// Comment on the test case.
internal::String comment_;
// The vector of TestInfos in their original order. It owns the
// elements in the vector.
const internal::scoped_ptr<internal::Vector<TestInfo*> > test_info_list_;
// Provides a level of indirection for the test list to allow easy
// shuffling and restoring the test order. The i-th element in this
// vector is the index of the i-th test in the shuffled test list.
const internal::scoped_ptr<internal::Vector<int> > test_indices_;
// Pointer to the function that sets up the test case.
Test::SetUpTestCaseFunc set_up_tc_;
// Pointer to the function that tears down the test case.
Test::TearDownTestCaseFunc tear_down_tc_;
// True iff any test in this test case should run.
bool should_run_;
// Elapsed time, in milliseconds.
TimeInMillis elapsed_time_;
// We disallow copying TestCases.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);
};
// An Environment object is capable of setting up and tearing down an // An Environment object is capable of setting up and tearing down an
// environment. The user should subclass this to define his own // environment. The user should subclass this to define his own
// environment(s). // environment(s).
// //
// An Environment object does the set-up and tear-down in virtual // An Environment object does the set-up and tear-down in virtual
// methods SetUp() and TearDown() instead of the constructor and the // methods SetUp() and TearDown() instead of the constructor and the
// destructor, as: // destructor, as:
// //
// 1. You cannot safely throw from a destructor. This is a problem // 1. You cannot safely throw from a destructor. This is a problem
// as in some cases Google Test is used where exceptions are enabled, and // as in some cases Google Test is used where exceptions are enabled, and
skipping to change at line 464 skipping to change at line 773
// Override this to define how to tear down the environment. // Override this to define how to tear down the environment.
virtual void TearDown() {} virtual void TearDown() {}
private: private:
// If you see an error about overriding the following function or // If you see an error about overriding the following function or
// about it being private, you have mis-spelled SetUp() as Setup(). // about it being private, you have mis-spelled SetUp() as Setup().
struct Setup_should_be_spelled_SetUp {}; struct Setup_should_be_spelled_SetUp {};
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; } virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
}; };
// A UnitTest consists of a list of TestCases. // The interface for tracing execution of tests. The methods are organized
in
// the order the corresponding events are fired.
class TestEventListener {
public:
virtual ~TestEventListener() {}
// Fired before any test activity starts.
virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
// Fired before each iteration of tests starts. There may be more than
// one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
// index, starting from 0.
virtual void OnTestIterationStart(const UnitTest& unit_test,
int iteration) = 0;
// Fired before environment set-up for each iteration of tests starts.
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
// Fired after environment set-up for each iteration of tests ends.
virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
// Fired before the test case starts.
virtual void OnTestCaseStart(const TestCase& test_case) = 0;
// Fired before the test starts.
virtual void OnTestStart(const TestInfo& test_info) = 0;
// Fired after a failed assertion or a SUCCESS().
virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0
;
// Fired after the test ends.
virtual void OnTestEnd(const TestInfo& test_info) = 0;
// Fired after the test case ends.
virtual void OnTestCaseEnd(const TestCase& test_case) = 0;
// Fired before environment tear-down for each iteration of tests starts.
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
// Fired after environment tear-down for each iteration of tests ends.
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
// Fired after each iteration of tests finishes.
virtual void OnTestIterationEnd(const UnitTest& unit_test,
int iteration) = 0;
// Fired after all test activities have ended.
virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
};
// The convenience class for users who need to override just one or two
// methods and are not concerned that a possible change to a signature of
// the methods they override will not be caught during the build. For
// comments about each method please see the definition of TestEventListene
r
// above.
class EmptyTestEventListener : public TestEventListener {
public:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
int /*iteration*/) {}
virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
virtual void OnTestStart(const TestInfo& /*test_info*/) {}
virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/)
{}
virtual void OnTestEnd(const TestInfo& /*test_info*/) {}
virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {
}
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int /*iteration*/) {}
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
};
// TestEventListeners lets users add listeners to track events in Google Te
st.
class TestEventListeners {
public:
TestEventListeners();
~TestEventListeners();
// Appends an event listener to the end of the list. Google Test assumes
// the ownership of the listener (i.e. it will delete the listener when
// the test program finishes).
void Append(TestEventListener* listener);
// Removes the given event listener from the list and returns it. It the
n
// becomes the caller's responsibility to delete the listener. Returns
// NULL if the listener is not found in the list.
TestEventListener* Release(TestEventListener* listener);
// Returns the standard listener responsible for the default console
// output. Can be removed from the listeners list to shut down default
// console output. Note that removing this object from the listener list
// with Release transfers its ownership to the caller and makes this
// function return NULL the next time.
TestEventListener* default_result_printer() const {
return default_result_printer_;
}
// Returns the standard listener responsible for the default XML output
// controlled by the --gtest_output=xml flag. Can be removed from the
// listeners list by users who want to shut down the default XML output
// controlled by this flag and substitute it with custom one. Note that
// removing this object from the listener list with Release transfers its
// ownership to the caller and makes this function return NULL the next
// time.
TestEventListener* default_xml_generator() const {
return default_xml_generator_;
}
private:
friend class TestCase;
friend class internal::DefaultGlobalTestPartResultReporter;
friend class internal::NoExecDeathTest;
friend class internal::TestEventListenersAccessor;
friend class internal::TestInfoImpl;
friend class internal::UnitTestImpl;
// Returns repeater that broadcasts the TestEventListener events to all
// subscribers.
TestEventListener* repeater();
// Sets the default_result_printer attribute to the provided listener.
// The listener is also added to the listener list and previous
// default_result_printer is removed from it and deleted. The listener ca
n
// also be NULL in which case it will not be added to the list. Does
// nothing if the previous and the current listener objects are the same.
void SetDefaultResultPrinter(TestEventListener* listener);
// Sets the default_xml_generator attribute to the provided listener. Th
e
// listener is also added to the listener list and previous
// default_xml_generator is removed from it and deleted. The listener can
// also be NULL in which case it will not be added to the list. Does
// nothing if the previous and the current listener objects are the same.
void SetDefaultXmlGenerator(TestEventListener* listener);
// Controls whether events will be forwarded by the repeater to the
// listeners in the list.
bool EventForwardingEnabled() const;
void SuppressEventForwarding();
// The actual list of listeners.
internal::TestEventRepeater* repeater_;
// Listener responsible for the standard result output.
TestEventListener* default_result_printer_;
// Listener responsible for the creation of the XML output file.
TestEventListener* default_xml_generator_;
// We disallow copying TestEventListeners.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
};
// A UnitTest consists of a vector of TestCases.
// //
// This is a singleton class. The only instance of UnitTest is // This is a singleton class. The only instance of UnitTest is
// created when UnitTest::GetInstance() is first called. This // created when UnitTest::GetInstance() is first called. This
// instance is never deleted. // instance is never deleted.
// //
// UnitTest is not copyable. // UnitTest is not copyable.
// //
// This class is thread-safe as long as the methods are called // This class is thread-safe as long as the methods are called
// according to their specification. // according to their specification.
class UnitTest { class UnitTest {
public: public:
// Gets the singleton UnitTest object. The first time this method // Gets the singleton UnitTest object. The first time this method
// is called, a UnitTest object is constructed and returned. // is called, a UnitTest object is constructed and returned.
// Consecutive calls will return the same object. // Consecutive calls will return the same object.
static UnitTest* GetInstance(); static UnitTest* GetInstance();
// Registers and returns a global test environment. When a test
// program is run, all global test environments will be set-up in
// the order they were registered. After all tests in the program
// have finished, all global test environments will be torn-down in
// the *reverse* order they were registered.
//
// The UnitTest object takes ownership of the given environment.
//
// This method can only be called from the main thread.
Environment* AddEnvironment(Environment* env);
// Adds a TestPartResult to the current TestResult object. All
// Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
// eventually call this to report their results. The user code
// should use the assertion macros instead of calling this directly.
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
void AddTestPartResult(TestPartResultType result_type,
const char* file_name,
int line_number,
const internal::String& message,
const internal::String& os_stack_trace);
// Adds a TestProperty to the current TestResult object. If the result al
ready
// contains a property with the same key, the value will be updated.
void RecordPropertyForCurrentTest(const char* key, const char* value);
// Runs all tests in this UnitTest object and prints the result. // Runs all tests in this UnitTest object and prints the result.
// Returns 0 if successful, or 1 otherwise. // Returns 0 if successful, or 1 otherwise.
// //
// This method can only be called from the main thread. // This method can only be called from the main thread.
// //
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
int Run() GTEST_MUST_USE_RESULT_; int Run() GTEST_MUST_USE_RESULT_;
// Returns the working directory when the first TEST() or TEST_F() // Returns the working directory when the first TEST() or TEST_F()
// was executed. The UnitTest object owns the string. // was executed. The UnitTest object owns the string.
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;
// Returns the random seed used at the start of the current test run.
int random_seed() const;
#if 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 IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
internal::ParameterizedTestCaseRegistry& parameterized_test_registry(); internal::ParameterizedTestCaseRegistry& parameterized_test_registry();
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
// Gets the number of successful test cases.
int successful_test_case_count() const;
// Gets the number of failed test cases.
int failed_test_case_count() const;
// Gets the number of all test cases.
int total_test_case_count() const;
// Gets the number of all test cases that contain at least one test
// that should run.
int test_case_to_run_count() const;
// Gets the number of successful tests.
int successful_test_count() const;
// Gets the number of failed tests.
int failed_test_count() const;
// Gets the number of disabled tests.
int disabled_test_count() const;
// Gets the number of all tests.
int total_test_count() const;
// Gets the number of tests that should run.
int test_to_run_count() const;
// Gets the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const;
// Returns true iff the unit test passed (i.e. all test cases passed).
bool Passed() const;
// Returns true iff the unit test failed (i.e. some test case failed
// or something outside of all tests failed).
bool Failed() const;
// Gets the i-th test case among all the test cases. i can range from 0 t
o
// total_test_case_count() - 1. If i is not in that range, returns NULL.
const TestCase* GetTestCase(int i) const;
// Returns the list of event listeners that can be used to track events
// inside Google Test.
TestEventListeners& listeners();
private:
// Registers and returns a global test environment. When a test
// program is run, all global test environments will be set-up in
// the order they were registered. After all tests in the program
// have finished, all global test environments will be torn-down in
// the *reverse* order they were registered.
//
// The UnitTest object takes ownership of the given environment.
//
// This method can only be called from the main thread.
Environment* AddEnvironment(Environment* env);
// Adds a TestPartResult to the current TestResult object. All
// Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
// eventually call this to report their results. The user code
// should use the assertion macros instead of calling this directly.
void AddTestPartResult(TestPartResult::Type result_type,
const char* file_name,
int line_number,
const internal::String& message,
const internal::String& os_stack_trace);
// Adds a TestProperty to the current TestResult object. If the result al
ready
// contains a property with the same key, the value will be updated.
void RecordPropertyForCurrentTest(const char* key, const char* value);
// Gets the i-th test case among all the test cases. i can range from 0 t
o
// total_test_case_count() - 1. If i is not in that range, returns NULL.
TestCase* GetMutableTestCase(int i);
// 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:
// ScopedTrace is a friend as it needs to modify the per-thread // These classes and funcions are friends as they need to access private
// trace stack, which is a private member of UnitTest. // members of UnitTest.
friend class Test;
friend class internal::AssertHelper;
friend class internal::ScopedTrace; friend class internal::ScopedTrace;
friend Environment* AddGlobalTestEnvironment(Environment* env);
friend internal::UnitTestImpl* internal::GetUnitTestImpl();
friend void internal::ReportFailureInUnknownLocation(
TestPartResult::Type result_type,
const internal::String& message);
// Creates an empty UnitTest. // Creates an empty UnitTest.
UnitTest(); UnitTest();
// D'tor // D'tor
virtual ~UnitTest(); virtual ~UnitTest();
// Pushes a trace defined by SCOPED_TRACE() on to the per-thread // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
// Google Test trace stack. // Google Test trace stack.
void PushGTestTrace(const internal::TraceInfo& trace); void PushGTestTrace(const internal::TraceInfo& trace);
skipping to change at line 930 skipping to change at line 1452
const char* abs_error_expr, const char* abs_error_expr,
double val1, double val1,
double val2, double val2,
double abs_error); double abs_error);
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// A class that enables one to stream messages to assertion macros // A class that enables one to stream messages to assertion macros
class AssertHelper { class AssertHelper {
public: public:
// Constructor. // Constructor.
AssertHelper(TestPartResultType type, const char* file, int line, AssertHelper(TestPartResult::Type type,
const char* file,
int line,
const char* message); const char* message);
~AssertHelper();
// Message assignment is a semantic trick to enable assertion // Message assignment is a semantic trick to enable assertion
// streaming; see the GTEST_MESSAGE_ macro below. // streaming; see the GTEST_MESSAGE_ macro below.
void operator=(const Message& message) const; void operator=(const Message& message) const;
private: private:
TestPartResultType const type_; // We put our data in a struct so that the size of the AssertHelper class
const char* const file_; can
int const line_; // be as small as possible. This is important because gcc is incapable o
String const message_; f
// re-using stack space even for temporary variables, so every EXPECT_EQ
// reserves stack space for another AssertHelper.
struct AssertHelperData {
AssertHelperData(TestPartResult::Type t,
const char* srcfile,
int line_num,
const char* msg)
: type(t), file(srcfile), line(line_num), message(msg) { }
TestPartResult::Type const type;
const char* const file;
int const line;
String const message;
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
};
AssertHelperData* const data_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper); GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
}; };
} // namespace internal } // namespace internal
#if 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
 End of changes. 24 change blocks. 
53 lines changed or deleted 617 lines changed or added

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