Hi,
I'm trying to mock a method call where I want to check a specific property of the passed object.
struct MockExporter : public Exporter
{
MOCK_METHOD1(saveChannel, void(ChannelPtr));
}
with
class Channel
{
...
QString name() const { return _name; }
...
};
typedef std::shared_ptr<Channel> ChannelPtr;
Using this in an expectation like
EXPECT_CALL(*mockExporter, saveChannel(Property(&Channel::name, Eq("RainflowMatrixX_Test2"))));
results in the following compiler error
\gmock\gmock.h:6364: Fehler: C2664: 'bool testing::internal::PropertyMatcher<Class,PropertyType>::MatchAndExplainImpl(testing::internal::false_type,const Class &,testing::MatchResultListener *) const': Konvertierung des Parameters 2 von 'const ChannelPtr' in 'const Channel &' nicht m”glich
with
[
Class=Channel,
PropertyType=QString
]
Ursache: Konvertierung von 'const ChannelPtr' in 'const Channel' nicht m”glich
Kein benutzerdefinierter Konvertierungsoperator verf gbar, der diese Konvertierung durchf hren kann, oder der Operator kann nicht aufgerufen werden
D:\VirtualBox\Shared\Projekte\monalysis\3rd_party\testing\gmock/gmock.h(4961): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "bool testing::internal::PropertyMatcher<Class,PropertyType>::MatchAndExplain<T>(const T &,testing::MatchResultListener *) const".
with
[
Class=Channel,
PropertyType=QString,
T=ChannelPtr
]
D:\VirtualBox\Shared\Projekte\monalysis\3rd_party\testing\gmock/gmock.h(4960): Bei der Kompilierung der Klassen-template der bool testing::PolymorphicMatcher<Impl>::MonomorphicImpl<T>::MatchAndExplain(T,testing::MatchResultListener *) const-Memberfunktion
with
[
Impl=testing::internal::PropertyMatcher<Channel,QString>,
T=ChannelPtr
]
D:\VirtualBox\Shared\Projekte\monalysis\3rd_party\testing\gmock/gmock.h(4943): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "testing::PolymorphicMatcher<Impl>::MonomorphicImpl<T>".
with
[
Impl=testing::internal::PropertyMatcher<Channel,QString>,
T=ChannelPtr
]
.\FrequencyDistributionWorkflowTest.cpp(382): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template "testing::PolymorphicMatcher<Impl>::operator testing::Matcher<T>(void) const<A1>".
with
[
Impl=testing::internal::PropertyMatcher<Channel,QString>,
T=ChannelPtr,
A1=ChannelPtr
]
Sorry for being in german, rough translation is that the second argument of MatchAndExplainImpl cannot be converted from const ChannelPtr to const Channel&.
I'm stuck here having no clue how to solve it. Should the shared_ptr argument not be used just like a plain pointer as stated in the docs?
Thanks for any help.
Greets
An Ky