Closed tnovotny closed 7 years ago
I'm interested in this as well. It seems FakeIt is storing the parameters of a call in order to find a matcher for it to return the correct value. It seems to be keeping the copies for later as well though, I'm not sure why. I'm using move-only types quite a bit, I'd like to use FakeIt, but it seems like it won't be possible..
The issue is unfortunately still not fixed for me. I really hope this can be fixed as FakeIt is really great and I'd love to use it.
The following code triggers an error:
class Testclass {
public:
Testclass() {};
virtual int* foo(std::unique_ptr<int> i) {
i_ = std::move(i);
return i_.get();
};
protected:
std::unique_ptr<int> i_;
};
Mock<Testclass> mock;
When(Method(mock, foo)).AlwaysReturn(nullptr);
Error message is:
C2665: 'std::tuple<std::unique_ptr<int,std::default_delete<_Ty>>>::tuple': none of the 2 overloads could convert all the argument types .....\fakeit.hpp 350
All the thanks to @dgel who submitted the fix.
When trying to set up an expectation for a method that takes a non copyable argument such as a unique_ptr, I get the following message from the compiler (mscv 2015)
Basically the class looks like this.
and the following code is enough to trigger the error.
As passing unique_ptr by value is the preferred method for passing "sink" values, this is not that uncommon.