mat007 / turtle

C++ mock object library for Boost

Home Page:http://turtle.sourceforge.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MOCK_EXPECT(...).moves(...) fails to compile if return value is a unique_ptr

Aperion opened this issue · comments

The following code fails to compile with an error "cannot convert argument 1 from 'std::reference_wrapperstd::unique_ptr<Interface,std::default_delete<_Ty>>' to 'std::nullptr_t'"

could be a regression of http://sourceforge.net/p/turtle/tickets/15/ ?

#include "stdafx.h"

#include "Mocks/QueryMocks.h"

class Interface
{
public:
   virtual ~Interface() {}

   virtual std::unique_ptr<std::string> SomeFunc() const = 0;
};

class Mock : public virtual Interface
{
public:
   MOCK_CONST_METHOD(SomeFunc, 0, std::unique_ptr<std::string>());
};


BOOST_AUTO_TEST_SUITE(Test_Suite)
BOOST_AUTO_TEST_CASE(Test_Base)
{
   Mock instance;
   std::unique_ptr<Interface> returnee = std::make_unique<Mock>();

   //boost\function\function_template.hpp(132): error C2664: 'std::unique_ptr<std::string,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : cannot convert argument 1 from 'std::reference_wrapper<std::unique_ptr<Mock,std::default_delete<Mock>>>' to 'std::nullptr_t'
   MOCK_EXPECT(instance.SomeFunc).moves(std::move(returnee)); //error C2664
   MOCK_EXPECT(instance.SomeFunc).moves(std::ref(returnee)); //error C2664
}

BOOST_AUTO_TEST_SUITE_END()