I'm working for the first time with GMock, I'm mocking a class with pure virtual methods, I created an instance from the Mock class
MockInterface mockIntr;
Then I need to pass this mock as a parameter to another function
func->action(std::make_shared<MockInterface>(mockIntr);
in this case I got the error : "C2280 : MockInterface::MockInterface(const MockInterface&) : attempt to reference a deleted function"
I'm not sure if the solution is to create a copy constructor in the class MockInterface or there is another way to fix the problem.
You're not passing that mock, you're trying to copy it and pass the copy.
(make_shared<T>(x)
means "create a new T
from x
that we can share", not "let's share x
".)
Create a shared object immediately:
auto mockIntr = std::make_shared<MockInterface>();
func->action(mockIntr);