diff options
author | Abseil Team <absl-team@google.com> | 2021-07-02 21:01:11 (GMT) |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2021-07-07 18:34:19 (GMT) |
commit | 977cffc4423a2d6c0df3fc9a7b5253b8f79c3f18 (patch) | |
tree | f984ad508b34bbdfb1812efaffe5b62e35ab70ae /googletest/include/gtest/internal | |
parent | 4cfd14984fb0ae68ae434ae6e82d67b75986adec (diff) | |
download | googletest-977cffc4423a2d6c0df3fc9a7b5253b8f79c3f18.zip googletest-977cffc4423a2d6c0df3fc9a7b5253b8f79c3f18.tar.gz googletest-977cffc4423a2d6c0df3fc9a7b5253b8f79c3f18.tar.bz2 |
Googletest export
Introduce GTEST_FLAG_GET and GTEST_FLAG_SET macros.
PiperOrigin-RevId: 382808313
Diffstat (limited to 'googletest/include/gtest/internal')
-rw-r--r-- | googletest/include/gtest/internal/custom/README.md | 2 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-death-test-internal.h | 4 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 40 |
3 files changed, 33 insertions, 13 deletions
diff --git a/googletest/include/gtest/internal/custom/README.md b/googletest/include/gtest/internal/custom/README.md index ff391fb..0af3539 100644 --- a/googletest/include/gtest/internal/custom/README.md +++ b/googletest/include/gtest/internal/custom/README.md @@ -26,6 +26,8 @@ The following macros can be defined: * `GTEST_DEFINE_bool_(name, default_val, doc)` * `GTEST_DEFINE_int32_(name, default_val, doc)` * `GTEST_DEFINE_string_(name, default_val, doc)` +* `GTEST_FLAG_GET(flag_name)` +* `GTEST_FLAG_SET(flag_name, value)` ### Logging: diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index 867a840..44277c3 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -42,11 +42,11 @@ #include <stdio.h> #include <memory> +GTEST_DECLARE_string_(internal_run_death_test); + namespace testing { namespace internal { -GTEST_DECLARE_string_(internal_run_death_test); - // Names of the flags (needed for parsing Google Test flags). const char kDeathTestStyleFlag[] = "death_test_style"; const char kDeathTestUseFork[] = "death_test_use_fork"; diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 361354b..524bbeb 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2216,22 +2216,40 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. # 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) \ - GTEST_API_ extern std::int32_t GTEST_FLAG(name) -# define GTEST_DECLARE_string_(name) \ - GTEST_API_ extern ::std::string GTEST_FLAG(name) +#define GTEST_DECLARE_bool_(name) \ + namespace testing { \ + GTEST_API_ extern bool GTEST_FLAG(name); \ + } +#define GTEST_DECLARE_int32_(name) \ + namespace testing { \ + GTEST_API_ extern std::int32_t GTEST_FLAG(name); \ + } +#define GTEST_DECLARE_string_(name) \ + namespace testing { \ + GTEST_API_ extern ::std::string GTEST_FLAG(name); \ + } // Macros for defining flags. -# define GTEST_DEFINE_bool_(name, default_val, doc) \ - GTEST_API_ bool GTEST_FLAG(name) = (default_val) -# define GTEST_DEFINE_int32_(name, default_val, doc) \ - GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val) -# define GTEST_DEFINE_string_(name, default_val, doc) \ - GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val) +#define GTEST_DEFINE_bool_(name, default_val, doc) \ + namespace testing { \ + GTEST_API_ bool GTEST_FLAG(name) = (default_val); \ + } +#define GTEST_DEFINE_int32_(name, default_val, doc) \ + namespace testing { \ + GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val); \ + } +#define GTEST_DEFINE_string_(name, default_val, doc) \ + namespace testing { \ + GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val); \ + } #endif // !defined(GTEST_DECLARE_bool_) +#if !defined(GTEST_FLAG_GET) +#define GTEST_FLAG_GET(name) ::testing::GTEST_FLAG(name) +#define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value) +#endif // !defined(GTEST_FLAG_GET) + // Thread annotations #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) # define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) |