From 155de14cd861a29886e85a1f98407d93e16b0595 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Thu, 1 Jul 2021 11:43:07 -0700 Subject: [PATCH 1/2] Use GTEST_DONT_DEFINE_TEST_F to guard TEST_F The documentation is clear that the FOO we'll be guarding always matches the spelling of the DONT macro. A single guard macro should not toggle more than one implementation macro. This fixes a regression in 7413280c52c1f759395572a384165023d24eeb57. Relatedly, improve the documentation of the DONT macros to bring the list of valid FOO values up to date. --- googletest/README.md | 4 +++- googletest/include/gtest/gtest.h | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/googletest/README.md b/googletest/README.md index c8aedb78..83ae6cf5 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -203,7 +203,9 @@ add -DGTEST_DONT_DEFINE_FOO=1 to the compiler flags to tell GoogleTest to change the macro's name from `FOO` -to `GTEST_FOO`. Currently `FOO` can be `FAIL`, `SUCCEED`, or `TEST`. For +to `GTEST_FOO`. Currently `FOO` can be `ASSERT_EQ`, `ASSERT_FALSE`, `ASSERT_GE`, +`ASSERT_GT`, `ASSERT_LE`, `ASSERT_LT`, `ASSERT_NE`, `ASSERT_TRUE`, +`EXPECT_FALSE`, `EXPECT_TRUE`, `FAIL`, `SUCCEED`, `TEST`, or `TEST_F`. For example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write GTEST_TEST(SomeTest, DoesThis) { ... } diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 7a5d057c..258c42bb 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -2379,12 +2379,13 @@ constexpr bool StaticAssertTypeEq() noexcept { // EXPECT_EQ(b_.size(), 1); // } // -// GOOGLETEST_CM0011 DO NOT DELETE -#if !GTEST_DONT_DEFINE_TEST -#define TEST_F(test_fixture, test_name)\ +#define GTEST_TEST_F(test_fixture, test_name)\ GTEST_TEST_(test_fixture, test_name, test_fixture, \ ::testing::internal::GetTypeId()) -#endif // !GTEST_DONT_DEFINE_TEST +// GOOGLETEST_CM0011 DO NOT DELETE +#if !GTEST_DONT_DEFINE_TEST_F +#define TEST_F(test_fixture, test_name) GTEST_TEST_F(test_fixture, test_name) +#endif // Returns a path to temporary directory. // Tries to determine an appropriate directory for the platform. From a42111b49b6391c28886f8f75e60cef606e46d67 Mon Sep 17 00:00:00 2001 From: Derek Mauro <761129+derekmauro@users.noreply.github.com> Date: Wed, 14 Jul 2021 16:02:00 -0400 Subject: [PATCH 2/2] Fix location of GOOGLETEST_CM0011 marker --- googletest/include/gtest/gtest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 258c42bb..55576309 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -2379,10 +2379,10 @@ constexpr bool StaticAssertTypeEq() noexcept { // EXPECT_EQ(b_.size(), 1); // } // +// GOOGLETEST_CM0011 DO NOT DELETE #define GTEST_TEST_F(test_fixture, test_name)\ GTEST_TEST_(test_fixture, test_name, test_fixture, \ ::testing::internal::GetTypeId()) -// GOOGLETEST_CM0011 DO NOT DELETE #if !GTEST_DONT_DEFINE_TEST_F #define TEST_F(test_fixture, test_name) GTEST_TEST_F(test_fixture, test_name) #endif