nagyistoce / googlemock

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

the mock registry should be created on demand #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
googlemock uses a global registry object to record the states of mock
objects.  If a mock object is created and expectations are set on it before
the registry is created, the program will crash.

We should create the registry the first time it's needed.

Original issue reported on code.google.com by zhanyong...@gmail.com on 23 Jun 2009 at 4:55

GoogleCodeExporter commented 9 years ago
On second thought, we probably don't want to support this.

InitGoogleMock() must be called to initialize Google Mock before it can be 
used, as 
the behavior of Google Mock can be affected by command line flags.  The command 
line 
flags cannot be obtained before main() is entered.  Therefore, Google Mock must 
not 
be used before main() is entered.

Once main() is entered, the global registry object is already created and can 
be 
used.

So, it's invalid for a user program to create a mock and set expectations on it 
before main() is entered.

Original comment by zhanyong...@gmail.com on 21 Sep 2009 at 10:55