Re: [googlemock: 1869] Trouble compiling using the 'Args<>' template

472 views
Skip to first unread message

Corey Kosak

unread,
Jun 5, 2013, 2:57:07 PM6/5/13
to gmock...@google.com, googl...@googlegroups.com, joeb...@gmail.com
Args<1> is a selector for a one-dimensional tuple, so your code can be made to compile if it looks like this:

  EXPECT_CALL(mocker, doSomethingElse(_, _)).Times(Exactly(1))
          .With(Args<1>(Eq(tr1::make_tuple(10))));

I admit that looks a little awkward; I' don't know whether or not there's a better way.


On Wednesday, June 5, 2013 1:12:03 PM UTC-4, Joe Boese wrote:
Hey Guys,
I'm having a heck of a time figuring out what is wrong with the following line:

EXPECT_CALL(mocker, doSomethingElse(_, _)).Times(Exactly(1)).With(Args<1>(Eq(10)));

My class definition is as follows:

class MockBase : public Base {
 public:
  MOCK_METHOD2(doSomething, void(int x, char y));
  MOCK_METHOD2(doSomethingElse, void(const char* value, int len));
};

This fails to compile with:
googlemock/gmock-1.6.0/include/gmock/gmock-matchers.h:738: error: no match for ‘operator==’ in ‘lhs == ((const testing::internal::EqMatcher<int>::Impl<const std::tr1::tuple<int>&>*)this)->testing::internal::EqMatcher<int>::Impl<const std::tr1::tuple<int>&>::rhs_’

I expect that this would end up evaluating to "Check that the second argument in the call to doSomethingElse() is equal to 10.  I realize there are other simpler ways to express what I'm doing here; however I'm building up to a more complicated With/AllOf call.

Thanks
Joe

--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Mocking Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googlemock+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joe Boese

unread,
Jun 5, 2013, 3:00:39 PM6/5/13
to googl...@googlegroups.com, gmock...@google.com, joeb...@gmail.com
Ahh I see!  Thank you very much.

Joe
To unsubscribe from this group and stop receiving emails from it, send an email to googlemock+...@googlegroups.com.

Zhanyong Wan (λx.x x)

unread,
Jun 5, 2013, 3:49:03 PM6/5/13
to Joe Boese, Google C++ Mocking Framework
On Wed, Jun 5, 2013 at 10:12 AM, Joe Boese <joeb...@gmail.com> wrote:
Hey Guys,
I'm having a heck of a time figuring out what is wrong with the following line:

EXPECT_CALL(mocker, doSomethingElse(_, _)).Times(Exactly(1)).With(Args<1>(Eq(10)));

You are using a matcher where an action is expected.  You should put matchers in the function argument list instead:

  EXPECT_CALL(mocker, doSomethingElse(_, Eq(10))).Times(Exactly(1));

Also, Eq() is implied, and so is Times(Exactly(1)), so the above is equivalent to

  EXPECT_CALL(mocker, doSomethingElse(_, 10));

 
 

My class definition is as follows:

class MockBase : public Base {
 public:
  MOCK_METHOD2(doSomething, void(int x, char y));
  MOCK_METHOD2(doSomethingElse, void(const char* value, int len));
};

This fails to compile with:
googlemock/gmock-1.6.0/include/gmock/gmock-matchers.h:738: error: no match for ‘operator==’ in ‘lhs == ((const testing::internal::EqMatcher<int>::Impl<const std::tr1::tuple<int>&>*)this)->testing::internal::EqMatcher<int>::Impl<const std::tr1::tuple<int>&>::rhs_’

I expect that this would end up evaluating to "Check that the second argument in the call to doSomethingElse() is equal to 10.  I realize there are other simpler ways to express what I'm doing here; however I'm building up to a more complicated With/AllOf call.

Thanks
Joe

--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Mocking Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googlemock+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Zhanyong
Reply all
Reply to author
Forward
0 new messages