Open
Conversation
This allows creating default unique_ptr<T> mock objects. Signed-off-by: Andreas Pokorny <andreas.pokorny@gmail.com>
This assumes that the destructor of "base" is actually called. Signed-off-by: Andreas Pokorny <andreas.pokorny@gmail.com>
Solves the common case of capturing an object to formulate expectations while forwarding exclusive ownership to the class under test Signed-off-by: Andreas Pokorny <andreas.pokorny@gmail.com>
Signed-off-by: Andreas Pokorny <andreas.pokorny@gmail.com>
Author
|
Is there anything missing here? |
Owner
|
Only time for me to review your change. I'll find some time the next two days. |
|
@dascandy Are you planning to merge to cpp 11 branch. |
Owner
|
@APokorny Time got lost here. From what I can tell it's similar to adding an ExpectDestructor to a regular mock & returning a unique_ptr directly? That would be a much smaller delta to the existing code base & not require a new subclass... |
jeremy-ir
added a commit
to jeremy-ir/hippomocks
that referenced
this pull request
Jun 12, 2022
[Issue/Feature Description] Mocking of unique_ptr is currently not supported in HippoMocks. [Resolution] Cherry-pick changes from dascandy#82 which add support for unique_ptr.
This was referenced Jun 12, 2022
jeremy-ir
added a commit
to jeremy-ir/hippomocks
that referenced
this pull request
Jun 12, 2022
[Issue/Feature Description] Mocking of unique_ptr is currently not supported in HippoMocks. [Resolution] Cherry-pick changes from dascandy#82 which add support for unique_ptr.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for mock objects controlled by unique_ptr. In this proposal the mock repository is not the owner of the mock object - it just assists in construction. The verification of expectations thus happens when the mock object is destroyed.
Use the new UniqueMock function (or UniqueMock(Deleter d)) to construct a mock object within a unique_ptr. For example in your test you can write: