Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bojan-97 opened this issue Dec 2, 2024 · 0 comments
Open

Comments

@bojan-97
Copy link

bojan-97 commented Dec 2, 2024

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

@bojan-97 bojan-97 changed the title 一个TEST_F用例中写两个EMOCK会报内存错误 一个TEST_F用例中写两个成员函数的EMOCK会报内存错误 Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant