Rollback: Uses a simpler mechanism to disable the copying of GoogleTest test suites.

PiperOrigin-RevId: 477560280
Change-Id: I1c1f5a1d6645859ec38cb1a75cd267816d2aff35
This commit is contained in:
Abseil Team 2022-09-28 14:58:29 -07:00 committed by Copybara-Service
parent c43b916a96
commit 19387c9dd5
2 changed files with 13 additions and 6 deletions

View File

@ -409,7 +409,7 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
#define TEST_P(test_suite_name, test_name) \ #define TEST_P(test_suite_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
: public test_suite_name, private ::testing::internal::NonCopyable { \ : public ::testing::internal::UserTestSuite<test_suite_name> { \
public: \ public: \
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
void TestBody() override; \ void TestBody() override; \

View File

@ -190,12 +190,19 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
const std::string& message); const std::string& message);
std::set<std::string>* GetIgnoredParameterizedTestSuites(); std::set<std::string>* GetIgnoredParameterizedTestSuites();
class NonCopyable { // 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: public:
NonCopyable() = default; UserTestSuite() = default;
NonCopyable(const NonCopyable &) = delete; UserTestSuite(const UserTestSuite &) = delete;
NonCopyable &operator=(const NonCopyable &) = delete; UserTestSuite &operator=(const UserTestSuite &) = delete;
~NonCopyable() = default; virtual ~UserTestSuite() = default;
}; };
} // namespace internal } // namespace internal