VerifyAndClearExpectations - Setting expectations after code that exercises the mock has undefined behavior? #4779
Unanswered
DomXC
asked this question in
Community Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, as I have seen usage of Mock::VerifyAndClearExpectations in a codebase, where the expectations are set after the Mock::VerifyAndClearExpectations call, even in the [googlemock]
googletest/googlemock/test/gmock-spec-builders_test.cc
Lines 2276 to 2291 in 35b75a2
test (lines 2280 and 2282, my question is: causes really the usage as above - call
VerifyAndClearExpectations
, usingEXPECT_CALL
- undefined behavior on the mock as states int the documentation?https://google.github.io/googletest/gmock_cook_book.html#forcing-a-verification:
"Do not set new expectations after verifying and clearing a mock after its use. Setting expectations after code that exercises the mock has undefined behavior."
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions