diff options
author | Abseil Team <absl-team@google.com> | 2022-09-28 18:55:06 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-09-28 18:55:57 (GMT) |
commit | 4924e0610a89dcd58077a691a2e3702b0d6e58ed (patch) | |
tree | bd81fa3e5cf72dd06a66870a752d95a8a7639cbb /googletest/include | |
parent | e23cdb78e9fef1f69a9ef917f447add5638daf2a (diff) | |
download | googletest-4924e0610a89dcd58077a691a2e3702b0d6e58ed.zip googletest-4924e0610a89dcd58077a691a2e3702b0d6e58ed.tar.gz googletest-4924e0610a89dcd58077a691a2e3702b0d6e58ed.tar.bz2 |
Moves boilerplate disabling copy constructor/assignment from GoogleTest's TEST_P macro into a header file to avoid triggering warnings in user code.
Fixes #4015
PiperOrigin-RevId: 477513399
Change-Id: Ia21928ee12e85946b4c8db86835d225cb257eecc
Diffstat (limited to 'googletest/include')
-rw-r--r-- | googletest/include/gtest/gtest-param-test.h | 7 | ||||
-rw-r--r-- | googletest/include/gtest/gtest.h | 15 |
2 files changed, 16 insertions, 6 deletions
diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index b55119a..19238ae 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -409,7 +409,7 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) { #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public test_suite_name { \ + : public ::testing::internal::UserTestSuite<test_suite_name> { \ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ @@ -429,11 +429,6 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) { return 0; \ } \ static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ - GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - (const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \ - GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \ - const GTEST_TEST_CLASS_NAME_(test_suite_name, \ - test_name) &) = delete; /* NOLINT */ \ }; \ int GTEST_TEST_CLASS_NAME_(test_suite_name, \ test_name)::gtest_registering_dummy_ = \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index d19a587..6ff2774 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -190,6 +190,21 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message); std::set<std::string>* GetIgnoredParameterizedTestSuites(); +// Mix-in class for user tests. +// This allows us to add/delete members to/from test suites without having to +// modify the test macros themselves. +// This makes the code easier to read and maintain, as well making it easier +// for users to suppress any warnings originating from these members, as the +// members are now declared in an external header instead of in user code. +template <class TestClass> +class UserTestSuite : public TestClass { + public: + UserTestSuite() = default; + UserTestSuite(const UserTestSuite &) = delete; + UserTestSuite &operator=(const UserTestSuite &) = delete; + virtual ~UserTestSuite() = default; +}; + } // namespace internal // The friend relationship of some of these classes is cyclic. |