Uses a simpler mechanism to disable the copying of GoogleTest test suites, to move code out of the TEST_P macro.

PiperOrigin-RevId: 478031678
Change-Id: I45f0ce17a4add526c86b8212d836d98d63b3a193
pull/4028/head
Abseil Team 2 years ago committed by Copybara-Service
parent d1a0039b97
commit 93f08be653
  1. 7
      googletest/include/gtest/gtest-param-test.h
  2. 11
      googletest/include/gtest/gtest.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 test_suite_name, private ::testing::internal::GTestNonCopyable {\
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_ = \

@ -190,6 +190,17 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
const std::string& message);
std::set<std::string>* GetIgnoredParameterizedTestSuites();
// A base class that prevents subclasses from being copyable.
// We do this instead of using '= delete' so as to avoid triggering warnings
// inside user code regarding any of our declarations.
class GTestNonCopyable {
public:
GTestNonCopyable() = default;
GTestNonCopyable(const GTestNonCopyable &) = delete;
GTestNonCopyable &operator=(const GTestNonCopyable &) = delete;
~GTestNonCopyable() = default;
};
} // namespace internal
// The friend relationship of some of these classes is cyclic.

Loading…
Cancel
Save