eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.22k stars 170 forks source link

Call default mock method for virtual destructor #289

Closed malcolmdavey closed 1 year ago

malcolmdavey commented 1 year ago

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: https://github.com/eranpeer/FakeIt/issues/288

coveralls commented 1 year ago

Coverage Status

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

FranckRJ commented 1 year ago

Good catch, thanks.