I have a problem with matching a function argument to a specific object using google mock.
Consider the following code:
class Foo { public: struct Bar { int foobar; } void myMethod(const Bar& bar); }
Now I have the code for testing, it might look like this:
Foo::Bar bar; EXPECT_CALL(fooMock, myMethod(Eq(bar));
So I want to make sure that when Foo :: myMethod is called, the argument looks like my locally based object.
When I try to use this approach, I get an error message like:
gmock/gmock-matchers.h(738): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const Foo::Bar' (or there is no acceptable conversion)
I tried playing with the defining operator == and! = (At least as a member of a free function) using Eq (ByRef (bar)), but I could not fix this problem. The only thing that helps is to use
Field(&Foo::Bar::foobar, x)
but so I have to check every field in my structure, which seems to print a lot of work ...
source share