Open GoogleCodeExporter opened 9 years ago
This can be done by delegating the operator call to a named method. I'll write
up a
recipe for this soon.
Original comment by zhanyong...@gmail.com
on 23 Jun 2009 at 4:53
I realise delegation can be used as a workaround. However, consider an
interface with
one (or more) pure virtual operators. How can one define a mock that can be
instantiated?
Original comment by organic...@googlemail.com
on 23 Jun 2009 at 8:12
Example:
class IAm {
public:
virtual ~IAm() {}
virtual bool operator==(const IAm&) = 0;
};
class MockIAm : public IAm {
public:
MOCK_METHOD1(Equals, bool(const IAm&));
virtual bool operator==(const IAm& rhs) { return Equals(rhs); }
};
MockIAm can be instantiated. You should set expectations on Equals()
instead of operator==:
MockIAm x;
EXPECT_CALL(x, Equals(_));
BTW, for questions and feature requests instead of bug reports, it
works better to use the discussion group. (Very few people are paying
attention to the comments in the issue tracker, so you may wait for a
long time to get an answer if you post your questions here.)
Original comment by zhanyong...@gmail.com
on 9 Aug 2009 at 1:46
I shall add a recipe to the cookbook.
Original comment by w...@google.com
on 6 Mar 2010 at 5:53
Hi,
Is there any way to mocking a templatized functor??
Original comment by rodrigue...@gmail.com
on 8 Jan 2015 at 8:41
Original issue reported on code.google.com by
organic...@googlemail.com
on 23 Jun 2009 at 2:26