I'm having a crash in the following code:
class ITest
{
virtual void test(){};
};
void doNothing(){}
class TestMock: ITest
{
public:
MOCK_METHOD0(test, void());
};
class Server_Fixture: public ::testing::Test
{
public:
std::unique_ptr<TestMock> mock;
void SetUp() override
{
mock = std::unique_ptr<TestMock>();
}
void TearDown() override
{
}
TestMock& getMock(){ return *mock; }
};
TEST_F(Server_Fixture, execute)
{
EXPECT_CALL(getMock(), test()).WillRepeatedly(Invoke(doNothing)); // <<<< Segmentation fault (core dumped)
}
Could someone explain why it is crashing ? The crash does not happen if I create a local mock object (without using unique_ptr) in the TEST_F function.