eranpeer / FakeIt

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

Missing .CoReturn method #325

Open tripleslash opened 5 months ago

tripleslash commented 5 months ago

Hello, I want to co_return something from a mocked function. Something like:

// Instantiate a mock object.
Mock<SomeInterface> mock;

// Setup mock behavior.
When(Method(mock,foo)).CoReturn(1); // Method mock.foo will co_return 1 once.

But the CoReturn method does not exist. How can something like this be achieved?

FranckRJ commented 5 months ago

Maybe you can do it by using the .Do() method and passing it a lambda that uses co_return (if it's possible). But a proper support of coroutines in fakeit should be investigated.