I have factory that creates some windows by returning unique_ptr:
std::unique_ptr<WindowsInterface> NCursesWindowsFactory::createMainWindow()
{
return std::make_unique<NCursesMainWindowDecorator>(std::make_unique<NCursesWindow>());
}
And in Mocked factory class this method:
MOCK_METHOD0(createMainWindow, std::unique_ptr<WindowsInterface>());
How to write EXPECT_CALL that will return some object as unique_ptr without copying it, just as I do in my fist method?
My EXPECT_CALL on factory mock has return like this:
.WillOnce(Return(std::make_unique<NCursesMainWindowDecorator>(std::make_unique<NCursesWindow>())))
And I want to move this unique_ptr but gmock tries to copy that:
./lib/googletest/googlemock/include/gmock/gmock-actions.h:579:59: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = miniReader::windowsManager::WindowsInterface; _Dp = std::default_delete<miniReader::windowsManager::WindowsInterface>]’
Aucun commentaire:
Enregistrer un commentaire