36 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
37 #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
49 #if GTEST_HAS_STD_TYPE_TRAITS_ // Defined by gtest-port.h via gmock-port.h.
50 #include <type_traits>
66 template <
typename F1,
typename F2>
74 template <
typename T,
bool kDefaultConstructible>
81 Assert(
false, __FILE__, __LINE__,
82 "Default action undefined for the function return type.");
83 return internal::Invalid<T>();
99 #if GTEST_HAS_STD_TYPE_TRAITS_
110 #else // GTEST_HAS_STD_TYPE_TRAITS_
120 #endif // GTEST_HAS_STD_TYPE_TRAITS_
125 template <
typename T>
134 template <
typename T>
138 static T*
Get() {
return NULL; }
143 #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
145 class BuiltInDefaultValue<type> { \
147 static bool Exists() { return true; } \
148 static type Get() { return value; } \
152 #if GTEST_HAS_GLOBAL_STRING
154 #endif // GTEST_HAS_GLOBAL_STRING
167 #if GMOCK_WCHAR_T_IS_NATIVE_
182 #undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
199 template <
typename T>
274 template <
typename T>
288 static bool IsSet() {
return address_ != NULL; }
300 return address_ == NULL ?
318 template <
typename T>
319 typename DefaultValue<T>::ValueProducer* DefaultValue<T>::producer_ = NULL;
322 template <
typename T>
326 template <
typename F>
329 typedef typename internal::Function<F>::Result
Result;
354 template <
typename F>
357 typedef typename internal::Function<F>::Result
Result;
375 template <
typename Func>
390 "You are using DoDefault() inside a composite action like "
391 "DoAll() or WithArgs(). This is not supported for technical "
392 "reasons. Please instead spell out the default action, or "
393 "assign the default action to an Action variable and use "
394 "the variable in various places.");
395 return impl_->Perform(args);
399 template <
typename F1,
typename F2>
426 template <
typename Impl>
431 template <
typename F>
437 template <
typename F>
440 typedef typename internal::Function<F>::Result
Result;
446 return impl_.template Perform<Result>(
args);
462 template <
typename F>
474 template <
typename Impl>
483 template <
typename F1,
typename F2>
486 typedef typename internal::Function<F1>::Result
Result;
503 template <
typename T>
533 template <
typename R>
543 template <
typename F>
556 use_ReturnRef_instead_of_Return_to_return_a_reference);
562 template <
typename R_,
typename F>
583 Result_cannot_be_a_reference_type);
594 template <
typename R_,
typename F>
601 : performed_(
false), wrapper_(wrapper) {}
605 <<
"A ByMove() action should only be performed once.";
628 template <
typename Result,
typename ArgumentTuple>
634 ReturnNull_can_be_used_to_return_a_pointer_only);
636 #endif // GTEST_LANG_CXX11
644 template <
typename Result,
typename ArgumentTuple>
653 template <
typename T>
661 template <
typename F>
668 use_Return_instead_of_ReturnRef_to_return_a_value);
674 template <
typename F>
700 template <
typename T>
709 template <
typename F>
717 use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);
723 template <
typename F>
751 template <
typename F>
757 template <
typename T1,
typename T2>
762 template <
typename Result,
typename ArgumentTuple>
774 #if !GTEST_OS_WINDOWS_MOBILE
778 template <
typename T>
784 template <
typename Result,
typename ArgumentTuple>
797 #endif // !GTEST_OS_WINDOWS_MOBILE
803 template <
size_t N,
typename A,
bool kIsProto>
810 template <
typename Result,
typename ArgumentTuple>
822 template <
size_t N,
typename Proto>
830 proto_->CopyFrom(proto);
833 template <
typename Result,
typename ArgumentTuple>
836 ::testing::get<N>(
args)->CopyFrom(*proto_);
850 template <
typename FunctionImpl>
860 template <
typename Result,
typename ArgumentTuple>
870 template <
class Class,
typename MethodPtr>
876 template <
typename Result,
typename ArgumentTuple>
889 template <
typename A>
894 template <
typename F>
904 typedef typename internal::Function<F>::Result Result;
913 template <
typename F>
916 typedef typename internal::Function<F>::Result
Result;
929 typedef typename internal::Function<F>::MakeResultIgnoredValue
949 template <
typename T>
963 template <
typename T>
971 template <
typename Action1,
typename Action2>
979 template <
typename F>
986 template <
typename F>
1052 template <
typename To>
1053 template <
typename From>
1060 template <
typename R>
1076 template <
typename R>
1084 template <
typename R>
1093 template <
typename R>
1105 template <
size_t N,
typename T>
1107 internal::SetArgumentPointeeAction<
1114 #if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
1120 internal::SetArgumentPointeeAction<N, const char*, false> >
1123 N,
const char*,
false>(p));
1128 internal::SetArgumentPointeeAction<N, const wchar_t*, false> >
1131 N,
const wchar_t*,
false>(p));
1136 template <
size_t N,
typename T>
1138 internal::SetArgumentPointeeAction<
1146 template <
typename T1,
typename T2>
1151 #if !GTEST_OS_WINDOWS_MOBILE
1154 template <
typename T>
1155 PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
1161 #endif // !GTEST_OS_WINDOWS_MOBILE
1166 template <
typename FunctionImpl>
1167 PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
1175 template <
class Class,
typename MethodPtr>
1176 PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >
1180 obj_ptr, method_ptr));
1186 template <
typename A>
1198 template <
typename T>
1205 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_