Closed c0yote closed 9 years ago
You are doing right. It seems like Fakeit doesn't support const overload. I will try to solve this issue this weekend. Thanks, Eran. On Mar 11, 2015 11:32 PM, "U.G. Wilson" notifications@github.com wrote:
I may just be doing it wrong, but I can't find a way to return from a const overload. I checked the project's unit test code and didn't find any examples.
Support for the following situation would be highly appreciated.
virtual Foo& GetBar(); virtual const Foo& GetBar() const;
Love the framework, thanks for all of your effort!
— Reply to this email directly or view it on GitHub https://github.com/eranpeer/FakeIt/issues/14.
Ok, I added a ConstOverloadedMethod macro that is used just like the OverloadedMethod macro. For example:
struct SomeInterface {
virtual int func() = 0;
virtual int func() const = 0;
}
Mock<SomeInterface> mock;
When(OverloadedMethod(mock, func, int())).Return(1);
When(ConstOverloadedMethod(mock, func, int())).Return(2);
SomeInterface &obj = mock.get();
const SomeInterface& constObj = mock.get();
ASSERT_EQUAL(1, obj.func());
ASSERT_EQUAL(2, constObj.func());
Thank you for submitting this issue. Fakeit is better now!!
BTW, I added some more samples to the overloadded_methods_tests.cpp file. I hope this helps.
Thanks! Works like a champ!
I may just be doing it wrong, but I can't find a way to return from a const overload. I checked the project's unit test code and didn't find any examples.
Support for the following situation would be highly appreciated.
Love the framework, thanks for all of your effort!