diff options
author | Abseil Team <absl-team@google.com> | 2021-09-14 18:59:42 (GMT) |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2021-09-15 17:33:42 (GMT) |
commit | 6202251f0963187a7781f181365cf8c19bf343d5 (patch) | |
tree | 11dcdadad81eea51b6db2f229270b7556199c490 /googlemock/include | |
parent | 159c9ad23e8b276e8c975bb8621c81d4df5fd863 (diff) | |
download | googletest-6202251f0963187a7781f181365cf8c19bf343d5.zip googletest-6202251f0963187a7781f181365cf8c19bf343d5.tar.gz googletest-6202251f0963187a7781f181365cf8c19bf343d5.tar.bz2 |
Googletest export
Introduce GMOCK_FLAG_GET and GMOCK_FLAG_SET macros.
PiperOrigin-RevId: 396649214
Diffstat (limited to 'googlemock/include')
-rw-r--r-- | googlemock/include/gmock/gmock.h | 4 | ||||
-rw-r--r-- | googlemock/include/gmock/internal/custom/README.md | 2 | ||||
-rw-r--r-- | googlemock/include/gmock/internal/gmock-port.h | 40 |
3 files changed, 33 insertions, 13 deletions
diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h index 13e435f..3a728db 100644 --- a/googlemock/include/gmock/gmock.h +++ b/googlemock/include/gmock/gmock.h @@ -63,13 +63,13 @@ #include "gmock/gmock-nice-strict.h" #include "gmock/internal/gmock-internal-utils.h" -namespace testing { - // Declares Google Mock flags that we want a user to use programmatically. GMOCK_DECLARE_bool_(catch_leaked_mocks); GMOCK_DECLARE_string_(verbose); GMOCK_DECLARE_int32_(default_mock_behavior); +namespace testing { + // Initializes Google Mock. This must be called before running the // tests. In particular, it parses the command line for the flags // that Google Mock recognizes. Whenever a Google Mock flag is seen, diff --git a/googlemock/include/gmock/internal/custom/README.md b/googlemock/include/gmock/internal/custom/README.md index f6c93f6..9c4874f 100644 --- a/googlemock/include/gmock/internal/custom/README.md +++ b/googlemock/include/gmock/internal/custom/README.md @@ -14,3 +14,5 @@ The following macros can be defined: * `GMOCK_DEFINE_bool_(name, default_val, doc)` * `GMOCK_DEFINE_int32_(name, default_val, doc)` * `GMOCK_DEFINE_string_(name, default_val, doc)` +* `GMOCK_FLAG_GET(flag_name)` +* `GMOCK_FLAG_SET(flag_name, value)` diff --git a/googlemock/include/gmock/internal/gmock-port.h b/googlemock/include/gmock/internal/gmock-port.h index d2d1b74..7ec0730 100644 --- a/googlemock/include/gmock/internal/gmock-port.h +++ b/googlemock/include/gmock/internal/gmock-port.h @@ -67,19 +67,37 @@ #if !defined(GMOCK_DECLARE_bool_) // Macros for declaring flags. -# define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name) -# define GMOCK_DECLARE_int32_(name) extern GTEST_API_ int32_t GMOCK_FLAG(name) -# define GMOCK_DECLARE_string_(name) \ - extern GTEST_API_ ::std::string GMOCK_FLAG(name) +#define GMOCK_DECLARE_bool_(name) \ + namespace testing { \ + GTEST_API_ extern bool GMOCK_FLAG(name); \ + } +#define GMOCK_DECLARE_int32_(name) \ + namespace testing { \ + GTEST_API_ extern int32_t GMOCK_FLAG(name); \ + } +#define GMOCK_DECLARE_string_(name) \ + namespace testing { \ + GTEST_API_ extern ::std::string GMOCK_FLAG(name); \ + } // Macros for defining flags. -# define GMOCK_DEFINE_bool_(name, default_val, doc) \ - GTEST_API_ bool GMOCK_FLAG(name) = (default_val) -# define GMOCK_DEFINE_int32_(name, default_val, doc) \ - GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val) -# define GMOCK_DEFINE_string_(name, default_val, doc) \ - GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val) - +#define GMOCK_DEFINE_bool_(name, default_val, doc) \ + namespace testing { \ + GTEST_API_ bool GMOCK_FLAG(name) = (default_val); \ + } +#define GMOCK_DEFINE_int32_(name, default_val, doc) \ + namespace testing { \ + GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val); \ + } +#define GMOCK_DEFINE_string_(name, default_val, doc) \ + namespace testing { \ + GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val); \ + } #endif // !defined(GMOCK_DECLARE_bool_) +#if !defined(GMOCK_FLAG_GET) +#define GMOCK_FLAG_GET(name) ::testing::GMOCK_FLAG(name) +#define GMOCK_FLAG_SET(name, value) (void)(::testing::GMOCK_FLAG(name) = value) +#endif // !defined(GMOCK_FLAG_GET) + #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_ |