summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-09-30 17:54:41 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-09-30 17:55:15 (GMT)
commit93f08be653c36ddc6943e9513fc14c7292b4d007 (patch)
treebcdaf5edc50c7860f638f9e974eaaefda6eb8367 /googletest
parentd1a0039b97291dd1dc14f123b906bb7622ffe07c (diff)
downloadgoogletest-93f08be653c36ddc6943e9513fc14c7292b4d007.zip
googletest-93f08be653c36ddc6943e9513fc14c7292b4d007.tar.gz
googletest-93f08be653c36ddc6943e9513fc14c7292b4d007.tar.bz2
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
Diffstat (limited to 'googletest')
-rw-r--r--googletest/include/gtest/gtest-param-test.h7
-rw-r--r--googletest/include/gtest/gtest.h11
2 files changed, 12 insertions, 6 deletions
diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h
index b55119a..2d38b96 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 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_ = \
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index d19a587..81e124f 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -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.