aboutsummaryrefslogtreecommitdiffstats
path: root/googletest/include
diff options
context:
space:
mode:
authortrzeci <kontakt@trzeci.eu>2019-12-17 23:43:31 +0100
committertrzeci <kontakt@trzeci.eu>2019-12-17 23:43:31 +0100
commit9d8222ad667284cfad8be9cb27b25dab75f34ccb (patch)
treec39c9ed6cf1bc9eaea3b9189cef3eddf2f2b075a /googletest/include
parentd166e09483845b9b6a658dccc3d3dbb293676b62 (diff)
downloadgoogletest-9d8222ad667284cfad8be9cb27b25dab75f34ccb.tar.gz
googletest-9d8222ad667284cfad8be9cb27b25dab75f34ccb.tar.bz2
googletest-9d8222ad667284cfad8be9cb27b25dab75f34ccb.zip
Disable move constructor and assignment operator for test classes.
Disable move operations for TEST() and TEST_F() macros. Previous implementation disabled only copy ctor and assing operator, but this was violating rule of 5[1], which was captured by static code analysis tools like clang-tidy `cppcoreguidelines-special-member-functions`. [1]: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all
Diffstat (limited to 'googletest/include')
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h2
-rw-r--r--googletest/include/gtest/internal/gtest-port.h17
2 files changed, 17 insertions, 2 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index eac831a8..062611ea 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -1395,6 +1395,8 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
test_name)); \
+ GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
+ test_name)); \
}; \
\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index fcaac0bb..95a94799 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -190,8 +190,10 @@
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
// variable don't have to be used.
-// GTEST_DISALLOW_ASSIGN_ - disables operator=.
+// GTEST_DISALLOW_ASSIGN_ - disables copy operator=.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
+// GTEST_DISALLOW_MOVE_ASSIGN_ - disables move operator=.
+// GTEST_DISALLOW_MOVE_AND_ASSIGN_ - disables move ctor and operator=.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
// suppressed (constant conditional).
@@ -666,7 +668,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif
-// A macro to disallow operator=
+// A macro to disallow copy operator=
// This should be used in the private: declarations for a class.
#define GTEST_DISALLOW_ASSIGN_(type) \
void operator=(type const &) = delete
@@ -677,6 +679,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
type(type const &) = delete; \
GTEST_DISALLOW_ASSIGN_(type)
+// A macro to disallow move operator=
+// This should be used in the private: declarations for a class.
+#define GTEST_DISALLOW_MOVE_ASSIGN_(type) \
+ void operator=(type &&) = delete
+
+// A macro to disallow move constructor and operator=
+// This should be used in the private: declarations for a class.
+#define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \
+ type(type &&) = delete; \
+ GTEST_DISALLOW_MOVE_ASSIGN_(type)
+
// Tell the compiler to warn about unused return values for functions declared
// with this macro. The macro should be used on function declarations
// following the argument list: