lundi 2 novembre 2015

gmock TypedEq same string different address

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

EXPECT_CALL(actx_mock, getDeviceClientService(TypedEq<const char*>("avout"),_,_)).WillOnce(...

TypedEq is needed because the method is overloaded, accepting either a string or a 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 even though the string is the same, since it is pointing do a different instance of that string at a different address, it doesn't match? Is there a way to make it match on any string that matches that value, regardless of address?

Aucun commentaire:

Enregistrer un commentaire