Why compile error in SetArgReferee

1,944 views
Skip to first unread message

jeromy

unread,
Oct 24, 2011, 9:51:13 PM10/24/11
to Google C++ Mocking Framework
Hi all,

I've encounter an error in using SetArgReferee, any
suggestions?

Thanks in advance!

std::vector<IFilter::QueryResult> result;
//IFilter::QueryResult r;
//r.t = IFilter::SERVICE_SVC;
//result.push_back(r);
EXPECT_CALL(m_filter,
QueryDownlinkRequired(_,_)).Times(1).WillOnce(SetArgReferee<1>(result));


The error in compiling:

f:\3rdlibs\gmock\include\gmock\gmock-more-actions.h(175) : error
C2118: negative subscript
1> f:\3rdlibs\gmock\include\gmock\gmock-generated-
actions.h(665) : see reference to function template instantiation
'unsigned long
testing::SetArgRefereeActionP<k,value_type>::gmock_Impl<F>::gmock_PerformImpl<A0,A1,testing::internal::ExcessiveArg,testing::internal::ExcessiveArg,testing::internal::ExcessiveArg,testing::internal::ExcessiveArg,testing::internal::ExcessiveArg,testing::internal::ExcessiveArg,testing::internal::ExcessiveArg,testing::internal::ExcessiveArg>(const
std::tr1::tuple<T0,T1>
&,arg0_type,arg1_type,arg2_type,arg3_type,arg4_type,arg5_type,arg6_type,arg7_type,arg8_type,arg9_type)
const' being compiled
1> with
1> [
1> k=1,
1> value_type=std::vector<IFilter::QueryResult>,
1> F=unsigned long
(IFilter::QUERY_TYPE,IFilter::QueryResult *),
1> A0=IFilter::QUERY_TYPE,
1> A1=IFilter::QueryResult *,
1> T0=IFilter::QUERY_TYPE,
1> T1=IFilter::QueryResult *,
1> arg0_type=IFilter::QUERY_TYPE,
1> arg1_type=IFilter::QueryResult *,
1> arg2_type=testing::internal::ExcessiveArg,
1> arg3_type=testing::internal::ExcessiveArg,
1> arg4_type=testing::internal::ExcessiveArg,
1> arg5_type=testing::internal::ExcessiveArg,
1> arg6_type=testing::internal::ExcessiveArg,
1> arg7_type=testing::internal::ExcessiveArg,
1> arg8_type=testing::internal::ExcessiveArg,
1> arg9_type=testing::internal::ExcessiveArg
1> ]
1> f:\3rdlibs\gmock\include\gmock\gmock-more-actions.h(170) :
see reference to function template instantiation 'Result
testing::internal::ActionHelper<Result,Impl>::Perform<A1,A2>(Impl
*,const std::tr1::tuple<T0,T1> &)' being compiled
1> with
1> [
1> Result=unsigned long,
1>
Impl=testing::SetArgRefereeActionP<1,std::vector<IFilter::QueryResult>>::gmock_Impl<unsigned
long (IFilter::QUERY_TYPE,IFilter::QueryResult *)>,
1> A1=IFilter::QUERY_TYPE,
1> A2=IFilter::QueryResult *,
1> T0=IFilter::QUERY_TYPE,
1> T1=IFilter::QueryResult *
1> ]
1> f:\3rdlibs\gmock\include\gmock\gmock-more-actions.h(170) :
while compiling class template member function 'unsigned long
testing::SetArgRefereeActionP<k,value_type>::gmock_Impl<F>::Perform(const
std::tr1::tuple<T0,T1> &)'
1> with
1> [
1> k=1,
1> value_type=std::vector<IFilter::QueryResult>,
1> F=unsigned long
(IFilter::QUERY_TYPE,IFilter::QueryResult *),
1> T0=IFilter::QUERY_TYPE,
1> T1=IFilter::QueryResult *
1> ]
1> f:\3rdlibs\gmock\include\gmock\gmock-more-actions.h(170) :
see reference to class template instantiation
'testing::SetArgRefereeActionP<k,value_type>::gmock_Impl<F>' being
compiled
1> with
1> [
1> k=1,
1> value_type=std::vector<IFilter::QueryResult>,
1> F=unsigned long
(IFilter::QUERY_TYPE,IFilter::QueryResult *)
1> ]
1> e:\t28l10n\westlake\src\qoscontrol\unittest\main.cc(36) :
see reference to function template instantiation
'testing::SetArgRefereeActionP<k,value_type>::operator
testing::Action<F>(void) const<F>' being compiled
1> with
1> [
1> k=1,
1> value_type=std::vector<IFilter::QueryResult>,
1> F=unsigned long
(IFilter::QUERY_TYPE,IFilter::QueryResult *)
1> ]
1>f:\3rdlibs\gmock\include\gmock\gmock-more-actions.h(177) : error
C2440: '=' : cannot convert from 'const std::vector<_Ty>' to
'IFilter::QueryResult *const '
1> with
1> [
1> _Ty=IFilter::QueryResult
1> ]
1> No user-defined-conversion operator available that can
perform this conversion, or the operator cannot be called

Greg Miller

unread,
Oct 25, 2011, 9:46:15 AM10/25/11
to jeromy, Google C++ Mocking Framework
From the compiler output it looks like the second argument to your QueryDownlinkRequired() function is a pointer, not a reference. If that's true, then you want to be using SetArgPointee() rather than SetArgReferee(). The latter is for when the argument is a reference.

HTH,

G~

Bhavya S G

unread,
Dec 3, 2014, 6:15:17 AM12/3/14
to googl...@googlegroups.com
Hi,

Was this issue fixed?

regards
Reply all
Reply to author
Forward
0 new messages