code-mx / googlemock

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

support explicit checking for leaked mock objects #42

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
2009/4/16 Simon Bowden:

> As a suggestion, it would be convenient if there were a function to call any
> time [mainly at the end of a single test case] to assert the no-leaks check
> earlier. Specifically, I'd like all of my test cases to assert no leaks at
> the end of the case so that error reporting is better targetted.

I like it.  Does

 // Returns true if the mock registry is empty; otherwise
 // generates a non-fatal failure for each leaked mock object
 // and returns false.
 bool Mock::CatchLeakedMock();

sound good?

Original issue reported on code.google.com by zhanyong...@gmail.com on 17 Apr 2009 at 9:51

GoogleCodeExporter commented 9 years ago
I'd like that. But what about the following instead?

 // Returns true if the mock registry doesn't contain the given
 // mock object; otherwise returns false.
 bool Mock::CatchLeakedMock(const void* mock_obj)

 // Returns true if the mock registry is empty; otherwise
 // generates a non-fatal failure for each leaked mock object
 // and returns false.
 bool Mock::CatchLeakedMocks()

Original comment by kai.diet...@secrypt.de on 17 Aug 2010 at 1:15

GoogleCodeExporter commented 9 years ago
I think it's a good idea to rename the argumentless version to 
CatchLeakedMocks() (i.e. adding an 's' to the end).

I don't like CatchLeakedMock(const void* mock_obj) though as it's unsound: if 
mock_obj was already deleted and another mock object was then created at the 
same address, this function will fail even though the original mock_obj wasn't 
leaked.

Original comment by w...@google.com on 27 Sep 2010 at 9:25