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

Using a named scope mock results in memory leak unless global scope is used for clear() #1764

Open
icvidal opened this issue Nov 9, 2023 · 0 comments

Comments

@icvidal
Copy link

icvidal commented Nov 9, 2023

I can't find if this behavior is documented/designed: when using a mock with a custom scope, it requires using mock().clear() instead of mock("<SCOPE NAME>").clear()

The following example illustrates the issue:

#include <CppUTest/TestHarness.h>
#include <CppUTestExt/MockSupport.h>

TEST_GROUP(NamedMockFailure) {
};


TEST(NamedMockFailure, TriggerFailure) {
    mock("NamedMockFailure").enable();
    mock("NamedMockFailure").checkExpectations();
    mock("NamedMockFailure").clear();
}

TEST(NamedMockFailure, SeemsToWork) {
    mock("NamedMockFailure").enable();
    mock("NamedMockFailure").checkExpectations();
    mock("").clear();
}

Can anybody confirm if this behavior is expected? If so, can you point me to it's documentation?
Thanks!

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