Is it possible with gmock to mock a function which contains a class template parameter in it's signature? For example:
template <typename T>
struct Mockable
{
virtual void do_work(const int num, const T& value) = 0;
};
template <typename T>
struct MockMockable : Mockable<T>
{
MOCK_METHOD2(do_work, void(const int, const T&));
};
I found the answer, you need to denote the mock methods specifically as template mock methods with a _T
template <typename T>
struct MockMockable : Mockable<T>
{
MOCK_METHOD2_T(do_work, void(const int, const T&));
};
More information: https://github.com/google/googletest/blob/master/googlemock/docs/cheat_sheet.md#mocking-a-class-template-mocktemplate