From 7cf64792957ca249d9ee8faa3756cdac6a2460c5 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 9 Jan 2023 17:15:45 -0800 Subject: [PATCH] Use "#if GTEST_HAS_DEATH_TEST" instead of "#ifdef GTEST_HAS_DEATH_TEST" This is consistent with the example in gtest-port.h. PiperOrigin-RevId: 500846191 --- src/google/protobuf/any_test.cc | 2 +- src/google/protobuf/arena_align_test.cc | 12 ++++++------ src/google/protobuf/compiler/cpp/unittest.inc | 2 +- src/google/protobuf/extension_set_unittest.cc | 2 +- .../generated_message_reflection_unittest.cc | 2 +- src/google/protobuf/io/printer_death_test.cc | 2 +- src/google/protobuf/io/tokenizer_unittest.cc | 4 ++-- src/google/protobuf/map_test.inc | 4 ++-- src/google/protobuf/message_unittest.inc | 2 +- src/google/protobuf/reflection_ops_unittest.cc | 2 +- .../protobuf/repeated_field_reflection_unittest.cc | 4 ++-- src/google/protobuf/repeated_field_unittest.cc | 4 ++-- src/google/protobuf/util/time_util_test.cc | 2 +- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/google/protobuf/any_test.cc b/src/google/protobuf/any_test.cc index 5a3c7a43c1..9ff0e34b3a 100644 --- a/src/google/protobuf/any_test.cc +++ b/src/google/protobuf/any_test.cc @@ -178,7 +178,7 @@ TEST(AnyTest, MoveAssignment) { EXPECT_EQ(12345, payload.int32_value()); } -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST #ifndef NDEBUG TEST(AnyTest, PackSelfDeath) { google::protobuf::Any any; diff --git a/src/google/protobuf/arena_align_test.cc b/src/google/protobuf/arena_align_test.cc index f594e2236b..be71ff96fa 100644 --- a/src/google/protobuf/arena_align_test.cc +++ b/src/google/protobuf/arena_align_test.cc @@ -72,7 +72,7 @@ TEST(ArenaAlignDefault, Padded) { EXPECT_THAT(align_default.Padded(0), Eq(0)); EXPECT_THAT(align_default.Padded(8), Eq(8)); EXPECT_THAT(align_default.Padded(64), Eq(64)); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_default.Padded(1), ".*"); #endif // PROTOBUF_HAS_DEATH_TEST } @@ -95,7 +95,7 @@ TEST(ArenaAlignDefault, CheckAligned) { EXPECT_THAT(align_default.CheckAligned(p + 0), Eq(p + 0)); EXPECT_THAT(align_default.CheckAligned(p + 8), Eq(p + 8)); EXPECT_THAT(align_default.CheckAligned(p + 16), Eq(p + 16)); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_default.CheckAligned(p + 9), ".*"); @@ -110,7 +110,7 @@ TEST(ArenaAlignDefault, CeilDefaultAligned) { EXPECT_THAT(align_default.CeilDefaultAligned(p + 0), Eq(p + 0)); EXPECT_THAT(align_default.CeilDefaultAligned(p + 8), Eq(p + 8)); EXPECT_THAT(align_default.CeilDefaultAligned(p + 16), Eq(p + 16)); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_default.CeilDefaultAligned(p + 9), ".*"); @@ -161,7 +161,7 @@ TEST(ArenaAlign, Padded) { auto align_64 = ArenaAlignAs(64); EXPECT_THAT(align_64.Padded(64), Eq(64 + 64 - ArenaAlignDefault::align)); EXPECT_THAT(align_64.Padded(128), Eq(128 + 64 - ArenaAlignDefault::align)); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST // TODO(mvels): there are direct callers of AllocateAligned() that violate // `size` being a multiple of `align`: that should be an error / assert. // EXPECT_DEBUG_DEATH(align_64.Padded(16), ".*"); @@ -187,7 +187,7 @@ TEST(ArenaAlign, CheckAligned) { EXPECT_THAT(align_64.CheckAligned(p + 0), Eq(p)); EXPECT_THAT(align_64.CheckAligned(p + 64), Eq(p + 64)); EXPECT_THAT(align_64.CheckAligned(p + 128), Eq(p + 128)); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_64.CheckAligned(p + 8), ".*"); @@ -210,7 +210,7 @@ TEST(ArenaAlign, CeilDefaultAligned) { EXPECT_THAT(align_64.CeilDefaultAligned(p + 72), Eq(p + 128)); EXPECT_THAT(align_64.CeilDefaultAligned(p + 120), Eq(p + 128)); EXPECT_THAT(align_64.CeilDefaultAligned(p + 128), Eq(p + 128)); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 1), ".*"); EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 7), ".*"); EXPECT_DEBUG_DEATH(align_64.CeilDefaultAligned(p + 63), ".*"); diff --git a/src/google/protobuf/compiler/cpp/unittest.inc b/src/google/protobuf/compiler/cpp/unittest.inc index 292f70002e..aaf149eff8 100644 --- a/src/google/protobuf/compiler/cpp/unittest.inc +++ b/src/google/protobuf/compiler/cpp/unittest.inc @@ -1331,7 +1331,7 @@ TEST_F(GENERATED_SERVICE_TEST_NAME, CallMethod) { TEST_F(GENERATED_SERVICE_TEST_NAME, CallMethodTypeFailure) { // Verify death if we call Foo() with Bar's message types. -#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet +#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet EXPECT_DEBUG_DEATH( mock_service_.CallMethod(foo_, &mock_controller_, &foo_request_, &bar_response_, done_.get()), diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 94e4bbbc4b..611fcd4106 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -1186,7 +1186,7 @@ TEST(ExtensionSetTest, AbsentExtension) { .bb()); } -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST TEST(ExtensionSetTest, InvalidEnumDeath) { unittest::TestAllExtensions message; diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index 7608324415..639796caa8 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -1273,7 +1273,7 @@ TEST(GeneratedMessageReflectionTest, ArenaReleaseOneofMessageTest) { EXPECT_TRUE(released == nullptr); } -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST TEST(GeneratedMessageReflectionTest, UsageErrors) { unittest::TestAllTypes message; diff --git a/src/google/protobuf/io/printer_death_test.cc b/src/google/protobuf/io/printer_death_test.cc index 2accb5d3d3..f4e4b1fe12 100644 --- a/src/google/protobuf/io/printer_death_test.cc +++ b/src/google/protobuf/io/printer_death_test.cc @@ -95,7 +95,7 @@ class FakeAnnotationCollector : public AnnotationCollector { } }; -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST TEST_F(PrinterTest, Death) { Printer printer(output(), '$'); diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc index 1b214f6c4f..41713bca92 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc @@ -1020,7 +1020,7 @@ TEST_F(TokenizerTest, ParseFloat) { EXPECT_EQ(0.0, Tokenizer::ParseFloat("1e-9999999999999999999999999999")); EXPECT_EQ(HUGE_VAL, Tokenizer::ParseFloat("1e+9999999999999999999999999999")); -#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet +#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet // Test invalid integers that will never be tokenized as integers. EXPECT_DEBUG_DEATH( Tokenizer::ParseFloat("zxy"), @@ -1075,7 +1075,7 @@ TEST_F(TokenizerTest, ParseString) { EXPECT_EQ("\\U00110000\\U00200000\\Uffffffff", output); // Test invalid strings that will never be tokenized as strings. -#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet +#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet EXPECT_DEBUG_DEATH( Tokenizer::ParseString("", &output), "passed text that could not have been tokenized as a string"); diff --git a/src/google/protobuf/map_test.inc b/src/google/protobuf/map_test.inc index 4ff1845227..0aaa1be175 100644 --- a/src/google/protobuf/map_test.inc +++ b/src/google/protobuf/map_test.inc @@ -327,7 +327,7 @@ TEST_F(MapImplTest, MutableAt) { ExpectSingleElement(key, value2); } -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST TEST_F(MapImplTest, MutableAtNonExistDeathTest) { EXPECT_DEATH(map_.at(0), ""); @@ -1380,7 +1380,7 @@ void TestTransparent(const Key& key, const Key& miss_key) { EXPECT_EQ(m.at(key), 1); EXPECT_EQ(cm.at(key), 1); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEATH(m.at(miss_key), ""); EXPECT_DEATH(cm.at(miss_key), ""); #endif // PROTOBUF_HAS_DEATH_TEST diff --git a/src/google/protobuf/message_unittest.inc b/src/google/protobuf/message_unittest.inc index 5595fc898a..d4c8a40376 100644 --- a/src/google/protobuf/message_unittest.inc +++ b/src/google/protobuf/message_unittest.inc @@ -689,7 +689,7 @@ TEST(MESSAGE_TEST_NAME, DynamicCastToGenerated) { test_all_types_pointer_nullptr)); } -#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet. +#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet. TEST(MESSAGE_TEST_NAME, SerializeFailsIfNotInitialized) { UNITTEST::TestRequired message; diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc index 5500a01cd1..6f4b501186 100644 --- a/src/google/protobuf/reflection_ops_unittest.cc +++ b/src/google/protobuf/reflection_ops_unittest.cc @@ -184,7 +184,7 @@ TEST(ReflectionOpsTest, MergeOneof) { TestUtil::ExpectOneofSet2(message2); } -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST TEST(ReflectionOpsTest, MergeFromSelf) { // Note: Copy is implemented in terms of Merge() so technically the Copy diff --git a/src/google/protobuf/repeated_field_reflection_unittest.cc b/src/google/protobuf/repeated_field_reflection_unittest.cc index 19970d69e9..4d4f39e184 100644 --- a/src/google/protobuf/repeated_field_reflection_unittest.cc +++ b/src/google/protobuf/repeated_field_reflection_unittest.cc @@ -139,7 +139,7 @@ TEST(RepeatedFieldReflectionTest, RegularFields) { EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, 7)); } -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST // Make sure types are checked correctly at runtime. const FieldDescriptor* fd_optional_int32 = desc->FindFieldByName("optional_int32"); @@ -421,7 +421,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) { EXPECT_TRUE(rf_message.empty()); EXPECT_TRUE(mrf_message.empty()); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST // Make sure types are checked correctly at runtime. const FieldDescriptor* fd_optional_int32 = diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index ec858cf5a3..189785475c 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -951,7 +951,7 @@ TEST(RepeatedField, Truncate) { // Truncations that don't change the size are allowed, but growing is not // allowed. field.Truncate(field.size()); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(field.Truncate(field.size() + 1), "new_size"); #endif } @@ -1010,7 +1010,7 @@ TEST(RepeatedField, TruncateCords) { // Truncating to the current size should be fine (no-op), but truncating // to a larger size should crash. field.Truncate(field.size()); -#ifdef PROTOBUF_HAS_DEATH_TEST +#if PROTOBUF_HAS_DEATH_TEST EXPECT_DEBUG_DEATH(field.Truncate(field.size() + 1), "new_size"); #endif } diff --git a/src/google/protobuf/util/time_util_test.cc b/src/google/protobuf/util/time_util_test.cc index dceb6dbe2b..c6554374c0 100644 --- a/src/google/protobuf/util/time_util_test.cc +++ b/src/google/protobuf/util/time_util_test.cc @@ -428,7 +428,7 @@ TEST(TimeUtilTest, IsTimestampValid) { EXPECT_FALSE(TimeUtil::IsTimestampValid(underflow_nanos)); } -#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet. +#if PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet. #ifndef NDEBUG TEST(TimeUtilTest, DurationBounds) {