diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index c1e4f352..0c7aa499 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -200,7 +200,7 @@ TEST(IsTrueTest, IsTrueIsFalse) { EXPECT_THAT(nonnull_unique, Not(IsFalse())); } -#if GTEST_HAS_TYPED_TEST +#ifdef GTEST_HAS_TYPED_TEST // Tests ContainerEq with different container types, and // different element types. diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index ad56ead0..d53196b3 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -1088,7 +1088,7 @@ TEST(UnexpectedCallTest, UnsatisfiedPrerequisites) { // Verifies that the failure message contains the two unsatisfied // pre-requisites but not the satisfied one. -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE EXPECT_THAT(r.message(), ContainsRegex( // POSIX RE doesn't understand the (?s) prefix, but has no diff --git a/googletest/include/gtest/gtest-death-test.h b/googletest/include/gtest/gtest-death-test.h index b793528b..08fef8c7 100644 --- a/googletest/include/gtest/gtest-death-test.h +++ b/googletest/include/gtest/gtest-death-test.h @@ -51,7 +51,7 @@ GTEST_DECLARE_string_(death_test_style); namespace testing { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST namespace internal { @@ -328,7 +328,7 @@ class GTEST_API_ KilledBySignal { // death tests are supported; otherwise they just issue a warning. This is // useful when you are combining death test assertions with normal test // assertions in one test. -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ EXPECT_DEATH(statement, regex) #define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 2bf64938..c1001d67 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -600,7 +600,7 @@ class GTEST_API_ TestInfo { const TestResult* result() const { return &result_; } private: -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST friend class internal::DefaultDeathTestFactory; #endif // GTEST_HAS_DEATH_TEST friend class Test; diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index 21f3d29f..522eed85 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -57,7 +57,7 @@ const char kDeathTestStyleFlag[] = "death_test_style"; const char kDeathTestUseFork[] = "death_test_use_fork"; const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index b757c7d8..29503db0 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -161,10 +161,10 @@ // NOT define them. // // These macros are public so that portable tests can be written. -// Such tests typically surround code using a feature with an #if +// Such tests typically surround code using a feature with an #ifdef // which controls that code. For example: // -// #if GTEST_HAS_DEATH_TEST +// #ifdef GTEST_HAS_DEATH_TEST // EXPECT_DEATH(DoSomethingDeadly()); // #endif // @@ -794,7 +794,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // GTEST_IS_THREADSAFE -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE // Some platforms don't support including these threading related headers. #include // NOLINT #include // NOLINT @@ -909,7 +909,7 @@ GTEST_API_ bool IsTrue(bool condition); // Defines RE. -#if GTEST_USES_RE2 +#ifdef GTEST_USES_RE2 // This is almost `using RE = ::RE2`, except it is copy-constructible, and it // needs to disambiguate the `std::string`, `absl::string_view`, and `const @@ -934,7 +934,7 @@ class GTEST_API_ RE { RE2 regex_; }; -#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE +#elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_SIMPLE_RE) // A simple C++ wrapper for . It uses the POSIX Extended // Regular Expression syntax. @@ -972,7 +972,7 @@ class GTEST_API_ RE { std::string pattern_; bool is_valid_; -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE regex_t full_regex_; // For FullMatch(). regex_t partial_regex_; // For PartialMatch(). @@ -1200,7 +1200,7 @@ GTEST_API_ std::string ReadEntireFile(FILE* file); // All command line arguments. GTEST_API_ std::vector GetArgvs(); -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST std::vector GetInjectableArgvs(); // Deprecated: pass the args vector by value instead. @@ -1211,7 +1211,7 @@ void ClearInjectableArgvs(); #endif // GTEST_HAS_DEATH_TEST // Defines synchronization primitives. -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE #ifdef GTEST_OS_WINDOWS // Provides leak-safe Windows kernel handle ownership. diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index f91eba22..649b17b5 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -40,7 +40,7 @@ #include "gtest/internal/custom/gtest.h" #include "gtest/internal/gtest-port.h" -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #ifdef GTEST_OS_MAC #include @@ -133,7 +133,7 @@ GTEST_DEFINE_string_( namespace testing { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST namespace internal { diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 036c3415..007e0498 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl { void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc, internal::TearDownTestSuiteFunc tear_down_tc, TestInfo* test_info) { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // In order to support thread-safe death tests, we need to // remember the original working directory when the test program // was first invoked. We cannot do this in RUN_ALL_TESTS(), as @@ -778,7 +778,7 @@ class GTEST_API_ UnitTestImpl { return gtest_trace_stack_.get(); } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST void InitDeathTestSubprocessControlInfo() { internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag()); } @@ -943,7 +943,7 @@ class GTEST_API_ UnitTestImpl { // How long the test took to run, in milliseconds. TimeInMillis elapsed_time_; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // The decomposed components of the gtest_internal_run_death_test flag, // parsed when RUN_ALL_TESTS is called. std::unique_ptr internal_run_death_test_flag_; @@ -967,7 +967,7 @@ inline UnitTestImpl* GetUnitTestImpl() { return UnitTest::GetInstance()->impl(); } -#if GTEST_USES_SIMPLE_RE +#ifdef GTEST_USES_SIMPLE_RE // Internal helper functions for implementing the simple regular // expression matcher. @@ -993,7 +993,7 @@ GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str); GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv); GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // Returns the message describing the last system error, regardless of the // platform. diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index da4d12d8..994fabd4 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -657,7 +657,7 @@ void ThreadLocalRegistry::OnThreadLocalDestroyed( #endif // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE // Implements RE. Currently only needed for death tests. @@ -719,7 +719,7 @@ void RE::Init(const char* regex) { delete[] full_pattern; } -#elif GTEST_USES_SIMPLE_RE +#elif defined(GTEST_USES_SIMPLE_RE) // Returns true if and only if ch appears anywhere in str (excluding the // terminating '\0' character). @@ -1221,7 +1221,7 @@ std::string ReadEntireFile(FILE* file) { return content; } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST static const std::vector* g_injected_test_argvs = nullptr; // Owned. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 88bbcd20..7ffbf418 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5018,7 +5018,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { #endif // GTEST_HAS_ABSL } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // A helper class that creates the premature-exit file in its // constructor and deletes the file in its destructor. class ScopedPrematureExitFile { @@ -5383,7 +5383,7 @@ void UnitTest::RecordProperty(const std::string& key, // We don't protect this under mutex_, as we only support calling it // from the main thread. int UnitTest::Run() { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST const bool in_death_test_child_process = GTEST_FLAG_GET(internal_run_death_test).length() > 0; @@ -5560,7 +5560,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent) random_(0), // Will be reseeded before first use. start_timestamp_(0), elapsed_time_(0), -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST death_test_factory_(new DefaultDeathTestFactory), #endif // Will be overridden by the flag before first use. @@ -5600,7 +5600,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) { test_result->RecordProperty(xml_element, test_property); } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // Disables event forwarding if the control is currently in a death test // subprocess. Must not be called before InitGoogleTest. void UnitTestImpl::SuppressTestEventsIfInSubprocess() { @@ -5663,7 +5663,7 @@ void UnitTestImpl::PostFlagParsingInit() { listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_()); #endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_) -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST InitDeathTestSubprocessControlInfo(); SuppressTestEventsIfInSubprocess(); #endif // GTEST_HAS_DEATH_TEST @@ -5801,7 +5801,7 @@ bool UnitTestImpl::RunAllTests() { // death test. bool in_subprocess_for_death_test = false; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != nullptr); #if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index a361a574..3579ce88 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -37,7 +37,7 @@ using testing::internal::AlwaysFalse; using testing::internal::AlwaysTrue; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #ifdef GTEST_OS_WINDOWS #include // For chdir(). @@ -1353,7 +1353,7 @@ void DieWithMessage(const char* message) { TEST(MatcherDeathTest, DoesNotBreakBareRegexMatching) { // googletest tests this, of course; here we ensure that including googlemock // has not broken it. -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE EXPECT_DEATH(DieWithMessage("O, I die, Horatio."), "I d[aeiou]e"); #else EXPECT_DEATH(DieWithMessage("O, I die, Horatio."), "I di?e"); diff --git a/googletest/test/googletest-death-test_ex_test.cc b/googletest/test/googletest-death-test_ex_test.cc index f2515e37..34d55013 100644 --- a/googletest/test/googletest-death-test_ex_test.cc +++ b/googletest/test/googletest-death-test_ex_test.cc @@ -33,7 +33,7 @@ #include "gtest/gtest-death-test.h" #include "gtest/gtest.h" -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_SEH #include // For RaiseException(). diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index 090fb070..1a496ac8 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -41,7 +41,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127 /* conditional expression is constant */) -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE using testing::ScopedFakeTestPartResultReporter; using testing::TestPartResultArray; @@ -247,7 +247,7 @@ TEST(SCOPED_TRACETest, CanBeRepeated) { << "contain trace point A, B, and D."; } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE // Tests that SCOPED_TRACE()s can be used concurrently from multiple // threads. Namely, an assertion should be affected by // SCOPED_TRACE()s in its own thread only. @@ -773,7 +773,7 @@ REGISTER_TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest, Used); // typedef ::testing::Types MyTypes; // INSTANTIATE_TYPED_TEST_SUITE_P(All, DetectNotInstantiatedTypesTest, MyTypes); -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // We rely on the golden file to verify that tests whose test case // name ends with DeathTest are run first. @@ -851,7 +851,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) { "failure."); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE class ExpectFailureWithThreadsTest : public ExpectFailureTest { protected: @@ -1024,7 +1024,7 @@ int main(int argc, char** argv) { std::count(argv, argv + argc, std::string("internal_skip_environment_and_ad_hoc_tests")) > 0; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST if (GTEST_FLAG_GET(internal_run_death_test) != "") { // Skip the usual output capturing if we're running as the child // process of an threadsafe-style death test. diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index a93572a9..f3ebda9f 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -361,7 +361,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) { const char regex[] = #ifdef _MSC_VER "googletest-port-test\\.cc\\(\\d+\\):" -#elif GTEST_USES_POSIX_RE +#elif defined(GTEST_USES_POSIX_RE) "googletest-port-test\\.cc:[0-9]+" #else "googletest-port-test\\.cc:\\d+" @@ -372,7 +372,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) { regex); } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) { EXPECT_EXIT( @@ -399,7 +399,7 @@ TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) { #endif } -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE template class RETest : public ::testing::Test {}; @@ -456,7 +456,7 @@ TYPED_TEST(RETest, PartialMatchWorks) { EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re)); } -#elif GTEST_USES_SIMPLE_RE +#elif defined(GTEST_USES_SIMPLE_RE) TEST(IsInSetTest, NulCharIsNotInAnySet) { EXPECT_FALSE(IsInSet('\0', "")); @@ -1011,7 +1011,7 @@ TEST(ThreadLocalTest, PointerAndConstPointerReturnSameValue) { EXPECT_EQ(thread_local_string.pointer(), const_thread_local_string.pointer()); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE void AddTwo(int* param) { *param += 2; } diff --git a/googletest/test/gtest_help_test_.cc b/googletest/test/gtest_help_test_.cc index da289f05..18b5f3cd 100644 --- a/googletest/test/gtest_help_test_.cc +++ b/googletest/test/gtest_help_test_.cc @@ -39,6 +39,6 @@ TEST(HelpFlagTest, ShouldNotBeRun) { ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} #endif diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc index 24b173ff..af9733ad 100644 --- a/googletest/test/gtest_stress_test.cc +++ b/googletest/test/gtest_stress_test.cc @@ -35,7 +35,7 @@ #include "gtest/gtest.h" #include "src/gtest-internal-inl.h" -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE namespace testing { namespace { diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 461297ab..2f137d24 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -270,7 +270,7 @@ using testing::internal::CaptureStdout; using testing::internal::GetCapturedStdout; #endif -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE using testing::internal::ThreadWithParam; #endif @@ -1189,7 +1189,7 @@ TEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) { EXPECT_EQ(1, results.size()); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE class ScopedFakeTestPartResultReporterWithThreadsTest : public ScopedFakeTestPartResultReporterTest { @@ -1347,7 +1347,7 @@ TEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) { ""); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE typedef ScopedFakeTestPartResultReporterWithThreadsTest ExpectFailureWithThreadsTest; @@ -6178,7 +6178,7 @@ TEST_F(ParseFlagsTest, FilterBad) { const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr}; -#if GTEST_HAS_ABSL && GTEST_HAS_DEATH_TEST +#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true), testing::ExitedWithCode(1), @@ -6197,7 +6197,7 @@ TEST_F(ParseFlagsTest, OutputEmpty) { const char* argv2[] = {"foo.exe", "--gtest_output", nullptr}; -#if GTEST_HAS_ABSL && GTEST_HAS_DEATH_TEST +#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true), testing::ExitedWithCode(1),