CppUMock return value

446 views
Skip to first unread message

BGill

unread,
May 8, 2012, 2:57:09 AM5/8/12
to cpputest
Is there any way to get return value as stringList in CppUMock?

I have function called getList( ) that returns stringList.

fun stringList getList()
{
return strList << "1" << "2";
}
I can get string return value as following:-
const char * str =
mock("MyList").actualCall("getList").returnValue().getStringValue();

I want to set expect return value as stringList as parameter in
andReturnValue ();

mock("MyList").expectOneCall("getList").andReturnValue(stringList)

Terry Yin

unread,
May 9, 2012, 10:35:29 AM5/9/12
to cppu...@googlegroups.com
Hi,

May I ask what is a stringList?

br, Terry
--
-terry
-------------------------
Blog: http://terryyin.blogbus.com/
twitter: http://twitter.com/terryyin

Bas Vodde

unread,
May 12, 2012, 2:23:02 AM5/12/12
to cppu...@googlegroups.com

Hiya,

Ouch, sorry for the slow response.

The best way to do this is to use the PointerValue and make sure that your object doesn't go out of scope.

So, it would be something:

mock("MyList").expectOneCall("getList").andReturnValue(&stringList);

Then, you do getPointerValue in the function and cast it to a stringList pointer.

Hope that helps?

Thanks,

Bas

ps. It works this way because we chose to stay away from templates in CppUTest...
Reply all
Reply to author
Forward
0 new messages