Monday 15 March 2010

c++ - Matching arguments of custom type in googlemock -


I have a problem matching a function argument for a specific object using Google Mock.

Consider the following code:

  square fu {public: straight bar {int foobar; } Zero myMethod (Constant Bar and Bar); }   

Now I have some test codes, it can look like this:

  Foo :: repeatedly; EXPECT_CALL (fooMock, mymethod (Eq (bar));   

So I have to make sure that when Foo :: myMethod called logic looks like my object locally immediate time is.

when I tried this approach, I get an error message:

  gmock / gmock-matchers.h (738): error C2678: binary '==': No operator found that takes a left hand operation type 'const foo :: bar' (or no acceptable conversion)   

I defined the option By using Eq (ByRef (Bar)), I was not able to fix this issue. The only thing that helps.

  Field (& Foo :: Bar :: Forbear, X)   

But in this way, I have to look at each field in my string which will be used for typing Looks like a task ...

OK, so I will answer myself:

Operator == Function for you FU Will Nwyn. Bar:

  Bull Operator == (Const Fu :: Bar & First, Conf Fu :: Time & Second) {...}   

It is not add to the FU :: bar as a member function, but use a free function.

And, lessons learned, be careful to update them (update: not ) in an anonymous namespace ;-)

No comments:

Post a Comment