How to correctly construct a matcher for "const char*" argument?

4,845 views
Skip to first unread message

fspirit

unread,
Feb 3, 2011, 8:02:41 AM2/3/11
to Google C++ Mocking Framework
Hi All!

I'm trying to write an expectation for a method that has a const char*
param

I've tried

EXPECT_CALL(mockObject, methodName(StrEq("123456")));

it doesn't compile, giving errors

../../gmock-gtest/gtest.h:16851:0 ../../gmock-gtest/gtest.h:16851:
error: no match for 'operator==' in 'expected == actual'
../../gmock-gtest/gtest.h:6490:0 ../../gmock-gtest/gtest.h:6490:
error: no match for 'operator<<' in '* os << val'


Piotr Gorak

unread,
Feb 8, 2011, 4:37:20 AM2/8/11
to Google C++ Mocking Framework
Is your method "methodName" overloaded by any chance? What I found a
while ago was that:

EXPECT_CALL(mockObject, methodName(StrEq("123456")));

worked fine for me if the method was not overloaded. In the case of an
overloaded method I had to use:

EXPECT_CALL(mockObject, methodName(Matcher<string>(StrEq("123456"))));

to disambiguate parameter type. Let me know if this helped.

Piotr
Reply all
Reply to author
Forward
0 new messages