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

Fix undefined behavior using gMock #1159

Open
DanRStevens opened this issue Jul 9, 2024 · 0 comments
Open

Fix undefined behavior using gMock #1159

DanRStevens opened this issue Jul 9, 2024 · 0 comments

Comments

@DanRStevens
Copy link
Collaborator

DanRStevens commented Jul 9, 2024

https://google.github.io/googletest/gmock_for_dummies.html#expectation-ordering

Important note: gMock requires expectations to be set before the mock functions are called, otherwise the behavior is undefined. Do not alternate between calls to EXPECT_CALL() and calls to the mock functions, and do not set any expectations on a mock after passing the mock to an API.

We have code with interleaved calls to EXPECT_CALL and tested methods in the following files:

  • Sprite.test.cpp
  • Signal.test.cpp
  • Delegate.test.cpp (passed to API, but not used before setting expectations)

Note that this often appears to work, though there is no guarantee it will work.

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