eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.24k stars 173 forks source link

Currently unable to mock returns for functions with move only return values. e.g. unique_ptr #281

Closed malcolmdavey closed 1 year ago

malcolmdavey commented 2 years ago

The following fails to compile

class A
{
public:
    virtual std::unique_ptr<std::string> method_move_only_return() = 0;
};

TEST(fakeit, Compile_Fails_ReturnMoveOnly)
{
    Mock<A> mockA;

    When(Method(mockA, method_move_only_return))
        .Return(make_unique<std::string>("value"));

    EXPECT_EQ("value", *mockA.get().method_move_only_return());
}
malcolmdavey commented 2 years ago

I have a solution for this one.

FranckRJ commented 1 year ago

Fixed by #282 in 2.3.1.