谷歌模拟EXPECT_CALL返回值

时间:2015-08-25 12:34:37

标签: c++ googletest googlemock

我在C中有以下代码想要使用谷歌测试框架进行测试:

src

我想测试文件a.h void getValue(int age, int * value); a.c #include <a.h> void getValue(int age, int * value) { value[0] = 0; value[1] = 1; } b.c #include <a.h> void formValue() { int value[2]; getValue(age, value); /* the code to handle the value[] array */ /* for() */ } 中的函数void formValue(),因此我为b创建了以下模拟:     // AFileMock.hh     #包括     #include“a.h”

void getValue(int age, int * value)

然后在测试文件中我想调用模拟函数class AFileMock { public: AFileMock(); ~AFileMock(); MOCK_METHOD1(getValue, void(int, int *)); }; 并返回getValue部分的值,但是当调用a时如何返回void getValue(int age, int * value)的即将到来的参数模拟功能?

value array

所以在这种情况下,当调用mock函数时,如何返回数组的值?

1 个答案:

答案 0 :(得分:1)

我无法理解您的示例代码,a.c甚至无法编译。但我想你要找的答案是Gmock Actions。提供了rich set个。