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

Call default mock method for virtual destructor #289

Merged

Conversation

malcolmdavey
Copy link
Contributor

@malcolmdavey malcolmdavey commented Aug 9, 2022

Make sure we copy and use the default mock destructor from the default virtual function table.

It seems it sets the default VTable up by default to call unmockedDtor(), but then makes a new VTable for the specific object but doesn't copy it across.

Seems to only be an issue on windows

A general work around is:

Fake(Dtor(mock));
// or When(Dtor(mock)).Do([](auto){} );

Another one for shared_ptr is this

shared_ptr ptr( &mock.get(), [](auto) {} );

Issue here:
#288

Make sure we copy it from the default vertual function table.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.925% when pulling fa2cd3d on iress:OSS-7-fix-virtual-destructor-windows into 78ca536 on eranpeer:master.

@FranckRJ
Copy link
Collaborator

FranckRJ commented Aug 9, 2022

Good catch, thanks.

@malcolmdavey malcolmdavey changed the title Call default mock method for destructor. Call default mock method for virtual destructor Aug 10, 2022
@FranckRJ FranckRJ changed the base branch from master to dev-2.3.1 August 15, 2022 12:46
@FranckRJ FranckRJ merged commit 9f399c3 into eranpeer:dev-2.3.1 Aug 15, 2022
@FranckRJ FranckRJ added this to the 2.3.1 milestone Nov 4, 2022
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

Successfully merging this pull request may close these issues.

3 participants