why SetArgReferee raise a Warninig: no return statement

399 views
Skip to first unread message

Yongbo Zou

unread,
Jun 17, 2013, 5:51:24 AM6/17/13
to googl...@googlegroups.com
When compiled, it raises a warning: no return statement

class ncACSDBMock: public ncIACSDB
{
        MOCK_METHOD2(GetCustomPerm, bool(const dbCustomPermInfo&, dbCustomPermInfo&));
}


TEST_F (ut_ncACSProcessor, IsGetCustomPermInfosWorks)
{
       EXPECT_CALL(*_acsdbMock, GetCustomPerm (_,_))
.WillOnce(SetArgReferee<1>(info));
}

Here are the details:

In file included from /home/platform/Deps/gmock/include/gmock/gmock.h:63:0,
                 from ncACSProcessorUT.cpp:15:
/home/platform/Deps/gmock/include/gmock/gmock-more-actions.h: ‘typename testing::internal::Function<F>::Result testing::SetArgRefereeActionP<k, value_type>::gmock_Impl<F>::gmock_PerformImpl(const args_type&, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, arg9_type) const [with arg0_type = const dbCustomPermInfo&, arg1_type = dbCustomPermInfo&, 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, F = bool(const dbCustomPermInfo&, dbCustomPermInfo&), int k = 1, value_type = dbCustomPermInfo, typename testing::internal::Function<F>::Result = bool, testing::SetArgRefereeActionP<k, value_type>::gmock_Impl<F>::args_type = std::tr1::tuple<const dbCustomPermInfo&, dbCustomPermInfo&>]’:
/home/platform/Deps/gmock/include/gmock/gmock-generated-actions.h:665:23:from ‘static Result testing::internal::ActionHelper<Result, Impl>::Perform(Impl*, const std::tr1::tuple<_U1, _U2>&) [with A0 = const dbCustomPermInfo&, A1 = dbCustomPermInfo&, Result = bool, Impl = testing::SetArgRefereeActionP<1, dbCustomPermInfo>::gmock_Impl<bool(const dbCustomPermInfo&, dbCustomPermInfo&)>]’
/home/platform/Deps/gmock/include/gmock/gmock-more-actions.h:170:1:from ‘testing::SetArgRefereeActionP<k, value_type>::gmock_Impl<F>::return_type testing::SetArgRefereeActionP<k, value_type>::gmock_Impl<F>::Perform(const args_type&) [with F = bool(const dbCustomPermInfo&, dbCustomPermInfo&), int k = 1, value_type = dbCustomPermInfo, testing::SetArgRefereeActionP<k, value_type>::gmock_Impl<F>::return_type = bool, testing::SetArgRefereeActionP<k, value_type>::gmock_Impl<F>::args_type = std::tr1::tuple<const dbCustomPermInfo&, dbCustomPermInfo&>]’
ncACSProcessorUT.cpp:359:1:
/home/platform/Deps/gmock/include/gmock/gmock-more-actions.h:178:1:  no return statement[-Wreturn-type]

Can someone tell me why?

Gregor Jehle

unread,
Jun 18, 2013, 3:36:34 AM6/18/13
to googl...@googlegroups.com
On Mon, Jun 17, 2013 at 11:51 AM, Yongbo Zou <yongb...@gmail.com> wrote:
> When compiled, it raises a warning: no return statement

It does so for a perfectly good reason.
The method you're trying to mock has a bool return value but you're
not returning anything from your mocked method.

Try something like this:
.WillOnce(DoAll(SetArgReferee<1>(info),Return(true)));

--
Best regards,
Gregor
Reply all
Reply to author
Forward
0 new messages