Skip to content

一个TEST_F用例中写两个成员函数的EMOCK会报内存错误 #47

Description

@bojan-97
// 待测成员函数
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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions