fcoulombe / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

leaked mock objects aren't detected by leak checkers #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ON_CALL and EXPECT_CALL cause a mock object to be referenced in a global
table Google Mock keeps.  Therefore if the user code forgets to delete a
mock object, a leak checker won't be able to detect it since the object is
still reachable from the global table.  This is bad as the verification of
expectations is done in the mock object's destructor.

We should use some kind of weak pointer instead of void* to reference the
mock objects in the global table.

Original issue reported on code.google.com by zhanyong...@gmail.com on 6 Feb 2009 at 7:48

GoogleCodeExporter commented 9 years ago
Vlad suggested:

> Why can't googlemock release all the pointers before exiting RUN_ALL_TESTS 
when
> run under gtest?

Good point.  Better yet, googlemock could report them as errors.  This is
especially useful where a heap checker cannot be used.

> This can be done once gtest's test listener interface is
> published.

Yes.  Or we can use a global test environment, which is already
supported.  We just need to make sure that googlemock's environment is torn
down after all other test environments.

Original comment by zhanyong...@gmail.com on 26 Feb 2009 at 7:11

GoogleCodeExporter commented 9 years ago

Original comment by zhanyong...@gmail.com on 26 Feb 2009 at 7:11

GoogleCodeExporter commented 9 years ago

Original comment by zhanyong...@gmail.com on 4 Mar 2009 at 7:15

GoogleCodeExporter commented 9 years ago
A simple solution is to add a destructor to the global table which will 
complain if
the table is not empty.

Original comment by zhanyong...@gmail.com on 15 Apr 2009 at 11:31

GoogleCodeExporter commented 9 years ago

Original comment by zhanyong...@gmail.com on 1 May 2009 at 7:47