36 #pragma warning(disable : 4577)
39 #include "gmock/gmock-more-actions.h"
46 #include "gmock/gmock.h"
47 #include "gtest/gtest-spi.h"
48 #include "gtest/gtest.h"
51 namespace gmock_more_actions_test {
68 inline short Short(
short n) {
return n; }
69 inline char Char(
char ch) {
return ch; }
76 bool Unary(
int x) {
return x < 0; }
89 int Ternary(
int x,
char y,
short z) {
return x +
y +
z; }
91 int SumOf4(
int a,
int b,
int c,
int d) {
return a +
b +
c +
d; }
95 int SumOf5(
int a,
int b,
int c,
int d,
int e) {
return a +
b +
c +
d +
e; }
97 struct SumOf5Functor {
99 return a +
b + c + d + e;
103 int SumOf6(
int a,
int b,
int c,
int d,
int e,
int f) {
104 return a +
b + c + d + e + f;
107 struct SumOf6Functor {
109 return a +
b + c + d + e + f;
114 const char* s4,
const char* s5,
const char* s6,
116 return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7;
120 const char* s4,
const char* s5,
const char* s6,
121 const char* s7,
const char*
s8) {
126 const char* s4,
const char* s5,
const char* s6,
127 const char* s7,
const char*
s8,
const char* s9) {
128 return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7 +
s8 + s9;
132 const char* s4,
const char* s5,
const char* s6,
133 const char* s7,
const char*
s8,
const char* s9,
135 return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7 +
s8 + s9 + s10;
150 int SumOf4(
int a,
int b,
int c,
int d)
const {
156 int SumOf5(
int a,
int b,
int c,
int d,
int e) {
return a +
b + c + d + e; }
158 int SumOf6(
int a,
int b,
int c,
int d,
int e,
int f) {
159 return a +
b + c + d + e + f;
163 const char* s4,
const char* s5,
const char* s6,
165 return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7;
169 const char* s4,
const char* s5,
const char* s6,
170 const char* s7,
const char*
s8) {
175 const char* s4,
const char* s5,
const char* s6,
176 const char* s7,
const char*
s8,
const char* s9) {
177 return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7 +
s8 + s9;
181 const char* s4,
const char* s5,
const char* s6,
182 const char* s7,
const char*
s8,
const char* s9,
184 return std::string(s1) + s2 + s3 + s4 + s5 + s6 + s7 +
s8 + s9 + s10;
206 Action<
const char*(
const char*, short)> a =
Invoke(
Binary);
207 const char*
p =
"Hello";
218 TEST(InvokeTest, FunctionThatTakes4Arguments) {
224 TEST(InvokeTest, FunctionThatTakes5Arguments) {
230 TEST(InvokeTest, FunctionThatTakes6Arguments) {
238 inline const char*
CharPtr(
const char* s) {
return s; }
241 TEST(InvokeTest, FunctionThatTakes7Arguments) {
242 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
243 const char*,
const char*,
const char*)>
252 TEST(InvokeTest, FunctionThatTakes8Arguments) {
253 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
254 const char*,
const char*,
const char*,
const char*)>
263 TEST(InvokeTest, FunctionThatTakes9Arguments) {
264 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
265 const char*,
const char*,
const char*,
const char*,
275 TEST(InvokeTest, FunctionThatTakes10Arguments) {
276 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
277 const char*,
const char*,
const char*,
const char*,
278 const char*,
const char*)>
288 TEST(InvokeTest, FunctionWithUnusedParameters) {
290 std::tuple<int, int, double, std::string>
dummy =
294 Action<
int(
int,
int,
bool,
int*)>
a2 =
301 TEST(InvokeTest, MethodWithUnusedParameters) {
306 Action<
int(
char,
double,
int,
int)>
a2 =
312 TEST(InvokeTest, Functor) {
318 TEST(InvokeTest, FunctionWithCompatibleType) {
356 TEST(InvokeMethodTest, MethodThatTakes4Arguments) {
363 TEST(InvokeMethodTest, MethodThatTakes5Arguments) {
370 TEST(InvokeMethodTest, MethodThatTakes6Arguments) {
372 Action<
int(
int,
int,
int,
int,
int,
int)>
a =
379 TEST(InvokeMethodTest, MethodThatTakes7Arguments) {
381 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
382 const char*,
const char*,
const char*)>
391 TEST(InvokeMethodTest, MethodThatTakes8Arguments) {
393 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
394 const char*,
const char*,
const char*,
const char*)>
403 TEST(InvokeMethodTest, MethodThatTakes9Arguments) {
405 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
406 const char*,
const char*,
const char*,
const char*,
416 TEST(InvokeMethodTest, MethodThatTakes10Arguments) {
418 Action<
std::string(
const char*,
const char*,
const char*,
const char*,
419 const char*,
const char*,
const char*,
const char*,
420 const char*,
const char*)>
430 TEST(InvokeMethodTest, MethodWithCompatibleType) {
432 Action<
long(
int,
short,
char,
bool)>
a =
438 TEST(WithoutArgsTest, NoArg) {
444 TEST(WithArgTest, OneArg) {
450 TEST(ReturnArgActionTest, WorksForOneArgIntArg0) {
451 const Action<
int(
int)>
a = ReturnArg<0>();
455 TEST(ReturnArgActionTest, WorksForMultiArgBoolArg0) {
456 const Action<
bool(
bool,
bool,
bool)>
a = ReturnArg<0>();
460 TEST(ReturnArgActionTest, WorksForMultiArgStringArg2) {
465 TEST(ReturnArgActionTest, WorksForNonConstRefArg0) {
468 EXPECT_EQ(&s, &
a.Perform(std::forward_as_tuple(s)));
471 TEST(SaveArgActionTest, WorksForSameType) {
478 TEST(SaveArgActionTest, WorksForCompatibleType) {
480 const Action<void(
bool,
char)>
a1 = SaveArg<1>(&
result);
485 TEST(SaveArgPointeeActionTest, WorksForSameType) {
488 const Action<void(
const int*)>
a1 = SaveArgPointee<0>(&
result);
493 TEST(SaveArgPointeeActionTest, WorksForCompatibleType) {
496 const Action<void(
bool,
char*)>
a1 = SaveArgPointee<1>(&
result);
501 TEST(SetArgRefereeActionTest, WorksForSameType) {
503 const Action<void(
int&)>
a1 = SetArgReferee<0>(1);
504 a1.Perform(std::tuple<int&>(
value));
508 TEST(SetArgRefereeActionTest, WorksForCompatibleType) {
510 const Action<void(
int,
int&)>
a1 = SetArgReferee<1>(
'a');
511 a1.Perform(std::tuple<int, int&>(0,
value));
515 TEST(SetArgRefereeActionTest, WorksWithExtraArguments) {
517 const Action<void(
bool,
int,
int&,
const char*)>
a1 = SetArgReferee<2>(
'a');
518 a1.Perform(std::tuple<bool, int, int&, const char*>(
true, 0,
value,
"hi"));
524 class DeletionTester {
540 TEST(DeleteArgActionTest, OneArg) {
541 bool is_deleted =
false;
542 DeletionTester* t =
new DeletionTester(&is_deleted);
543 const Action<void(DeletionTester*)>
a1 = DeleteArg<0>();
549 TEST(DeleteArgActionTest, TenArgs) {
550 bool is_deleted =
false;
551 DeletionTester* t =
new DeletionTester(&is_deleted);
552 const Action<void(
bool,
int,
int,
const char*,
bool,
553 int,
int,
int,
int, DeletionTester*)>
a1 = DeleteArg<9>();
559 #if GTEST_HAS_EXCEPTIONS
561 TEST(ThrowActionTest, ThrowsGivenExceptionInVoidFunction) {
562 const Action<void(
int n)>
a =
Throw(
'a');
566 class MyException {};
568 TEST(ThrowActionTest, ThrowsGivenExceptionInNonVoidFunction) {
569 const Action<double(
char ch)>
a =
Throw(MyException());
573 TEST(ThrowActionTest, ThrowsGivenExceptionInNullaryFunction) {
574 const Action<double()>
a =
Throw(MyException());
581 virtual void Func() {}
584 class MockObject :
public Object {
586 ~MockObject()
override {}
590 TEST(ThrowActionTest, Times0) {
595 ON_CALL(
m,
Func()).WillByDefault([] {
throw "something"; });
605 #endif // GTEST_HAS_EXCEPTIONS
609 TEST(SetArrayArgumentTest, SetsTheNthArray) {
611 int numbers[] = { 1, 2, 3 };
612 Action<MyFunction>
a = SetArrayArgument<1>(numbers, numbers + 3);
630 a = SetArrayArgument<2>(letters.begin(), letters.end());
631 std::fill_n(n, 4, 0);
632 std::fill_n(
ch, 4,
'\0');
645 TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) {
647 int numbers[] = { 1, 2, 3 };
648 Action<MyFunction>
a = SetArrayArgument<1>(numbers, numbers);
661 TEST(SetArrayArgumentTest, SetsTheNthArrayWithConvertibleType) {
663 char chars[] = { 97, 98, 99 };
664 Action<MyFunction>
a = SetArrayArgument<1>(chars, chars + 3);
666 int codes[4] = { 111, 222, 333, 444 };
676 TEST(SetArrayArgumentTest, SetsTheNthArrayWithIteratorArgument) {
677 using MyFunction = void(
bool, std::back_insert_iterator<std::string>);
679 Action<MyFunction>
a = SetArrayArgument<1>(letters.begin(), letters.end());
686 TEST(ReturnPointeeTest, Works) {
698 TEST(InvokeArgumentTest, Function0) {
699 Action<
int(
int,
int (*)())>
a = InvokeArgument<1>();
704 TEST(InvokeArgumentTest, Functor1) {
710 TEST(InvokeArgumentTest, Function5) {
711 Action<
int(
int (*)(
int,
int,
int,
int,
int))>
a =
712 InvokeArgument<0>(10000, 2000, 300, 40, 5);
717 TEST(InvokeArgumentTest, Functor5) {
719 InvokeArgument<0>(10000, 2000, 300, 40, 5);
724 TEST(InvokeArgumentTest, Function6) {
725 Action<
int(
int (*)(
int,
int,
int,
int,
int,
int))>
a =
726 InvokeArgument<0>(100000, 20000, 3000, 400, 50, 6);
731 TEST(InvokeArgumentTest, Functor6) {
733 InvokeArgument<0>(100000, 20000, 3000, 400, 50, 6);
738 TEST(InvokeArgumentTest, Function7) {
740 const char*,
const char*,
const char*,
742 a = InvokeArgument<0>(
"1",
"2",
"3",
"4",
"5",
"6",
"7");
747 TEST(InvokeArgumentTest, Function8) {
749 const char*,
const char*,
const char*,
750 const char*,
const char*))>
751 a = InvokeArgument<0>(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8");
756 TEST(InvokeArgumentTest, Function9) {
758 const char*,
const char*,
const char*,
759 const char*,
const char*,
const char*))>
760 a = InvokeArgument<0>(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9");
765 TEST(InvokeArgumentTest, Function10) {
767 const char*,
const char*,
const char*,
const char*,
const char*,
768 const char*,
const char*,
const char*,
const char*,
const char*))>
769 a = InvokeArgument<0>(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"0");
774 TEST(InvokeArgumentTest, ByPointerFunction) {
775 Action<
const char*(
const char* (*)(
const char*
input,
short n))>
776 a = InvokeArgument<0>(
static_cast<const char*
>(
"Hi"),
Short(1));
782 TEST(InvokeArgumentTest, FunctionWithCStringLiteral) {
783 Action<
const char*(
const char* (*)(
const char*
input,
short n))>
784 a = InvokeArgument<0>(
"Hi",
Short(1));
789 TEST(InvokeArgumentTest, ByConstReferenceFunction) {
800 TEST(InvokeArgumentTest, ByExplicitConstReferenceFunction) {
807 a = InvokeArgument<0>(
ByRef(
x));
821 TEST(DoAllTest, ThreeActions) {
824 SetArgPointee<1>(2),
Return(3));
835 DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2), SetArgPointee<2>(
'a'),
846 char a =
'\0',
b =
'\0';
848 DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2), SetArgPointee<2>(
'a'),
849 SetArgPointee<3>(
'b'),
Return(3));
860 char a =
'\0',
b =
'\0', c =
'\0';
862 DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2), SetArgPointee<2>(
'a'),
863 SetArgPointee<3>(
'b'), SetArgPointee<4>(
'c'),
Return(3));
873 TEST(DoAllTest, SevenActions) {
875 char a =
'\0',
b =
'\0', c =
'\0', d =
'\0';
877 DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2), SetArgPointee<2>(
'a'),
878 SetArgPointee<3>(
'b'), SetArgPointee<4>(
'c'), SetArgPointee<5>(
'd'),
890 TEST(DoAllTest, EightActions) {
892 char a =
'\0',
b =
'\0', c =
'\0', d =
'\0', e =
'\0';
893 Action<
int(
int*,
int*,
char*,
char*,
char*,
char*,
896 DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2), SetArgPointee<2>(
'a'),
897 SetArgPointee<3>(
'b'), SetArgPointee<4>(
'c'),
898 SetArgPointee<5>(
'd'), SetArgPointee<6>(
'e'),
Return(3));
912 char a =
'\0',
b =
'\0', c =
'\0', d =
'\0', e =
'\0', f =
'\0';
913 Action<
int(
int*,
int*,
char*,
char*,
char*,
char*,
915 action =
DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2),
916 SetArgPointee<2>(
'a'), SetArgPointee<3>(
'b'),
917 SetArgPointee<4>(
'c'), SetArgPointee<5>(
'd'),
918 SetArgPointee<6>(
'e'), SetArgPointee<7>(
'f'),
Return(3));
933 char a =
'\0',
b =
'\0', c =
'\0', d =
'\0';
934 char e =
'\0', f =
'\0',
g =
'\0';
935 Action<
int(
int*,
int*,
char*,
char*,
char*,
char*,
936 char*,
char*,
char*)>
938 DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2), SetArgPointee<2>(
'a'),
939 SetArgPointee<3>(
'b'), SetArgPointee<4>(
'c'),
940 SetArgPointee<5>(
'd'), SetArgPointee<6>(
'e'),
941 SetArgPointee<7>(
'f'), SetArgPointee<8>(
'g'),
Return(3));
956 bool ran_first =
false;
958 DoAll([&] { ran_first =
true; }, [&] {
return ran_first; });
962 TEST(DoAllTest, MoveOnlyArgs) {
963 bool ran_first =
false;
966 [](std::unique_ptr<int> p) {
return *p; });
971 TEST(DoAllTest, ImplicitlyConvertsActionArguments) {
972 bool ran_first =
false;
975 Action<void(std::vector<int>)>
first = [&] { ran_first =
true; };
989 #pragma warning(push)
990 #pragma warning(disable : 4100)
991 #pragma warning(disable : 4503)
999 TEST(ActionMacroTest, WorksWhenNotReferencingArguments) {
1010 TEST(ActionMacroTest, WorksWhenReturningVoid) {
1011 Action<void(
int,
int*)>
a1 = IncrementArg1();
1020 StaticAssertTypeEq<int*, arg2_type>();
1021 arg2_type
temp = arg2;
1025 TEST(ActionMacroTest, CanReferenceArgumentType) {
1026 Action<void(
int,
bool,
int*)>
a1 = IncrementArg2();
1035 StaticAssertTypeEq<std::tuple<int, char, int*>, args_type>();
1036 args_type args_copy =
args;
1037 return std::get<0>(args_copy) + std::get<1>(args_copy);
1040 TEST(ActionMacroTest, CanReferenceArgumentTuple) {
1055 StaticAssertTypeEq<int(bool), function_type>();
1056 function_type* fp = &
Dummy;
1060 TEST(ActionMacroTest, CanReferenceMockFunctionType) {
1069 StaticAssertTypeEq<int, return_type>();
1074 TEST(ActionMacroTest, CanReferenceMockFunctionReturnType) {
1082 StaticAssertTypeEq<const bool&, arg1_type>();
1086 TEST(ActionMacroTest, WorksForConstReferenceArg) {
1087 Action<
const bool*(
int,
const bool&)>
a = ReturnAddrOfConstBoolReferenceArg();
1088 const bool b =
false;
1089 EXPECT_EQ(&
b,
a.Perform(std::tuple<int, const bool&>(0,
b)));
1094 StaticAssertTypeEq<int&, arg0_type>();
1098 TEST(ActionMacroTest, WorksForNonConstReferenceArg) {
1101 EXPECT_EQ(&
n,
a.Perform(std::tuple<int&, bool, int>(
n,
true, 1)));
1105 namespace action_test {
1109 TEST(ActionMacroTest, WorksInNamespace) {
1118 TEST(ActionMacroTest, WorksForDifferentArgumentNumbers) {
1122 Action<double(
float,
void*)>
a2 = PlusTwo();
1130 TEST(ActionPMacroTest, DefinesParameterizedAction) {
1138 arg0_type
t1 = arg0;
1143 TEST(ActionPMacroTest, CanReferenceArgumentAndParameterTypes) {
1150 TEST(ActionPMacroTest, WorksInCompatibleMockFunction) {
1160 ACTION(OverloadedAction) {
return arg0 ? arg1 :
"hello"; }
1163 return arg0 ? arg1 : default_value;
1167 return arg0 ? true_value : false_value;
1170 TEST(ActionMacroTest, CanDefineOverloadedActions) {
1171 using MyAction =
Action<
const char*(
bool,
const char*)>;
1173 const MyAction
a1 = OverloadedAction();
1177 const MyAction
a2 = OverloadedAction(
"hi");
1181 const MyAction a3 = OverloadedAction(
"hi",
"you");
1190 TEST(ActionPnMacroTest, WorksFor3Parameters) {
1191 Action<double(
int m,
bool t)>
a1 = Plus(100, 20, 3.4);
1200 ACTION_P4(Plus, p0, p1, p2, p3) {
return arg0 + p0 + p1 + p2 + p3; }
1202 TEST(ActionPnMacroTest, WorksFor4Parameters) {
1207 ACTION_P5(Plus, p0, p1, p2, p3, p4) {
return arg0 + p0 + p1 + p2 + p3 + p4; }
1209 TEST(ActionPnMacroTest, WorksFor5Parameters) {
1215 return arg0 + p0 + p1 + p2 + p3 + p4 + p5;
1218 TEST(ActionPnMacroTest, WorksFor6Parameters) {
1224 return arg0 + p0 + p1 + p2 + p3 + p4 + p5 + p6;
1227 TEST(ActionPnMacroTest, WorksFor7Parameters) {
1233 return arg0 + p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7;
1236 TEST(ActionPnMacroTest, WorksFor8Parameters) {
1237 Action<
int(
int)>
a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8);
1238 EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8,
1243 return arg0 + p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8;
1246 TEST(ActionPnMacroTest, WorksFor9Parameters) {
1247 Action<
int(
int)>
a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8, 9);
1248 EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9,
1252 ACTION_P10(Plus, p0, p1, p2, p3, p4, p5, p6, p7, p8, last_param) {
1253 arg0_type
t0 = arg0;
1254 last_param_type t9 = last_param;
1255 return t0 + p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + t9;
1258 TEST(ActionPnMacroTest, WorksFor10Parameters) {
1259 Action<
int(
int)>
a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
1260 EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10,
1269 char suffix_char =
static_cast<char>(
suffix);
1270 return prefix_str + arg0 + suffix_char;
1273 TEST(ActionPnMacroTest, SimpleTypePromotion) {
1277 PadArgument(
"foo",
static_cast<int>(
'r'));
1288 std::stringstream ss;
1298 template <
typename T1,
typename T2>
1309 return ConcatImpl(
a,
b, c);
1314 return ConcatImpl<std::string, T1, T2>(
a,
b, c);
1320 template <
typename T1,
typename T2>
1322 return ConcatImpl(
a,
b, c);
1325 TEST(ActionPnMacroTest, CanPartiallyRestrictParameterTypes) {
1339 TEST(ActionPnMacroTest, TypesAreCorrect) {
1341 DoFooAction a0 = DoFoo();
1344 DoFooActionP<int>
a1 = DoFoo(1);
1348 DoFooActionP2<int, char>
a2 = DoFoo(1,
'2');
1349 PlusActionP3<int, int, char> a3 = Plus(1, 2,
'3');
1350 PlusActionP4<int, int, int, char> a4 = Plus(1, 2, 3,
'4');
1351 PlusActionP5<int, int, int, int, char> a5 = Plus(1, 2, 3, 4,
'5');
1352 PlusActionP6<int, int, int, int, int, char> a6 = Plus(1, 2, 3, 4, 5,
'6');
1353 PlusActionP7<int, int, int, int, int, int, char> a7 =
1354 Plus(1, 2, 3, 4, 5, 6,
'7');
1355 PlusActionP8<int, int, int, int, int, int, int, char> a8 =
1356 Plus(1, 2, 3, 4, 5, 6, 7,
'8');
1357 PlusActionP9<int, int, int, int, int, int, int, int, char> a9 =
1358 Plus(1, 2, 3, 4, 5, 6, 7, 8,
'9');
1359 PlusActionP10<int, int, int, int, int, int, int, int, int, char> a10 =
1360 Plus(1, 2, 3, 4, 5, 6, 7, 8, 9,
'0');
1382 ACTION_P10(Plus10, a0,
a1,
a2, a3, a4, a5, a6, a7, a8, a9) {
1383 return a0 +
a1 +
a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9;
1386 TEST(ActionPnMacroTest, CanExplicitlyInstantiateWithReferenceTypes) {
1387 int x = 1,
y = 2,
z = 3;
1393 a = Plus2<const int&, int&>(
x,
y);
1396 a = Plus3<int&, const int&, int&>(
x,
y,
z);
1399 int n[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1400 a = Plus10<
const int&,
int&,
const int&,
int&,
const int&,
int&,
const int&,
1401 int&,
const int&,
int&>(
n[0],
n[1],
n[2],
n[3],
n[4],
n[5],
n[6],
1409 int a8,
int a9,
int a10)
1410 :
value_(
a1 +
a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10) {}
1416 AND_0_VALUE_PARAMS()) {
1420 TEST(ActionTemplateTest, WorksWithoutValueParam) {
1421 const Action<
int*()>
a = CreateNew<int>();
1428 AND_1_VALUE_PARAMS(a0)) {
1432 TEST(ActionTemplateTest, WorksWithValueParams) {
1433 const Action<
int*()>
a = CreateNew<int>(42);
1441 AND_0_VALUE_PARAMS()) {
1442 delete std::get<k>(
args);
1455 TEST(ActionTemplateTest, WorksForIntegralTemplateParams) {
1466 HAS_1_TEMPLATE_PARAMS(template <typename Pointee>
class,
1468 AND_1_VALUE_PARAMS(pointee)) {
1469 return Pointer<pointee_type>(
new pointee_type(pointee));
1472 TEST(ActionTemplateTest, WorksForTemplateTemplateParameters) {
1474 ReturnSmartPointer<std::shared_ptr>(42);
1480 template <
typename T1,
typename T2,
typename T3,
int k4,
bool k5,
1481 unsigned int k6,
typename T7,
typename T8,
typename T9>
1489 HAS_10_TEMPLATE_PARAMS(
typename,
T1,
typename,
T2,
typename,
T3,
1490 int, k4,
bool, k5,
unsigned int, k6,
1491 class, T7,
class, T8,
class, T9,
1492 template <typename T>
class, T10),
1493 AND_1_VALUE_PARAMS(
value)) {
1497 TEST(ActionTemplateTest, WorksFor10TemplateParameters) {
1499 char, unsigned,
int>;
1500 const Action<Giant()>
a = ReturnGiant<
int,
bool, double, 5,
true, 6, char,
1501 unsigned,
int, std::shared_ptr>(42);
1508 AND_10_VALUE_PARAMS(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)) {
1509 return static_cast<Number
>(v1) + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10;
1512 TEST(ActionTemplateTest, WorksFor10ValueParameters) {
1513 const Action<
int()>
a = ReturnSum<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
1525 AND_2_VALUE_PARAMS(v1, v2)) {
1526 return static_cast<Number
>(v1) + v2;
1530 AND_3_VALUE_PARAMS(v1, v2, v3)) {
1531 return static_cast<Number
>(v1) + v2 + v3;
1535 AND_4_VALUE_PARAMS(v1, v2, v3, v4)) {
1536 return static_cast<Number
>(v1) + v2 + v3 + v4 +
k;
1539 TEST(ActionTemplateTest, CanBeOverloadedOnNumberOfValueParameters) {
1543 const Action<
int()> a3 = ReturnSum<int>(1, 2, 3);
1544 const Action<
int()> a4 = ReturnSum<int, 10000>(2000, 300, 40, 5);