Gmock TypedEq is the same line as another address

I am trying to set the wait on a gmock object. The wait should apply whenever "avout" is passed as an argument to my method. I set this expectation:

EXPECT_CALL(actx_mock, getDeviceClientService(TypedEq<const char*>("avout"),_,_)).WillOnce(DoAll(SetArgPointee<2>(&mockAVOut), Return(0)));

TypedEq is necessary because the method is overloaded, accepting either a string or const char *. When I run my test, I get the following error:

CAniSpiceServices_test.cpp:1357: EXPECT_CALL(actx_mock, getDeviceClientService(TypedEq<const char*>("avout"),_,_))...
  Expected arg #0: is equal to 0x4dbf41 pointing to "avout"
           Actual: 0x7fbc6861370d pointing to "avout"

So it looks like the string is the same, since it points another instance of this string to a different address, does it not match? Is there a way to make it match any string that matches this value, regardless of address?

+4
source share
1 answer

, , , , .

, TypedEq <type> Matcher <type> (Eq()), Eq , . , , , , . , , .

, , TypedEq <type> , Matcher <type> (StrEq()), StrEq , .

+4

Source: https://habr.com/ru/post/1614173/


All Articles