[Mockpp-devel] Virtual function
Brought to you by:
ewald-arnold
|
From: Patrick F. <pat...@gm...> - 2006-06-08 20:06:52
|
Hi,
I have the following code :
class A {
public:
void test()
{
// do some stuff
}
}
class A_mock : public A, public MOCKPP_NS::MockObject
{
public:
A_mock() : ex("counter", 0){};
void test(
ec.inc();
);
ExpectationCounter ex;
}
class B
{
public :
A* m_A;
void f1()
{
m_A->test();
}
}
int main ()
{
A_mock* mock = new A_mock();
mock->ex.setExpected(1);
B varB;
varB.m_A = mock;
mock->verify();
}
Since the test function in the base class A is NOT virtual, polymorphism
don't work. To work, I have to declarw A::test virtual. My problem,
is that in my design that function (A::test) should not be a virtual one.
I find it akward to declare it virtual only for testing. Any hint on doing
that kind of test with mockpp? I don't want to modify the B class.
Thank you and great work on mockpp
Patrick
|