Why does Google Mocks find this function call ambiguous?
For those of you who have the same issue but unlike the OP don't have or care about the input parameters, the other answer's solution using testing::Matcher can be combined with a wild card testing::_ this way:
EXPECT_CALL(mock, SetParameter(testing::_, Matcher<__int64>(testing::_)));
Google mock has trouble telling which overload to use. From the cookbook, try using the Matcher<T>
or TypedEq<T>
matchers to specify the exact type:
struct ITest
{
virtual int SetParameter(int n, double v) = 0;
virtual int SetParameter(int n, int v) = 0;
virtual int SetParameter(int n, __int64 v) = 0;
};
struct MockTest : public ITest
{
MOCK_METHOD2(SetParameter, int(int n, double v));
MOCK_METHOD2(SetParameter, int(int n, int v));
MOCK_METHOD2(SetParameter, int(int n, __int64 v));
};
TEST(Test, Test)
{
MockTest mock;
__int64 nFrom = 0, nTo = 0;
EXPECT_CALL(mock, SetParameter(2, Matcher<__int64>(nFrom)));
EXPECT_CALL(mock, SetParameter(3, Matcher<__int64>(nTo)));
mock.SetParameter(2, nFrom);
mock.SetParameter(3, nTo);
}