Merge 28476008b6
into 445e9bd8d0
This commit is contained in:
commit
d08384614a
@ -1112,10 +1112,11 @@ class GTEST_API_ TestEventListeners {
|
|||||||
// according to their specification.
|
// according to their specification.
|
||||||
class GTEST_API_ UnitTest {
|
class GTEST_API_ UnitTest {
|
||||||
public:
|
public:
|
||||||
|
friend std::default_delete<UnitTest>;
|
||||||
// Gets the singleton UnitTest object. The first time this method
|
// Gets the singleton UnitTest object. The first time this method
|
||||||
// is called, a UnitTest object is constructed and returned.
|
// is called, a UnitTest object is constructed and returned.
|
||||||
// Consecutive calls will return the same object.
|
// Consecutive calls will return the same object.
|
||||||
static UnitTest* GetInstance();
|
static std::unique_ptr<UnitTest>& GetInstance();
|
||||||
|
|
||||||
// Runs all tests in this UnitTest object and prints the result.
|
// Runs all tests in this UnitTest object and prints the result.
|
||||||
// Returns 0 if successful, or 1 otherwise.
|
// Returns 0 if successful, or 1 otherwise.
|
||||||
|
@ -5232,22 +5232,9 @@ void TestEventListeners::SuppressEventForwarding(bool suppress) {
|
|||||||
// Gets the singleton UnitTest object. The first time this method is
|
// Gets the singleton UnitTest object. The first time this method is
|
||||||
// called, a UnitTest object is constructed and returned. Consecutive
|
// called, a UnitTest object is constructed and returned. Consecutive
|
||||||
// calls will return the same object.
|
// calls will return the same object.
|
||||||
//
|
std::unique_ptr<UnitTest>& UnitTest::GetInstance() {
|
||||||
// We don't protect this under mutex_ as a user is not supposed to
|
static std::unique_ptr<UnitTest> instance{ new UnitTest };
|
||||||
// call this before main() starts, from which point on the return
|
|
||||||
// value will never change.
|
|
||||||
UnitTest* UnitTest::GetInstance() {
|
|
||||||
// CodeGear C++Builder insists on a public destructor for the
|
|
||||||
// default implementation. Use this implementation to keep good OO
|
|
||||||
// design with private destructor.
|
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
|
||||||
static UnitTest* const instance = new UnitTest;
|
|
||||||
return instance;
|
return instance;
|
||||||
#else
|
|
||||||
static UnitTest instance;
|
|
||||||
return &instance;
|
|
||||||
#endif // defined(__BORLANDC__)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the number of successful test suites.
|
// Gets the number of successful test suites.
|
||||||
|
Loading…
Reference in New Issue
Block a user