Merge 28476008b659670321b6c4b595dfaae6ebe3529e into 7140cd416cecd7462a8aae488024abeee55598e4

This commit is contained in:
Sasha Nik 2026-06-11 19:28:19 +02:00 committed by GitHub
commit f8a3138c84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 16 deletions

View File

@ -1117,10 +1117,11 @@ class GTEST_API_ [[nodiscard]] TestEventListeners {
// according to their specification.
class GTEST_API_ [[nodiscard]] UnitTest {
public:
friend std::default_delete<UnitTest>;
// 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.
static UnitTest* GetInstance();
static std::unique_ptr<UnitTest>& GetInstance();
// Runs all tests in this UnitTest object and prints the result.
// Returns 0 if successful, or 1 otherwise.

View File

@ -5278,22 +5278,9 @@ void TestEventListeners::SuppressEventForwarding(bool suppress) {
// 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.
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;
std::unique_ptr<UnitTest>& UnitTest::GetInstance() {
static std::unique_ptr<UnitTest> instance{ new UnitTest };
return instance;
#else
static UnitTest instance;
return &instance;
#endif // defined(__BORLANDC__)
}
// Gets the number of successful test suites.