Gets the singleton UnitTest object. The first time this method is called, a UnitTest object is constructed and returned. Consecutive calls will return the same object. We don't protect this under mutex_ as a user is not supposed to call this before main() starts, from which point on the return value will never change.
| 4934 | // call this before main() starts, from which point on the return |
| 4935 | // value will never change. |
| 4936 | UnitTest * UnitTest::GetInstance() { |
| 4937 | // When compiled with MSVC 7.1 in optimized mode, destroying the |
| 4938 | // UnitTest object upon exiting the program messes up the exit code, |
| 4939 | // causing successful tests to appear failed. We have to use a |
| 4940 | // different implementation in this case to bypass the compiler bug. |
| 4941 | // This implementation makes the compiler happy, at the cost of |
| 4942 | // leaking the UnitTest object. |
| 4943 | |
| 4944 | // CodeGear C++Builder insists on a public destructor for the |
| 4945 | // default implementation. Use this implementation to keep good OO |
| 4946 | // design with private destructor. |
| 4947 | |
| 4948 | #if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) |
| 4949 | static UnitTest* const instance = new UnitTest; |
| 4950 | return instance; |
| 4951 | #else |
| 4952 | static UnitTest instance; |
| 4953 | return &instance; |
| 4954 | #endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) |
| 4955 | } |
| 4956 | |
| 4957 | // Gets the number of successful test cases. |
| 4958 | int UnitTest::successful_test_case_count() const { |
nothing calls this directly
no outgoing calls
no test coverage detected