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

Can't mock override with ref-qualifiers? #292

Closed Ramjii closed 1 year ago

Ramjii commented 1 year ago

I have an interface with simple overloaded methods that I use as getter and setter: virtual auto Index() const& -> unsigned = 0; and virtual auto Index() & -> unsigned& = 0;

I can't seem to mock them, especially the second one (the setter). When using OverloadedMethod, I get hit with a compilation error. I know there is a ConstOverloadedMethod, but I think it's missing a version of the macro supporting ref-qualifiers?

malcolmdavey commented 1 year ago

Haven't tested it, but looks like a valid point. Looks like it is only supporting C++98/03 overloading at the moment.

Might be a matter of adding newer overload methods and macros e.g. LRefOverloadedMethod, RRefOverloadedMethod , ConstLRef... , ConstRRef ...

Not sure if there is a better solution to all this ...

malcolmdavey commented 1 year ago

A possible fix for this? https://github.com/eranpeer/FakeIt/pull/293

Ramjii commented 1 year ago

Thanks!! I just looked at it, looks like the right direction, but the Verify macro wasn't working

malcolmdavey commented 1 year ago

Thanks!! I just looked at it, looks like the right direction, but the Verify macro wasn't working

@Ramjii Could you give an example of your verify line ...?

FranckRJ commented 1 year ago

Implemented by #316 which should be available in FakeIt 2.4.0. If you find any bug (with Verify for example) please open an issue with all the code needed to reproduce it.