Edit: I have classes that receives messages:
class Foo {
public:
void receive(FooMessage& message));
// other messages
}
class Bar {
public:
void receive(BarMessage& message));
// other messages
}
and mock that test receiving those messages:
class Mock {
public:
MOCK_METHOD(void, receive, (FooMessage& arg));
MOCK_METHOD(void, receive, (BarMessage& arg));
// a lot other messages
}
I wanted to turn Mock
into template, so instead of writing long list of MOCK_METHOD()
in Mock
I would create mock like this:
Mock<BarMessage,BazMessage> myMock;
and have those mock methods generated for me. Is it possible to achieve?
Original question: I have mock class that looks like this:
class foo
{
public:
MOCK_METHOD(void, foo, (bar& arg));
MOCK_METHOD(void, foo, (bar& arg));
// other overloads
}
Is it possible to create those mock methods using template parameter pack? I'm looking to do something like this:
template <typename...Ts>
class foo
{
public:
template <Ts...t>
MOCK_METHOD(void, foo, (t& arg))...;
}