mikeb
unread,Jan 21, 2011, 7:13:47 PM1/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google C++ Mocking Framework
Hi,
I'm attempting to use SetArgumentPointee to change the value of an
argument when a method is called:
<code>
const string ip = "10.153.2.1";
string cmd = "configuration";
string responseIn;
string responseOut = "12345678901234567890";
string error = "";
int retInt = 0;
EXPECT_CALL(mdaf, sendCommand(ip, cmd, responseIn,
error)).WillOnce(DoAll(SetArgumentPointee<2>(responseOut),
Return(retInt)));
</code>
However, I am getting a compiler or linker error:
<code>
GTestArrayCLICommand.cpp:97: warning: deprecated conversion from
string constant to 'char*'
In file included from /usr/local/include/gmock/gmock.h:58,
from GTestArrayCLICommand.cpp:3:
/usr/local/include/gmock/gmock-actions.h: In member function 'void
testing::internal::SetArgumentPointeeAction<N, A,
kIsProto>::Perform(const ArgumentTuple&) const [with Result = void,
ArgumentTuple = std::tr1::tuple<const std::string&, std::string&,
std::string&, std::string&>, long unsigned int N = 2ul, A =
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, bool kIsProto = false]':
/usr/local/include/gmock/gmock-actions.h:380: instantiated from
'typename testing::internal::Function<F>::Result
testing::PolymorphicAction<Impl>::MonomorphicImpl<F>::Perform(const
typename testing::internal::Function<F>::ArgumentTuple&) [with F =
void(const std::string&, std::string&, std::string&, std::string&),
Impl = testing::internal::SetArgumentPointeeAction<2ul,
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, false>]'
GTestArrayCLICommand.cpp:105: instantiated from here
/usr/local/include/gmock/gmock-actions.h:684: error: no match for
'operator*' in '*std::tr1::get [with int __i = 2, _Elements = const
std::string&, std::string&, std::string&, std::string&](((const
std::tr1::tuple<const std::string&, std::string&, std::string&,
std::string&>&)((const std::tr1::tuple<const std::string&,
std::string&, std::string&, std::string&>*)args)))'
</code>
I am sortof assuming this is due to the fact that responseOut is not a
pointer arg. If this is the case, is there a way to influence a non-
pointer arg?
Magnificent test/mock framework implementation, by the way. I switched
over to it from boost::test in a very short period of time and have
introduced it to the rest of my team.
...Mike