i have a setup like this:
class Base { ... };
class Derived : public Base {
bool variable; // only defined in Derived not in Base
};
class MockFoo : public Foo {
public:
MOCK_METHOD1(DoThis, void(Base* base));
};
What I want to do is this:
EXPECT_CALL(foo, DoThis(Field(&Derived::variable, true));
ie. the function is called with a (Base*) which is actually a
(Derived*).
Of this derived class i wish to match a field.
I have tried all sorts of combinations of pointee and
matchercast<Derived*>() without success.
I get errors like :
(DebugCommand is Derived From AbstractCommand and has fieldname
"onoff" of type bool
In function 'void testing::internal::ExplainMatchResultTo(const
testing::internal::FieldMatcher<Class, FieldType>&, const T&,
std::ostream*) [with Class = DebugCommand, FieldType = bool, T =
AbstractCommand*]':
../gmock-1.4.0/include/gmock/gmock-matchers.h:282: instantiated from
'void
testing::PolymorphicMatcher<Impl>::MonomorphicImpl<T>::ExplainMatchResultTo(T,
std::ostream*) const [with T = AbstractCommand*, Impl =
testing::internal::FieldMatcher<DebugCommand, bool>]'
DBUSCommunicator_unittest.cc:227: instantiated from here
../gmock-1.4.0/include/gmock/gmock-matchers.h:1555: error: invalid
conversion from 'AbstractCommand* const' to 'const DebugCommand*'
../gmock-1.4.0/include/gmock/gmock-matchers.h:1555: error:
initializing argument 2 of 'void
testing::internal::FieldMatcher<Class,
FieldType>::ExplainMatchResultTo(testing::internal::true_type, const
Class*, std::ostream*) const [with Class = DebugCommand, FieldType =
bool]'
make: *** [DBUSCommunicator_unittest.o] Fehler 1
Should EXPECT_CALL(foo, DoThis(Field(&Derived::variable, true)); not
work??
Documentaion says Field can also take pointers automatically.
Somebody have some ideas? Seems to be a const issue, but i dont
understand it fully.
Thanks,
Jonathan from Germany
Thanks,
Jonathan from Germany
To unsubscribe from this group, send email to googlemock+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
--
---
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/googlemock/900dd3dc-8cdc-40cd-ab22-5ea0806fe65f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.