You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Possible Enhancement:
template <size_t N, typename A, bool kIsProto>
class SetArgumentRefereeAction {
public:
// Constructs an action that sets the variable pointed to by the
// N-th function argument to 'value'.
explicit SetArgumentRefereeAction(const A& value) : value_(value) {}
template <typename Result, typename ArgumentTuple>
void Perform(const ArgumentTuple& args) const {
CompileAssertTypesEqual<void, Result>();
::std::tr1::get<N>(args) = value_;
}
private:
const A value_;
};
template <size_t N, typename T>
PolymorphicAction<
internal::SetArgumentRefereeAction<
N, T, internal::IsAProtocolMessage<T>::value> >
SetArgumentReferee(const T& x) {
return MakePolymorphicAction(internal::SetArgumentRefereeAction<
N, T, internal::IsAProtocolMessage<T>::value>(x));
}
with following test case:
#include <gmock/gmock.h>
#include <memory>
using testing::_;
using testing::Return;
using testing::Action;
using testing::ActionInterface;
using testing::MakeAction;
using testing::DoAll;
using testing::SetArgumentPointee;
using testing::SetArgumentReferee;
using testing::internal::Function;
class Foo
{
public:
virtual bool func(int*) = 0;
virtual bool funcRef(int&) = 0;
};
class MockFoo : public Foo
{
public:
MOCK_METHOD1(func, bool(int*));
MOCK_METHOD1(funcRef, bool(int&));
};
class Bar
{
public:
explicit Bar(Foo* pFoo) : m_pFoo(pFoo)
{
}
int CallIt()
{
int i = 0;
m_pFoo->func(&i);
return i;
}
int CallItRef()
{
int i = 0;
m_pFoo->funcRef(i);
return i;
}
Foo* m_pFoo;
};
TEST(Testitout, argpointee)
{
MockFoo foo;
EXPECT_CALL(foo, func(_))
.WillOnce(DoAll(SetArgumentPointee<0>(5),Return(true)));
EXPECT_CALL(foo, funcRef(_))
.WillOnce(DoAll(SetArgumentReferee<0>(5),Return(true)));
Bar bar(&foo);
EXPECT_EQ(5, bar.CallIt());
EXPECT_EQ(5, bar.CallItRef());
}
int main(int argc, char **argv) {
std::cout << "Running main() from gtest_main.cc\n";
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Original issue reported on code.google.com by ecurbks...@gmail.com on 25 Dec 2008 at 6:02
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
ecurbks...@gmail.com
on 25 Dec 2008 at 6:02The text was updated successfully, but these errors were encountered: