eranpeer / FakeIt

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

Reset don't reinit offset vector #72

Closed facetothefate closed 7 years ago

facetothefate commented 8 years ago

I wonder why we don't reinit the offset vector here ?

I got a segmentation fault today, in my test, I have a big struct contains a lot of the virtual method, called mock_a I have two different test class, one setting up some functions of mock_a, the other one firstly reset the mock_a, and setting up some more functions, then I ran into a segmentation fault.

I trace back, it turns out the offset vector contains the old offset which are added in the previous test class. I think this happened because the two offset have same id.

however with _methodMocks have been reset, the old offset will provide a NULL pointer. Then I have a segmentation fault.

BTW, why we need to keep track all the offsets ? Why we don't make the whole _methodMocks as a map (id as the key)?

coveralls commented 8 years ago

Coverage Status

Coverage increased (+1.0e-05%) to 99.974% when pulling 808fed2efa0fef4015b3a35aba62e1d9f7c5c985 on facetothefate:master into 44f13731138b30de72a32aeb16f7a21490bc9135 on eranpeer:master.

facetothefate commented 7 years ago

Hello ~~ Are there anyone ?

eranpeer commented 7 years ago

Oops, somehow it skipped my busy to-do list. Taking a look right now.

On Fri, Sep 30, 2016 at 11:58 PM, Zhifei Fang notifications@github.com wrote:

Hello ~~ Are there anyone ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/eranpeer/FakeIt/pull/72#issuecomment-250850632, or mute the thread https://github.com/notifications/unsubscribe-auth/ACc8gn_C-rLMRqV1vIAcee5j8_Nc6ZYdks5qvXf1gaJpZM4J4SmR .

Eran 972-52-8387550

eranpeer commented 7 years ago

I push the single header versions with your fix. All single header files can be used now.

On Sat, Oct 1, 2016 at 6:35 AM, Eran Pe'er eranpe@gmail.com wrote:

Oops, somehow it skipped my busy to-do list. Taking a look right now.

On Fri, Sep 30, 2016 at 11:58 PM, Zhifei Fang notifications@github.com wrote:

Hello ~~ Are there anyone ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/eranpeer/FakeIt/pull/72#issuecomment-250850632, or mute the thread https://github.com/notifications/unsubscribe-auth/ACc8gn_C-rLMRqV1vIAcee5j8_Nc6ZYdks5qvXf1gaJpZM4J4SmR .

Eran 972-52-8387550

Eran 972-52-8387550