// 待测成员函数
class Foo
{
public:
void bar1(int) {}
int bar3() {return 0;}
};
// 指定调用的mock函数
void EMOCK_API mock_bar1(Foo* obj, int) {
// ...
}
class FooTest : public ::testing::Test {
};
TEST_F(FooTest, example) {
// 测试时,像下面这样就可以mock
EMOCK(&Foo::bar1)
.stubs()
.will(invoke(mock_bar1)); // 指定调用自定义的函数而不是指定返回值
EMOCK(&Foo::bar3)
.stubs()
.will(returnValue(1));
}
运行上面的用例,报错如下:
Testing started at 17:08 ...
unknown file: error: SEH exception with code 0xc0000005 thrown in auxiliary test code (environments or event listeners).
Stack trace:
运行上面的用例,报错如下:
Testing started at 17:08 ...
unknown file: error: SEH exception with code 0xc0000005 thrown in auxiliary test code (environments or event listeners).
Stack trace: