jeudi 24 septembre 2015

Using Gtest is possible to return value of invoked function

Is it possible to return value which will be got after calling invoke? For example,

int foo(int a, int b) {return a+b;}

class FooMock {
  MOCK_METHOD0(MockMethod, int(int a, int b));
}

void bar()
{
  FooMock mock;
  EXPECT_CALL(mock,MockMethod(_,_)).WillRepeatedly(DoAll(Invoke(foo),Return(result_of_foo)));
//Firstly foo should be invoked, secondly, result of function should be returned as result of MockMethod
}

How make result_of_foo be equal to result of function foo? Or does exist another way to return the calculated value?

Aucun commentaire:

Enregistrer un commentaire