sinojelly / mockcpp

Two C/C++ testing tools, mockcpp and testngpp.
Apache License 2.0
67 stars 42 forks source link

outbound does not work when mock a member fucntion of a class with a output parameter #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I want to use mockcpp to mock a member function of a class. The member function 
has a output parameter. I want to assign the value of the output parameter. but 
it doesnot work. Compilation can complete successfullly. But the output 
parameter is not assigned the mocked value. My code is below:

class Parameter
{
public:
int a;
Parameter() {a=0;}
}

class MyClass
{
public:
virtual void func(Parameter &b) { b.a = 1;}
}

Parameter p;
p.a = 2;
MockObject<MyClass> mocker;
MOCK_METHOD(mocker,  func ).stubs().with(outBound(p));

When MyClass::func is invoked, the output parameter p.a is not 2, but 1.

Original issue reported on code.google.com by njup...@gmail.com on 14 Aug 2014 at 2:52

GoogleCodeExporter commented 9 years ago
My operation system is linux and compiler is linux.

Original comment by njup...@gmail.com on 18 Aug 2014 at 3:44

git45016683 commented 2 years ago

hi, can mockcpp mock nonvirtual member function? like your sample code , if func is a nonvirtual member function, can it work?