From 0928adbfea9b7645e884bd95fee23cfd669729cd Mon Sep 17 00:00:00 2001 From: kosak Date: Tue, 14 Jul 2015 22:44:39 +0000 Subject: [PATCH] Move the selection of the flag saver implementation into gtest-port.h and custom/gtest-port.h. --- include/gtest/gtest.h | 3 +-- include/gtest/internal/gtest-port.h | 2 ++ src/gtest.cc | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h index 71d552e1..919df651 100644 --- a/include/gtest/gtest.h +++ b/include/gtest/gtest.h @@ -452,8 +452,7 @@ class GTEST_API_ Test { // internal method to avoid clashing with names used in user TESTs. void DeleteSelf_() { delete this; } - // Uses a GTestFlagSaver to save and restore all Google Test flags. - const internal::GTestFlagSaver* const gtest_flag_saver_; + const internal::scoped_ptr< GTEST_FLAG_SAVER_ > gtest_flag_saver_; // Often a user misspells SetUp() as Setup() and spends a long time // wondering why it is never called by Google Test. The declaration of diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index 83fa75db..b3830c58 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -2418,6 +2418,8 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds. #endif // !defined(GTEST_FLAG) #if !defined(GTEST_DECLARE_bool_) +# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver + // Macros for declaring flags. # define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name) # define GTEST_DECLARE_int32_(name) \ diff --git a/src/gtest.cc b/src/gtest.cc index 6dea6c6a..bb00879d 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -2179,14 +2179,15 @@ int TestResult::test_property_count() const { // Creates a Test object. -// The c'tor saves the values of all Google Test flags. +// The c'tor saves the states of all flags. Test::Test() - : gtest_flag_saver_(new internal::GTestFlagSaver) { + : gtest_flag_saver_(new GTEST_FLAG_SAVER_) { } -// The d'tor restores the values of all Google Test flags. +// The d'tor restores the states of all flags. The actual work is +// done by the d'tor of the gtest_flag_saver_ field, and thus not +// visible here. Test::~Test() { - delete gtest_flag_saver_; } // Sets up the test fixture.