Contains(StrEq()) not working as expected

318 views
Skip to first unread message

Phil Dibowitz

unread,
Aug 25, 2009, 2:05:11 PM8/25/09
to googletes...@googlegroups.com
I have some test code using gtest and gmock which does:

EXPECT_CALL(somemock, SomeCall(_,_,Contains(StrEq("foo"))));

Where the 3rd argument to SomeCall() should be a std::vector<const char*> who
only has 1 element which is "foo".

Unfortunately, that won't compile for me and gives me tons of templating
"no match" errors.

However, I *was* able to do:

EXPECT_CALL(somemock, SomeCall(_,_,ElementsAre(StrEq("foo"))));

And that works exactly as expected. I was also able to write a matcher that
does

return(!strcmp(arg[0], str))

Which also worked....

So am I misunderstanding how Contains() works, or have I stumbled into a bug?

--
Phil Dibowitz

signature.asc

Zhanyong Wan (λx.x x)

unread,
Aug 25, 2009, 3:00:50 PM8/25/09
to Phil Dibowitz, googletes...@googlegroups.com
Hi Phil,

Which version of gmock are you using?

Contains(matcher) is added in revision 164,
http://code.google.com/p/googlemock/source/detail?r=164&path=/trunk/include/gmock/gmock-matchers.h

Therefore it won't work unless you are using a newer revision from the
SVN trunk. It will be included in the next release of gmock. Thanks,

> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFKlCfXLBV88STLCDkRAjFkAJ9EI43BoflbE35kkBljBn7HaJZurgCeJMwR
> d+JuCv/TSBgusZf8UvnMJ2k=
> =Zt5N
> -----END PGP SIGNATURE-----
>
>

--
Zhanyong

Phil Dibowitz

unread,
Aug 25, 2009, 4:13:08 PM8/25/09
to Zhanyong Wan (λx.x x), googletes...@googlegroups.com
On Tue, Aug 25, 2009 at 12:00:50PM -0700, Zhanyong Wan (λx.x x) wrote:
> Hi Phil,
>
> Which version of gmock are you using?
>
> Contains(matcher) is added in revision 164,
> http://code.google.com/p/googlemock/source/detail?r=164&path=/trunk/include/gmock/gmock-matchers.h
>
> Therefore it won't work unless you are using a newer revision from the
> SVN trunk. It will be included in the next release of gmock. Thanks,

Aha! Thanks. =)

--
Phil Dibowitz
Site Reliability Engineer - Spam, Abuse, and Delivery
Google - Zurich, Switzerland
Unexpected attachment? http://www/~fixxxer/faq.html

signature.asc
Reply all
Reply to author
Forward
0 new messages