How to write EXPECT_CALL for the mock function with return type std::vector<std::tuple<int,int>> in gtest/gmock

Viewed 124

I have a member function in the c++ class with return type std::vector<std::tuple<int,int>>

code.cpp

class A
{
A();
~A();
std::vector<std::tuple<int,int>> function();

};

AMock.cpp**

using vectorOfTuple= std::vector<std::tuple<int,int>>;
Class A_mock
{
MOCK_METHOD(vectorOfTuple, function, (),());
};

ATest.cpp********

TEST_F(TestClass, testname)
{
using vectorOfTuple= std::vector<std::tuple<int,int>>;
vectorOfTuple result;
vectorOfTuple getAllValues = {{10,2},
    {20,2},
    {30,2},
    {40,2}
    };
 EXPECT_CALL(A_mock, function())
            .WillRepeatedly(DoAll(
                SetArrayArgument<0>(getAllValues.begin(),
                                    getAllValues.end()),
                SetArgPointee<1>(getAllValues.size()),
                Return(result)));
}

PROBLEM DESCRIPTION***********

  1. I am getting the error: external/googletest/googlemock/include/gmock/gmock-more-actions.h:125:41: error: no matching function for call to 'get<0>(const args_type&)' ::std::copy(first, last, ::std::get(args)); ~~~~~~~~~~~~~^~~~~~
  2. How to get all the values of VectorOfTuple to the result variable?

Please Note*********

  1. Please refer ATest.cpp first
  2. All the code is just for example/reference to explain the scenario, please do not concentrate on any other errors
0 Answers
Related