SetArgReferee gives me C2118: negative subscript error

845 views
Skip to first unread message

Bhavya S G

unread,
Dec 3, 2014, 6:46:49 AM12/3/14
to googl...@googlegroups.com
QList<DomainObjects::Fault> faults; 
createFault(faults); 

EXPECT_CALL(*mockService, readBitEncodedFaults(_,_)).WillOnce(SetArgReferee<1>(faults))                                                       .WillOnce(Return(DomainObjects::ErrorStatus::None)); 

Syntax: 

MOCK_METHOD2(readBitEncodedFaults, DomainObjects::CommsError(QList<DomainObjects::Fault>&,                                                                QList<DomainObjects::Fault>)); 

gmock-more-actions.h(175) : error C2118: negative subscript 
        C:\ScanTool\CheckII_latest\gmock\include\gmock/gmock-generated-actions.h(664) : see reference to function template instantiation 'DomainObjects::CommsError 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::tuple<<unnamed-symbol>,_V0_t> &,arg0_type,arg1_type,arg2_type,arg3_type,arg4_type,arg5_type,arg6_type,arg7_type,arg8_type,arg9_type) const' being compiled 
        with 
        [ 
            k=1, 
            value_type=QList<DomainObjects::Fault> *, 
            F=DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>), 
            A0=QList<DomainObjects::Fault> &, 
            A1=QList<DomainObjects::Fault>, 
            <unnamed-symbol>=QList<DomainObjects::Fault> &, 
            _V0_t=QList<DomainObjects::Fault>, 
            arg0_type=QList<DomainObjects::Fault> &, 
            arg1_type=QList<DomainObjects::Fault>, 
            arg2_type=testing::internal::ExcessiveArg, 
            arg3_type=testing::internal::ExcessiveArg, 
            arg4_type=testing::internal::ExcessiveArg, 
            arg5_type=testing::internal::ExcessiveArg, 
            arg6_type=testing::internal::ExcessiveArg, 
            arg7_type=testing::internal::ExcessiveArg, 
            arg8_type=testing::internal::ExcessiveArg, 
            arg9_type=testing::internal::ExcessiveArg 
        ] 
        C:\ScanTool\CheckII_latest\gmock\include\gmock/gmock-generated-actions.h(664) : see reference to function template instantiation 'DomainObjects::CommsError 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::tuple<<unnamed-symbol>,_V0_t> &,arg0_type,arg1_type,arg2_type,arg3_type,arg4_type,arg5_type,arg6_type,arg7_type,arg8_type,arg9_type) const' being compiled 
        with 
        [ 
            k=1, 
            value_type=QList<DomainObjects::Fault> *, 
            F=DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>), 
            A0=QList<DomainObjects::Fault> &, 
            A1=QList<DomainObjects::Fault>, 
            <unnamed-symbol>=QList<DomainObjects::Fault> &, 
            _V0_t=QList<DomainObjects::Fault>, 
            arg0_type=QList<DomainObjects::Fault> &, 
            arg1_type=QList<DomainObjects::Fault>, 
            arg2_type=testing::internal::ExcessiveArg, 
            arg3_type=testing::internal::ExcessiveArg, 
            arg4_type=testing::internal::ExcessiveArg, 
            arg5_type=testing::internal::ExcessiveArg, 
            arg6_type=testing::internal::ExcessiveArg, 
            arg7_type=testing::internal::ExcessiveArg, 
            arg8_type=testing::internal::ExcessiveArg, 
            arg9_type=testing::internal::ExcessiveArg 
        ] 
        C:\ScanTool\CheckII_latest\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::tuple<<unnamed-symbol>,_V0_t> &)' being compiled 
        with 
        [ 
            Result=DomainObjects::CommsError, 
            Impl=testing::SetArgRefereeActionP<1,QList<DomainObjects::Fault> *>::gmock_Impl<DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>)>, 
            A1=QList<DomainObjects::Fault> &, 
            A2=QList<DomainObjects::Fault>, 
            <unnamed-symbol>=QList<DomainObjects::Fault> &, 
            _V0_t=QList<DomainObjects::Fault> 
        ] 
        C:\ScanTool\CheckII_latest\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::tuple<<unnamed-symbol>,_V0_t> &)' being compiled 
        with 
        [ 
            Result=DomainObjects::CommsError, 
            Impl=testing::SetArgRefereeActionP<1,QList<DomainObjects::Fault> *>::gmock_Impl<DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>)>, 
            A1=QList<DomainObjects::Fault> &, 
            A2=QList<DomainObjects::Fault>, 
            <unnamed-symbol>=QList<DomainObjects::Fault> &, 
            _V0_t=QList<DomainObjects::Fault> 
        ] 
        C:\ScanTool\CheckII_latest\gmock\include\gmock/gmock-more-actions.h(170) : while compiling class template member function 'DomainObjects::CommsError testing::SetArgRefereeActionP<k,value_type>::gmock_Impl<F>::Perform(const std::tuple<<unnamed-symbol>,_V0_t> &)' 
        with 
        [ 
            k=1, 
            value_type=QList<DomainObjects::Fault> *, 
            F=DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>), 
            <unnamed-symbol>=QList<DomainObjects::Fault> &, 
            _V0_t=QList<DomainObjects::Fault> 
        ] 
        C:\ScanTool\CheckII_latest\gmock\include\gmock/gmock-more-actions.h(170) : see reference to class template instantiation 'testing::SetArgRefereeActionP<k,value_type>::gmock_Impl<F>' being compiled 
        with 
        [ 
            k=1, 
            value_type=QList<DomainObjects::Fault> *, 
            F=DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>) 
        ] 
        ..\..\..\ScanTool\CheckII_latest\ApplicationLayerTests\Faultcodemodelh8tests.cpp(39) : see reference to function template instantiation 'testing::SetArgRefereeActionP<k,value_type>::operator testing::Action<F>(void) const<F>' being compiled 
        with 
        [ 
            k=1, 
            value_type=QList<DomainObjects::Fault> *, 
            F=DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>) 
        ] 
        ..\..\..\ScanTool\CheckII_latest\ApplicationLayerTests\Faultcodemodelh8tests.cpp(40) : see reference to function template instantiation 'testing::SetArgRefereeActionP<k,value_type>::operator testing::Action<F>(void) const<F>' being compiled 
        with 
        [ 
            k=1, 
            value_type=QList<DomainObjects::Fault> *, 
            F=DomainObjects::CommsError (QList<DomainObjects::Fault> &,QList<DomainObjects::Fault>) 
        ] 
C:\ScanTool\CheckII_latest\gmock\include\gmock/gmock-more-actions.h(177) : error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const QList<T>' (or there is no acceptable conversion) 
        with 
        [ 
            T=DomainObjects::Fault 
        ] 
        c:\qt\qt5.2.1\5.2.1\msvc2012_64\include\qtcore\qlist.h(117): could be 'QList<T> &QList<T>::operator =(const QList<T> &)' 
        with 
        [ 
            T=DomainObjects::Fault 
        ] 
        c:\qt\qt5.2.1\5.2.1\msvc2012_64\include\qtcore\qlist.h(120): or       'QList<T> &QList<T>::operator =(QList<T> &&)' 
        with 
        [ 
            T=DomainObjects::Fault 
        ] 
        while trying to match the argument list '(const QList<T>, QList<T> )' 
        with 
        [ 
            T=DomainObjects::Fault 
        ] 

Samuel Benzaquen

unread,
Dec 3, 2014, 12:30:37 PM12/3/14
to Bhavya S G, googl...@googlegroups.com
On Wed, Dec 3, 2014 at 6:46 AM, Bhavya S G <bhavya...@gmail.com> wrote:
QList<DomainObjects::Fault> faults; 
createFault(faults); 

EXPECT_CALL(*mockService, readBitEncodedFaults(_,_)).WillOnce(SetArgReferee<1>(faults))                                                       .WillOnce(Return(DomainObjects::ErrorStatus::None)); 

Syntax: 

MOCK_METHOD2(readBitEncodedFaults, DomainObjects::CommsError(QList<DomainObjects::Fault>&,                                                                QList<DomainObjects::Fault>))

This is failing a compile time assertion:

  // Ensures that argument #k is a reference.  If you get a compiler
  // error on the next line, you are using SetArgReferee<k>(value) in
  // a mock function whose k-th (0-based) argument is not a reference.
  GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
                        SetArgReferee_must_be_used_with_a_reference_argument);

The problem is that argument 1 (0-based) is not a reference.
I wonder why the compiler is not showing SetArgReferee_must_be_used_with_a_reference_argument in the error.

Hope this helps,
_Sam
 

--

---
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/3fcfb539-c93b-4834-b35a-d83e6f1fad28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages