diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 0f30abde..ecf47c40 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -1335,15 +1335,17 @@ class ActionHelper { public: template static Result Perform(Impl* impl, const std::tuple& args) { - return Apply(impl, args, MakeIndexSequence{}, - MakeIndexSequence<10 - sizeof...(Ts)>{}); + static constexpr size_t kMaxArgs = sizeof...(Ts) <= 10 ? sizeof...(Ts) : 10; + return Apply(impl, args, MakeIndexSequence{}, + MakeIndexSequence<10 - kMaxArgs>{}); } private: template static Result Apply(Impl* impl, const std::tuple& args, IndexSequence, IndexSequence) { - return impl->template gmock_PerformImpl( + return impl->template gmock_PerformImpl< + typename std::tuple_element>::type...>( args, std::get(args)..., ((void)rest_ids, ExcessiveArg())...); } diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index cac8f94f..547f48f4 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -1550,6 +1550,26 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) { EXPECT_EQ(x, 3); } +ACTION(ReturnArity) { + return std::tuple_size::value; +} + +TEST(ActionMacro, LargeArity) { + EXPECT_EQ( + 1, testing::Action(ReturnArity()).Perform(std::make_tuple(0))); + EXPECT_EQ( + 10, + testing::Action( + ReturnArity()) + .Perform(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7, 8, 9))); + EXPECT_EQ( + 20, + testing::Action( + ReturnArity()) + .Perform(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19))); +} } // Unnamed namespace