-
Notifications
You must be signed in to change notification settings - Fork 174
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
Mocking methods with params as references result with storing those references regardles of their actual lifetime. #108
Comments
Please see the latest answer here. This is a simple workaround which helped me in this particular case. |
The Proposed workaround does not work fully. In case you made the modification to fakeit.hpp, you cannot mock any functions that take const-ref arguments using "When". See eg this code:
Error message when compiling with gcc7
(see the mismatched types const S& and const S line. I believe this is due to the std::remove_reference proposal. Any workarounds? |
I second this request. Being able to verify invocations with reference arguments is an absolute must. Setting a kind of "recorder" action is too cumbersome. |
yes - this seems like a big flaw. Especially if it doesn't work for string classes. If it can detect something has a copy constructor, wonder if it can use to implement the copying. Or if it can use a matcher object which can do the copying itself |
I'll centralize the discussion about this known bug in a new issue: #274 |
For the following scenario:
test will most likely fail, as (my guess) mocked class is keeping references to passed arguments and when Verify is called referenced values are gone.
The text was updated successfully, but these errors were encountered: