Remove the legacy internal GTEST_DISALLOW_* macros

PiperOrigin-RevId: 443715444
Change-Id: I3ffd54b63d2728ae4a668ee7875c8c3c8188087c
This commit is contained in:
Derek Mauro 2022-04-22 11:25:26 -07:00 committed by Copybara-Service
parent b85864c647
commit bf66935e07
32 changed files with 290 additions and 159 deletions

View File

@ -393,7 +393,8 @@ class DefaultValue {
private: private:
const T value_; const T value_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(FixedValueProducer); FixedValueProducer(const FixedValueProducer&) = delete;
FixedValueProducer& operator=(const FixedValueProducer&) = delete;
}; };
class FactoryValueProducer : public ValueProducer { class FactoryValueProducer : public ValueProducer {
@ -404,7 +405,8 @@ class DefaultValue {
private: private:
const FactoryFunction factory_; const FactoryFunction factory_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(FactoryValueProducer); FactoryValueProducer(const FactoryValueProducer&) = delete;
FactoryValueProducer& operator=(const FactoryValueProducer&) = delete;
}; };
static ValueProducer* producer_; static ValueProducer* producer_;
@ -478,7 +480,8 @@ class ActionInterface {
virtual Result Perform(const ArgumentTuple& args) = 0; virtual Result Perform(const ArgumentTuple& args) = 0;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface); ActionInterface(const ActionInterface&) = delete;
ActionInterface& operator=(const ActionInterface&) = delete;
}; };
// An Action<F> is a copyable and IMMUTABLE (except by assignment) // An Action<F> is a copyable and IMMUTABLE (except by assignment)
@ -951,7 +954,8 @@ class ReturnAction {
R value_before_cast_; R value_before_cast_;
Result value_; Result value_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl); Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
}; };
// Partially specialize for ByMoveWrapper. This version of ReturnAction will // Partially specialize for ByMoveWrapper. This version of ReturnAction will

View File

@ -313,7 +313,9 @@ class StringMatchResultListener : public MatchResultListener {
private: private:
::std::stringstream ss_; ::std::stringstream ss_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener); StringMatchResultListener(const StringMatchResultListener&) = delete;
StringMatchResultListener& operator=(const StringMatchResultListener&) =
delete;
}; };
// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
@ -2555,7 +2557,8 @@ class WhenSortedByMatcher {
const Comparator comparator_; const Comparator comparator_;
const Matcher<const ::std::vector<LhsValue>&> matcher_; const Matcher<const ::std::vector<LhsValue>&> matcher_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl); Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
}; };
private: private:

View File

@ -169,7 +169,8 @@ class GTEST_INTERNAL_EMPTY_BASE_CLASS NiceMock
} }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock); NiceMock(const NiceMock&) = delete;
NiceMock& operator=(const NiceMock&) = delete;
}; };
template <class MockClass> template <class MockClass>
@ -210,7 +211,8 @@ class GTEST_INTERNAL_EMPTY_BASE_CLASS NaggyMock
} }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(NaggyMock); NaggyMock(const NaggyMock&) = delete;
NaggyMock& operator=(const NaggyMock&) = delete;
}; };
template <class MockClass> template <class MockClass>
@ -251,7 +253,8 @@ class GTEST_INTERNAL_EMPTY_BASE_CLASS StrictMock
} }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock); StrictMock(const StrictMock&) = delete;
StrictMock& operator=(const StrictMock&) = delete;
}; };
#undef GTEST_INTERNAL_EMPTY_BASE_CLASS #undef GTEST_INTERNAL_EMPTY_BASE_CLASS

View File

@ -677,7 +677,8 @@ class GTEST_API_ InSequence {
private: private:
bool sequence_created_; bool sequence_created_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence); // NOLINT InSequence(const InSequence&) = delete;
InSequence& operator=(const InSequence&) = delete;
} GTEST_ATTRIBUTE_UNUSED_; } GTEST_ATTRIBUTE_UNUSED_;
namespace internal { namespace internal {
@ -1219,7 +1220,8 @@ class TypedExpectation : public ExpectationBase {
Matcher<const ArgumentTuple&> extra_matcher_; Matcher<const ArgumentTuple&> extra_matcher_;
Action<F> repeated_action_; Action<F> repeated_action_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation); TypedExpectation(const TypedExpectation&) = delete;
TypedExpectation& operator=(const TypedExpectation&) = delete;
}; // class TypedExpectation }; // class TypedExpectation
// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for // A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
@ -1392,7 +1394,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
Wrapper result_; Wrapper result_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder); ActionResultHolder(const ActionResultHolder&) = delete;
ActionResultHolder& operator=(const ActionResultHolder&) = delete;
}; };
// Specialization for T = void. // Specialization for T = void.
@ -1425,7 +1428,8 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
private: private:
ActionResultHolder() {} ActionResultHolder() {}
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder); ActionResultHolder(const ActionResultHolder&) = delete;
ActionResultHolder& operator=(const ActionResultHolder&) = delete;
}; };
template <typename F> template <typename F>

View File

@ -86,7 +86,8 @@ class BetweenCardinalityImpl : public CardinalityInterface {
const int min_; const int min_;
const int max_; const int max_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl); BetweenCardinalityImpl(const BetweenCardinalityImpl&) = delete;
BetweenCardinalityImpl& operator=(const BetweenCardinalityImpl&) = delete;
}; };
// Formats "n times" in a human-friendly way. // Formats "n times" in a human-friendly way.

View File

@ -869,7 +869,8 @@ class MockClass {
int(const std::unique_ptr<int>&, std::unique_ptr<int>)); int(const std::unique_ptr<int>&, std::unique_ptr<int>));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockClass); MockClass(const MockClass&) = delete;
MockClass& operator=(const MockClass&) = delete;
}; };
// Tests that DoDefault() returns the built-in default value for the // Tests that DoDefault() returns the built-in default value for the

View File

@ -54,7 +54,8 @@ class MockFoo {
MOCK_METHOD0(Bar, int()); // NOLINT MOCK_METHOD0(Bar, int()); // NOLINT
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); MockFoo(const MockFoo&) = delete;
MockFoo& operator=(const MockFoo&) = delete;
}; };
// Tests that Cardinality objects can be default constructed. // Tests that Cardinality objects can be default constructed.

View File

@ -202,7 +202,8 @@ class MockFoo : public FooInterface {
MOCK_METHOD(int, RefQualifiedOverloaded, (), (ref(&&), override)); MOCK_METHOD(int, RefQualifiedOverloaded, (), (ref(&&), override));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); MockFoo(const MockFoo&) = delete;
MockFoo& operator=(const MockFoo&) = delete;
}; };
class LegacyMockFoo : public FooInterface { class LegacyMockFoo : public FooInterface {
@ -274,7 +275,8 @@ class LegacyMockFoo : public FooInterface {
int RefQualifiedOverloaded() && override { return 0; } int RefQualifiedOverloaded() && override { return 0; }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockFoo); LegacyMockFoo(const LegacyMockFoo&) = delete;
LegacyMockFoo& operator=(const LegacyMockFoo&) = delete;
}; };
#ifdef _MSC_VER #ifdef _MSC_VER
@ -492,7 +494,8 @@ class MockB {
MOCK_METHOD(void, DoB, ()); MOCK_METHOD(void, DoB, ());
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB); MockB(const MockB&) = delete;
MockB& operator=(const MockB&) = delete;
}; };
class LegacyMockB { class LegacyMockB {
@ -502,7 +505,8 @@ class LegacyMockB {
MOCK_METHOD0(DoB, void()); MOCK_METHOD0(DoB, void());
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockB); LegacyMockB(const LegacyMockB&) = delete;
LegacyMockB& operator=(const LegacyMockB&) = delete;
}; };
template <typename T> template <typename T>
@ -557,7 +561,8 @@ class MockStack : public StackInterface<T> {
MOCK_METHOD((std::map<int, int>), ReturnTypeWithComma, (int), (const)); MOCK_METHOD((std::map<int, int>), ReturnTypeWithComma, (int), (const));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack); MockStack(const MockStack&) = delete;
MockStack& operator=(const MockStack&) = delete;
}; };
template <typename T> template <typename T>
@ -575,7 +580,8 @@ class LegacyMockStack : public StackInterface<T> {
MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int)); // NOLINT MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int)); // NOLINT
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStack); LegacyMockStack(const LegacyMockStack&) = delete;
LegacyMockStack& operator=(const LegacyMockStack&) = delete;
}; };
template <typename T> template <typename T>
@ -645,7 +651,8 @@ class MockStackWithCallType : public StackInterfaceWithCallType<T> {
(Calltype(STDMETHODCALLTYPE), override, const)); (Calltype(STDMETHODCALLTYPE), override, const));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStackWithCallType); MockStackWithCallType(const MockStackWithCallType&) = delete;
MockStackWithCallType& operator=(const MockStackWithCallType&) = delete;
}; };
template <typename T> template <typename T>
@ -659,7 +666,9 @@ class LegacyMockStackWithCallType : public StackInterfaceWithCallType<T> {
MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&()); MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&());
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStackWithCallType); LegacyMockStackWithCallType(const LegacyMockStackWithCallType&) = delete;
LegacyMockStackWithCallType& operator=(const LegacyMockStackWithCallType&) =
delete;
}; };
template <typename T> template <typename T>
@ -709,7 +718,9 @@ class MockOverloadedOnArgNumber {
MY_MOCK_METHODS1_; MY_MOCK_METHODS1_;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnArgNumber); MockOverloadedOnArgNumber(const MockOverloadedOnArgNumber&) = delete;
MockOverloadedOnArgNumber& operator=(const MockOverloadedOnArgNumber&) =
delete;
}; };
class LegacyMockOverloadedOnArgNumber { class LegacyMockOverloadedOnArgNumber {
@ -719,7 +730,10 @@ class LegacyMockOverloadedOnArgNumber {
LEGACY_MY_MOCK_METHODS1_; LEGACY_MY_MOCK_METHODS1_;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockOverloadedOnArgNumber); LegacyMockOverloadedOnArgNumber(const LegacyMockOverloadedOnArgNumber&) =
delete;
LegacyMockOverloadedOnArgNumber& operator=(
const LegacyMockOverloadedOnArgNumber&) = delete;
}; };
template <typename T> template <typename T>
@ -751,7 +765,9 @@ class MockOverloadedOnConstness {
MY_MOCK_METHODS2_; MY_MOCK_METHODS2_;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnConstness); MockOverloadedOnConstness(const MockOverloadedOnConstness&) = delete;
MockOverloadedOnConstness& operator=(const MockOverloadedOnConstness&) =
delete;
}; };
TEST(MockMethodOverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody) { TEST(MockMethodOverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody) {

View File

@ -955,7 +955,8 @@ class AllArgsHelper {
MOCK_METHOD2(Helper, int(char x, int y)); MOCK_METHOD2(Helper, int(char x, int y));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(AllArgsHelper); AllArgsHelper(const AllArgsHelper&) = delete;
AllArgsHelper& operator=(const AllArgsHelper&) = delete;
}; };
TEST(AllArgsTest, WorksInWithClause) { TEST(AllArgsTest, WorksInWithClause) {
@ -982,7 +983,8 @@ class OptionalMatchersHelper {
MOCK_METHOD2(Overloaded, int(char x, int y)); MOCK_METHOD2(Overloaded, int(char x, int y));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(OptionalMatchersHelper); OptionalMatchersHelper(const OptionalMatchersHelper&) = delete;
OptionalMatchersHelper& operator=(const OptionalMatchersHelper&) = delete;
}; };
TEST(AllArgsTest, WorksWithoutMatchers) { TEST(AllArgsTest, WorksWithoutMatchers) {

View File

@ -579,7 +579,8 @@ class Base {
Base() {} Base() {}
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(Base); Base(const Base&) = delete;
Base& operator=(const Base&) = delete;
}; };
class Derived : public Base { class Derived : public Base {

View File

@ -342,7 +342,8 @@ class Uncopyable {
private: private:
int value_; int value_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(Uncopyable); Uncopyable(const Uncopyable&) = delete;
Uncopyable& operator=(const Uncopyable&) = delete;
}; };
// Returns true if and only if x.value() is positive. // Returns true if and only if x.value() is positive.
@ -2764,7 +2765,10 @@ class NativeArrayPassedAsPointerAndSize {
MOCK_METHOD(void, Helper, (int* array, int size)); MOCK_METHOD(void, Helper, (int* array, int size));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(NativeArrayPassedAsPointerAndSize); NativeArrayPassedAsPointerAndSize(const NativeArrayPassedAsPointerAndSize&) =
delete;
NativeArrayPassedAsPointerAndSize& operator=(
const NativeArrayPassedAsPointerAndSize&) = delete;
}; };
TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) { TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {

View File

@ -106,7 +106,8 @@ class NotCopyable {
private: private:
int value_; int value_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(NotCopyable); NotCopyable(const NotCopyable&) = delete;
NotCopyable& operator=(const NotCopyable&) = delete;
}; };
TEST(ByRefTest, AllowsNotCopyableConstValueInMatchers) { TEST(ByRefTest, AllowsNotCopyableConstValueInMatchers) {

View File

@ -45,7 +45,8 @@ class Mock {
MOCK_METHOD0(DoThis, void()); MOCK_METHOD0(DoThis, void());
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock); Mock(const Mock&) = delete;
Mock& operator=(const Mock&) = delete;
}; };
namespace testing { namespace testing {
@ -93,7 +94,8 @@ class MockFoo : public Foo {
MOCK_METHOD0(ReturnNonDefaultConstructible, NotDefaultConstructible()); MOCK_METHOD0(ReturnNonDefaultConstructible, NotDefaultConstructible());
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); MockFoo(const MockFoo&) = delete;
MockFoo& operator=(const MockFoo&) = delete;
}; };
class MockBar { class MockBar {
@ -117,7 +119,8 @@ class MockBar {
private: private:
std::string str_; std::string str_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar); MockBar(const MockBar&) = delete;
MockBar& operator=(const MockBar&) = delete;
}; };
class MockBaz { class MockBaz {

View File

@ -150,7 +150,8 @@ class MockA {
MOCK_METHOD2(ReturnInt, int(int x, int y)); MOCK_METHOD2(ReturnInt, int(int x, int y));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockA); MockA(const MockA&) = delete;
MockA& operator=(const MockA&) = delete;
}; };
class MockB { class MockB {
@ -161,7 +162,8 @@ class MockB {
MOCK_METHOD1(DoB, int(int n)); // NOLINT MOCK_METHOD1(DoB, int(int n)); // NOLINT
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB); MockB(const MockB&) = delete;
MockB& operator=(const MockB&) = delete;
}; };
class ReferenceHoldingMock { class ReferenceHoldingMock {
@ -171,7 +173,8 @@ class ReferenceHoldingMock {
MOCK_METHOD1(AcceptReference, void(std::shared_ptr<MockA>*)); MOCK_METHOD1(AcceptReference, void(std::shared_ptr<MockA>*));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(ReferenceHoldingMock); ReferenceHoldingMock(const ReferenceHoldingMock&) = delete;
ReferenceHoldingMock& operator=(const ReferenceHoldingMock&) = delete;
}; };
// Tests that EXPECT_CALL and ON_CALL compile in a presence of macro // Tests that EXPECT_CALL and ON_CALL compile in a presence of macro
@ -193,7 +196,8 @@ class MockCC : public CC {
MOCK_METHOD0(Method, int()); MOCK_METHOD0(Method, int());
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockCC); MockCC(const MockCC&) = delete;
MockCC& operator=(const MockCC&) = delete;
}; };
// Tests that a method with expanded name compiles. // Tests that a method with expanded name compiles.
@ -1894,7 +1898,8 @@ class MockC {
MOCK_METHOD0(NonVoidMethod, int()); // NOLINT MOCK_METHOD0(NonVoidMethod, int()); // NOLINT
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockC); MockC(const MockC&) = delete;
MockC& operator=(const MockC&) = delete;
}; };
class VerboseFlagPreservingFixture : public testing::Test { class VerboseFlagPreservingFixture : public testing::Test {
@ -1909,7 +1914,9 @@ class VerboseFlagPreservingFixture : public testing::Test {
private: private:
const std::string saved_verbose_flag_; const std::string saved_verbose_flag_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(VerboseFlagPreservingFixture); VerboseFlagPreservingFixture(const VerboseFlagPreservingFixture&) = delete;
VerboseFlagPreservingFixture& operator=(const VerboseFlagPreservingFixture&) =
delete;
}; };
#if GTEST_HAS_STREAM_REDIRECTION #if GTEST_HAS_STREAM_REDIRECTION
@ -2129,7 +2136,8 @@ class LogTestHelper {
MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot)); MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(LogTestHelper); LogTestHelper(const LogTestHelper&) = delete;
LogTestHelper& operator=(const LogTestHelper&) = delete;
}; };
class GMockLogTest : public VerboseFlagPreservingFixture { class GMockLogTest : public VerboseFlagPreservingFixture {

View File

@ -51,7 +51,8 @@ class MockFoo : public FooInterface {
MOCK_METHOD0(DoThis, void()); MOCK_METHOD0(DoThis, void());
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); MockFoo(const MockFoo&) = delete;
MockFoo& operator=(const MockFoo&) = delete;
}; };
TEST(LeakTest, LeakedMockWithExpectCallCausesFailureWhenLeakCheckingIsEnabled) { TEST(LeakTest, LeakedMockWithExpectCallCausesFailureWhenLeakCheckingIsEnabled) {

View File

@ -221,7 +221,8 @@ class Mock : public Interface {
MOCK_METHOD1(VoidFromVector, void(const std::vector<int>& v)); MOCK_METHOD1(VoidFromVector, void(const std::vector<int>& v));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock); Mock(const Mock&) = delete;
Mock& operator=(const Mock&) = delete;
}; };
class InvokeHelper { class InvokeHelper {

View File

@ -62,7 +62,8 @@ class MockFoo {
MOCK_METHOD2(Bar3, void(int x, int y)); MOCK_METHOD2(Bar3, void(int x, int y));
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); MockFoo(const MockFoo&) = delete;
MockFoo& operator=(const MockFoo&) = delete;
}; };
class GMockOutputTest : public testing::Test { class GMockOutputTest : public testing::Test {

View File

@ -102,7 +102,8 @@ class MatchResultListener {
private: private:
::std::ostream* const stream_; ::std::ostream* const stream_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener); MatchResultListener(const MatchResultListener&) = delete;
MatchResultListener& operator=(const MatchResultListener&) = delete;
}; };
inline MatchResultListener::~MatchResultListener() {} inline MatchResultListener::~MatchResultListener() {}
@ -220,7 +221,8 @@ class DummyMatchResultListener : public MatchResultListener {
DummyMatchResultListener() : MatchResultListener(nullptr) {} DummyMatchResultListener() : MatchResultListener(nullptr) {}
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener); DummyMatchResultListener(const DummyMatchResultListener&) = delete;
DummyMatchResultListener& operator=(const DummyMatchResultListener&) = delete;
}; };
// A match result listener that forwards the explanation to a given // A match result listener that forwards the explanation to a given
@ -232,7 +234,9 @@ class StreamMatchResultListener : public MatchResultListener {
: MatchResultListener(os) {} : MatchResultListener(os) {}
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener); StreamMatchResultListener(const StreamMatchResultListener&) = delete;
StreamMatchResultListener& operator=(const StreamMatchResultListener&) =
delete;
}; };
struct SharedPayloadBase { struct SharedPayloadBase {

View File

@ -429,8 +429,11 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
return 0; \ return 0; \
} \ } \
static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_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, \ int GTEST_TEST_CLASS_NAME_(test_suite_name, \
test_name)::gtest_registering_dummy_ = \ test_name)::gtest_registering_dummy_ = \

View File

@ -85,7 +85,10 @@ class GTEST_API_ ScopedFakeTestPartResultReporter
TestPartResultReporterInterface* old_reporter_; TestPartResultReporterInterface* old_reporter_;
TestPartResultArray* const result_; TestPartResultArray* const result_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter); ScopedFakeTestPartResultReporter(const ScopedFakeTestPartResultReporter&) =
delete;
ScopedFakeTestPartResultReporter& operator=(
const ScopedFakeTestPartResultReporter&) = delete;
}; };
namespace internal { namespace internal {
@ -107,7 +110,8 @@ class GTEST_API_ SingleFailureChecker {
const TestPartResult::Type type_; const TestPartResult::Type type_;
const std::string substr_; const std::string substr_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker); SingleFailureChecker(const SingleFailureChecker&) = delete;
SingleFailureChecker& operator=(const SingleFailureChecker&) = delete;
}; };
} // namespace internal } // namespace internal

View File

@ -145,7 +145,8 @@ class GTEST_API_ TestPartResultArray {
private: private:
std::vector<TestPartResult> array_; std::vector<TestPartResult> array_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray); TestPartResultArray(const TestPartResultArray&) = delete;
TestPartResultArray& operator=(const TestPartResultArray&) = delete;
}; };
// This interface knows how to report a test part result. // This interface knows how to report a test part result.
@ -176,7 +177,8 @@ class GTEST_API_ HasNewFatalFailureHelper
bool has_new_fatal_failure_; bool has_new_fatal_failure_;
TestPartResultReporterInterface* original_reporter_; TestPartResultReporterInterface* original_reporter_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper); HasNewFatalFailureHelper(const HasNewFatalFailureHelper&) = delete;
HasNewFatalFailureHelper& operator=(const HasNewFatalFailureHelper&) = delete;
}; };
} // namespace internal } // namespace internal

View File

@ -339,7 +339,8 @@ class GTEST_API_ Test {
virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; } virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
// We disallow copying Tests. // We disallow copying Tests.
GTEST_DISALLOW_COPY_AND_ASSIGN_(Test); Test(const Test&) = delete;
Test& operator=(const Test&) = delete;
}; };
typedef internal::TimeInMillis TimeInMillis; typedef internal::TimeInMillis TimeInMillis;
@ -497,7 +498,8 @@ class GTEST_API_ TestResult {
TimeInMillis elapsed_time_; TimeInMillis elapsed_time_;
// We disallow copying TestResult. // We disallow copying TestResult.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult); TestResult(const TestResult&) = delete;
TestResult& operator=(const TestResult&) = delete;
}; // class TestResult }; // class TestResult
// A TestInfo object stores the following information about a test: // A TestInfo object stores the following information about a test:
@ -643,7 +645,8 @@ class GTEST_API_ TestInfo {
// test for the second time. // test for the second time.
TestResult result_; TestResult result_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo); TestInfo(const TestInfo&) = delete;
TestInfo& operator=(const TestInfo&) = delete;
}; };
// A test suite, which consists of a vector of TestInfos. // A test suite, which consists of a vector of TestInfos.
@ -852,7 +855,8 @@ class GTEST_API_ TestSuite {
TestResult ad_hoc_test_result_; TestResult ad_hoc_test_result_;
// We disallow copying TestSuites. // We disallow copying TestSuites.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite); TestSuite(const TestSuite&) = delete;
TestSuite& operator=(const TestSuite&) = delete;
}; };
// An Environment object is capable of setting up and tearing down an // An Environment object is capable of setting up and tearing down an
@ -1072,7 +1076,8 @@ class GTEST_API_ TestEventListeners {
TestEventListener* default_xml_generator_; TestEventListener* default_xml_generator_;
// We disallow copying TestEventListeners. // We disallow copying TestEventListeners.
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners); TestEventListeners(const TestEventListeners&) = delete;
TestEventListeners& operator=(const TestEventListeners&) = delete;
}; };
// A UnitTest consists of a vector of TestSuites. // A UnitTest consists of a vector of TestSuites.
@ -1279,7 +1284,8 @@ class GTEST_API_ UnitTest {
internal::UnitTestImpl* impl_; internal::UnitTestImpl* impl_;
// We disallow copying UnitTest. // We disallow copying UnitTest.
GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest); UnitTest(const UnitTest&) = delete;
UnitTest& operator=(const UnitTest&) = delete;
}; };
// A convenient wrapper for adding an environment for the test // A convenient wrapper for adding an environment for the test
@ -1597,12 +1603,14 @@ class GTEST_API_ AssertHelper {
std::string const message; std::string const message;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData); AssertHelperData(const AssertHelperData&) = delete;
AssertHelperData& operator=(const AssertHelperData&) = delete;
}; };
AssertHelperData* const data_; AssertHelperData* const data_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper); AssertHelper(const AssertHelper&) = delete;
AssertHelper& operator=(const AssertHelper&) = delete;
}; };
} // namespace internal } // namespace internal
@ -2053,7 +2061,8 @@ class GTEST_API_ ScopedTrace {
private: private:
void PushTrace(const char* file, int line, std::string message); void PushTrace(const char* file, int line, std::string message);
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace); ScopedTrace(const ScopedTrace&) = delete;
ScopedTrace& operator=(const ScopedTrace&) = delete;
} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its } GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
// c'tor and d'tor. Therefore it doesn't // c'tor and d'tor. Therefore it doesn't
// need to be used otherwise. // need to be used otherwise.

View File

@ -97,7 +97,8 @@ class GTEST_API_ DeathTest {
private: private:
DeathTest* const test_; DeathTest* const test_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel); ReturnSentinel(const ReturnSentinel&) = delete;
ReturnSentinel& operator=(const ReturnSentinel&) = delete;
} GTEST_ATTRIBUTE_UNUSED_; } GTEST_ATTRIBUTE_UNUSED_;
// An enumeration of possible roles that may be taken when a death // An enumeration of possible roles that may be taken when a death
@ -142,7 +143,8 @@ class GTEST_API_ DeathTest {
// A string containing a description of the outcome of the last death test. // A string containing a description of the outcome of the last death test.
static std::string last_death_test_message_; static std::string last_death_test_message_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest); DeathTest(const DeathTest&) = delete;
DeathTest& operator=(const DeathTest&) = delete;
}; };
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
@ -287,7 +289,8 @@ class InternalRunDeathTestFlag {
int index_; int index_;
int write_fd_; int write_fd_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag); InternalRunDeathTestFlag(const InternalRunDeathTestFlag&) = delete;
InternalRunDeathTestFlag& operator=(const InternalRunDeathTestFlag&) = delete;
}; };
// Returns a newly created InternalRunDeathTestFlag object with fields // Returns a newly created InternalRunDeathTestFlag object with fields

View File

@ -465,7 +465,8 @@ class TestFactoryBase {
TestFactoryBase() {} TestFactoryBase() {}
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase); TestFactoryBase(const TestFactoryBase&) = delete;
TestFactoryBase& operator=(const TestFactoryBase&) = delete;
}; };
// This class provides implementation of TeastFactoryBase interface. // This class provides implementation of TeastFactoryBase interface.
@ -886,7 +887,8 @@ class GTEST_API_ Random {
private: private:
uint32_t state_; uint32_t state_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(Random); Random(const Random&) = delete;
Random& operator=(const Random&) = delete;
}; };
// Turns const U&, U&, const U, and U all into U. // Turns const U&, U&, const U, and U all into U.
@ -1534,37 +1536,43 @@ class NeverThrown {
test_suite_name##_##test_name##_Test test_suite_name##_##test_name##_Test
// Helper macro for defining tests. // Helper macro for defining tests.
#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \ #define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \ static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \
"test_suite_name must not be empty"); \ "test_suite_name must not be empty"); \
static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \ static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
"test_name must not be empty"); \ "test_name must not be empty"); \
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
: public parent_class { \ : public parent_class { \
public: \ public: \
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \
~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \ ~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
test_name)); \ (const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \
GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \
test_name)); \ const GTEST_TEST_CLASS_NAME_(test_suite_name, \
\ test_name) &) = delete; /* NOLINT */ \
private: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
void TestBody() override; \ (GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &&) noexcept = delete; \
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \
}; \ GTEST_TEST_CLASS_NAME_(test_suite_name, \
\ test_name) &&) noexcept = delete; /* NOLINT */ \
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \ \
test_name)::test_info_ = \ private: \
::testing::internal::MakeAndRegisterTestInfo( \ void TestBody() override; \
#test_suite_name, #test_name, nullptr, nullptr, \ static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \ }; \
::testing::internal::SuiteApiResolver< \ \
parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__), \ ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
::testing::internal::SuiteApiResolver< \ test_name)::test_info_ = \
parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__), \ ::testing::internal::MakeAndRegisterTestInfo( \
new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \ #test_suite_name, #test_name, nullptr, nullptr, \
test_suite_name, test_name)>); \ ::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \
::testing::internal::SuiteApiResolver< \
parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__), \
::testing::internal::SuiteApiResolver< \
parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__), \
new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
test_suite_name, test_name)>); \
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody() void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_

View File

@ -406,7 +406,8 @@ class ParameterizedTestFactory : public TestFactoryBase {
private: private:
const ParamType parameter_; const ParamType parameter_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory); ParameterizedTestFactory(const ParameterizedTestFactory&) = delete;
ParameterizedTestFactory& operator=(const ParameterizedTestFactory&) = delete;
}; };
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
@ -442,7 +443,8 @@ class TestMetaFactory
} }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory); TestMetaFactory(const TestMetaFactory&) = delete;
TestMetaFactory& operator=(const TestMetaFactory&) = delete;
}; };
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
@ -473,7 +475,10 @@ class ParameterizedTestSuiteInfoBase {
ParameterizedTestSuiteInfoBase() {} ParameterizedTestSuiteInfoBase() {}
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase); ParameterizedTestSuiteInfoBase(const ParameterizedTestSuiteInfoBase&) =
delete;
ParameterizedTestSuiteInfoBase& operator=(
const ParameterizedTestSuiteInfoBase&) = delete;
}; };
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
@ -664,7 +669,9 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
TestInfoContainer tests_; TestInfoContainer tests_;
InstantiationContainer instantiations_; InstantiationContainer instantiations_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo); ParameterizedTestSuiteInfo(const ParameterizedTestSuiteInfo&) = delete;
ParameterizedTestSuiteInfo& operator=(const ParameterizedTestSuiteInfo&) =
delete;
}; // class ParameterizedTestSuiteInfo }; // class ParameterizedTestSuiteInfo
// Legacy API is deprecated but still available // Legacy API is deprecated but still available
@ -739,7 +746,10 @@ class ParameterizedTestSuiteRegistry {
TestSuiteInfoContainer test_suite_infos_; TestSuiteInfoContainer test_suite_infos_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry); ParameterizedTestSuiteRegistry(const ParameterizedTestSuiteRegistry&) =
delete;
ParameterizedTestSuiteRegistry& operator=(
const ParameterizedTestSuiteRegistry&) = delete;
}; };
// Keep track of what type-parameterized test suite are defined and // Keep track of what type-parameterized test suite are defined and

View File

@ -192,8 +192,6 @@
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning. // GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a // GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
// variable don't have to be used. // variable don't have to be used.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and 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_MUST_USE_RESULT_ - declares that a function's result must be used.
// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is // GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
// suppressed (constant conditional). // suppressed (constant conditional).
@ -689,20 +687,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
#endif #endif
// A macro to disallow copy constructor and operator=
// This should be used in the private: declarations for a class.
// NOLINT is for modernize-use-trailing-return-type in macro uses.
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \
type(type const&) = delete; \
type& operator=(type const&) = delete /* NOLINT */
// A macro to disallow move constructor and operator=
// This should be used in the private: declarations for a class.
// NOLINT is for modernize-use-trailing-return-type in macro uses.
#define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \
type(type&&) noexcept = delete; \
type& operator=(type&&) noexcept = delete /* NOLINT */
// Tell the compiler to warn about unused return values for functions declared // Tell the compiler to warn about unused return values for functions declared
// with this macro. The macro should be used on function declarations // with this macro. The macro should be used on function declarations
// following the argument list: // following the argument list:
@ -971,7 +955,8 @@ class GTEST_API_ GTestLog {
private: private:
const GTestLogSeverity severity_; const GTestLogSeverity severity_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog); GTestLog(const GTestLog&) = delete;
GTestLog& operator=(const GTestLog&) = delete;
}; };
#if !defined(GTEST_LOG_) #if !defined(GTEST_LOG_)
@ -1191,7 +1176,8 @@ class GTEST_API_ AutoHandle {
Handle handle_; Handle handle_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle); AutoHandle(const AutoHandle&) = delete;
AutoHandle& operator=(const AutoHandle&) = delete;
}; };
#endif #endif
@ -1314,7 +1300,8 @@ class ThreadWithParam : public ThreadWithParamBase {
// finished. // finished.
pthread_t thread_; // The native thread object. pthread_t thread_; // The native thread object.
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); ThreadWithParam(const ThreadWithParam&) = delete;
ThreadWithParam& operator=(const ThreadWithParam&) = delete;
}; };
#endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD || #endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
// GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
@ -1377,7 +1364,8 @@ class GTEST_API_ Mutex {
long critical_section_init_phase_; // NOLINT long critical_section_init_phase_; // NOLINT
GTEST_CRITICAL_SECTION* critical_section_; GTEST_CRITICAL_SECTION* critical_section_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); Mutex(const Mutex&) = delete;
Mutex& operator=(const Mutex&) = delete;
}; };
#define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ #define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
@ -1400,7 +1388,8 @@ class GTestMutexLock {
private: private:
Mutex* const mutex_; Mutex* const mutex_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock); GTestMutexLock(const GTestMutexLock&) = delete;
GTestMutexLock& operator=(const GTestMutexLock&) = delete;
}; };
typedef GTestMutexLock MutexLock; typedef GTestMutexLock MutexLock;
@ -1427,7 +1416,8 @@ class ThreadLocalBase {
virtual ~ThreadLocalBase() {} virtual ~ThreadLocalBase() {}
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase); ThreadLocalBase(const ThreadLocalBase&) = delete;
ThreadLocalBase& operator=(const ThreadLocalBase&) = delete;
}; };
// Maps a thread to a set of ThreadLocals that have values instantiated on that // Maps a thread to a set of ThreadLocals that have values instantiated on that
@ -1484,10 +1474,12 @@ class ThreadWithParam : public ThreadWithParamBase {
UserThreadFunc* const func_; UserThreadFunc* const func_;
const T param_; const T param_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl); RunnableImpl(const RunnableImpl&) = delete;
RunnableImpl& operator=(const RunnableImpl&) = delete;
}; };
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); ThreadWithParam(const ThreadWithParam&) = delete;
ThreadWithParam& operator=(const ThreadWithParam&) = delete;
}; };
// Implements thread-local storage on Windows systems. // Implements thread-local storage on Windows systems.
@ -1543,7 +1535,8 @@ class ThreadLocal : public ThreadLocalBase {
private: private:
T value_; T value_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder); ValueHolder(const ValueHolder&) = delete;
ValueHolder& operator=(const ValueHolder&) = delete;
}; };
T* GetOrCreateValue() const { T* GetOrCreateValue() const {
@ -1563,7 +1556,8 @@ class ThreadLocal : public ThreadLocalBase {
virtual ValueHolder* MakeNewHolder() const = 0; virtual ValueHolder* MakeNewHolder() const = 0;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory); ValueHolderFactory(const ValueHolderFactory&) = delete;
ValueHolderFactory& operator=(const ValueHolderFactory&) = delete;
}; };
class DefaultValueHolderFactory : public ValueHolderFactory { class DefaultValueHolderFactory : public ValueHolderFactory {
@ -1572,7 +1566,9 @@ class ThreadLocal : public ThreadLocalBase {
ValueHolder* MakeNewHolder() const override { return new ValueHolder(); } ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory); DefaultValueHolderFactory(const DefaultValueHolderFactory&) = delete;
DefaultValueHolderFactory& operator=(const DefaultValueHolderFactory&) =
delete;
}; };
class InstanceValueHolderFactory : public ValueHolderFactory { class InstanceValueHolderFactory : public ValueHolderFactory {
@ -1585,12 +1581,15 @@ class ThreadLocal : public ThreadLocalBase {
private: private:
const T value_; // The value for each thread. const T value_; // The value for each thread.
GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory); InstanceValueHolderFactory(const InstanceValueHolderFactory&) = delete;
InstanceValueHolderFactory& operator=(const InstanceValueHolderFactory&) =
delete;
}; };
std::unique_ptr<ValueHolderFactory> default_factory_; std::unique_ptr<ValueHolderFactory> default_factory_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); ThreadLocal(const ThreadLocal&) = delete;
ThreadLocal& operator=(const ThreadLocal&) = delete;
}; };
#elif GTEST_HAS_PTHREAD #elif GTEST_HAS_PTHREAD
@ -1663,7 +1662,8 @@ class Mutex : public MutexBase {
~Mutex() { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_)); } ~Mutex() { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_)); }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); Mutex(const Mutex&) = delete;
Mutex& operator=(const Mutex&) = delete;
}; };
// We cannot name this class MutexLock because the ctor declaration would // We cannot name this class MutexLock because the ctor declaration would
@ -1680,7 +1680,8 @@ class GTestMutexLock {
private: private:
MutexBase* const mutex_; MutexBase* const mutex_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock); GTestMutexLock(const GTestMutexLock&) = delete;
GTestMutexLock& operator=(const GTestMutexLock&) = delete;
}; };
typedef GTestMutexLock MutexLock; typedef GTestMutexLock MutexLock;
@ -1737,7 +1738,8 @@ class GTEST_API_ ThreadLocal {
private: private:
T value_; T value_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder); ValueHolder(const ValueHolder&) = delete;
ValueHolder& operator=(const ValueHolder&) = delete;
}; };
static pthread_key_t CreateKey() { static pthread_key_t CreateKey() {
@ -1769,7 +1771,8 @@ class GTEST_API_ ThreadLocal {
virtual ValueHolder* MakeNewHolder() const = 0; virtual ValueHolder* MakeNewHolder() const = 0;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory); ValueHolderFactory(const ValueHolderFactory&) = delete;
ValueHolderFactory& operator=(const ValueHolderFactory&) = delete;
}; };
class DefaultValueHolderFactory : public ValueHolderFactory { class DefaultValueHolderFactory : public ValueHolderFactory {
@ -1778,7 +1781,9 @@ class GTEST_API_ ThreadLocal {
ValueHolder* MakeNewHolder() const override { return new ValueHolder(); } ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory); DefaultValueHolderFactory(const DefaultValueHolderFactory&) = delete;
DefaultValueHolderFactory& operator=(const DefaultValueHolderFactory&) =
delete;
}; };
class InstanceValueHolderFactory : public ValueHolderFactory { class InstanceValueHolderFactory : public ValueHolderFactory {
@ -1791,14 +1796,17 @@ class GTEST_API_ ThreadLocal {
private: private:
const T value_; // The value for each thread. const T value_; // The value for each thread.
GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory); InstanceValueHolderFactory(const InstanceValueHolderFactory&) = delete;
InstanceValueHolderFactory& operator=(const InstanceValueHolderFactory&) =
delete;
}; };
// A key pthreads uses for looking up per-thread values. // A key pthreads uses for looking up per-thread values.
const pthread_key_t key_; const pthread_key_t key_;
std::unique_ptr<ValueHolderFactory> default_factory_; std::unique_ptr<ValueHolderFactory> default_factory_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); ThreadLocal(const ThreadLocal&) = delete;
ThreadLocal& operator=(const ThreadLocal&) = delete;
}; };
#endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ #endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_

View File

@ -424,7 +424,9 @@ class OsStackTraceGetterInterface {
static const char* const kElidedFramesMarker; static const char* const kElidedFramesMarker;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface); OsStackTraceGetterInterface(const OsStackTraceGetterInterface&) = delete;
OsStackTraceGetterInterface& operator=(const OsStackTraceGetterInterface&) =
delete;
}; };
// A working implementation of the OsStackTraceGetterInterface interface. // A working implementation of the OsStackTraceGetterInterface interface.
@ -446,7 +448,8 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface {
void* caller_frame_ = nullptr; void* caller_frame_ = nullptr;
#endif // GTEST_HAS_ABSL #endif // GTEST_HAS_ABSL
GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter); OsStackTraceGetter(const OsStackTraceGetter&) = delete;
OsStackTraceGetter& operator=(const OsStackTraceGetter&) = delete;
}; };
// Information about a Google Test trace point. // Information about a Google Test trace point.
@ -469,7 +472,10 @@ class DefaultGlobalTestPartResultReporter
private: private:
UnitTestImpl* const unit_test_; UnitTestImpl* const unit_test_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter); DefaultGlobalTestPartResultReporter(
const DefaultGlobalTestPartResultReporter&) = delete;
DefaultGlobalTestPartResultReporter& operator=(
const DefaultGlobalTestPartResultReporter&) = delete;
}; };
// This is the default per thread test part result reporter used in // This is the default per thread test part result reporter used in
@ -485,7 +491,10 @@ class DefaultPerThreadTestPartResultReporter
private: private:
UnitTestImpl* const unit_test_; UnitTestImpl* const unit_test_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter); DefaultPerThreadTestPartResultReporter(
const DefaultPerThreadTestPartResultReporter&) = delete;
DefaultPerThreadTestPartResultReporter& operator=(
const DefaultPerThreadTestPartResultReporter&) = delete;
}; };
// The private implementation of the UnitTest class. We don't protect // The private implementation of the UnitTest class. We don't protect
@ -942,7 +951,8 @@ class GTEST_API_ UnitTestImpl {
// starts. // starts.
bool catch_exceptions_; bool catch_exceptions_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl); UnitTestImpl(const UnitTestImpl&) = delete;
UnitTestImpl& operator=(const UnitTestImpl&) = delete;
}; // class UnitTestImpl }; // class UnitTestImpl
// Convenience function for accessing the global UnitTest // Convenience function for accessing the global UnitTest
@ -1101,7 +1111,8 @@ class StreamingListener : public EmptyTestEventListener {
const std::string host_name_; const std::string host_name_;
const std::string port_num_; const std::string port_num_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter); SocketWriter(const SocketWriter&) = delete;
SocketWriter& operator=(const SocketWriter&) = delete;
}; // class SocketWriter }; // class SocketWriter
// Escapes '=', '&', '%', and '\n' characters in str as "%xx". // Escapes '=', '&', '%', and '\n' characters in str as "%xx".
@ -1187,7 +1198,8 @@ class StreamingListener : public EmptyTestEventListener {
const std::unique_ptr<AbstractSocketWriter> socket_writer_; const std::unique_ptr<AbstractSocketWriter> socket_writer_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener); StreamingListener(const StreamingListener&) = delete;
StreamingListener& operator=(const StreamingListener&) = delete;
}; // class StreamingListener }; // class StreamingListener
#endif // GTEST_CAN_STREAM_RESULTS_ #endif // GTEST_CAN_STREAM_RESULTS_

View File

@ -374,7 +374,8 @@ class MemoryIsNotDeallocated {
private: private:
int old_crtdbg_flag_; int old_crtdbg_flag_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(MemoryIsNotDeallocated); MemoryIsNotDeallocated(const MemoryIsNotDeallocated&) = delete;
MemoryIsNotDeallocated& operator=(const MemoryIsNotDeallocated&) = delete;
}; };
#endif // _MSC_VER #endif // _MSC_VER
@ -469,7 +470,8 @@ class ThreadWithParamSupport : public ThreadWithParamBase {
// Prohibit instantiation. // Prohibit instantiation.
ThreadWithParamSupport(); ThreadWithParamSupport();
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParamSupport); ThreadWithParamSupport(const ThreadWithParamSupport&) = delete;
ThreadWithParamSupport& operator=(const ThreadWithParamSupport&) = delete;
}; };
} // namespace } // namespace
@ -1146,7 +1148,8 @@ class CapturedStream {
// Name of the temporary file holding the stderr output. // Name of the temporary file holding the stderr output.
::std::string filename_; ::std::string filename_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream); CapturedStream(const CapturedStream&) = delete;
CapturedStream& operator=(const CapturedStream&) = delete;
}; };
GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_DEPRECATED_POP_()

View File

@ -3800,7 +3800,8 @@ class TestEventRepeater : public TestEventListener {
// The list of listeners that receive events. // The list of listeners that receive events.
std::vector<TestEventListener*> listeners_; std::vector<TestEventListener*> listeners_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater); TestEventRepeater(const TestEventRepeater&) = delete;
TestEventRepeater& operator=(const TestEventRepeater&) = delete;
}; };
TestEventRepeater::~TestEventRepeater() { TestEventRepeater::~TestEventRepeater() {
@ -3978,7 +3979,8 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
// The output file. // The output file.
const std::string output_file_; const std::string output_file_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter); XmlUnitTestResultPrinter(const XmlUnitTestResultPrinter&) = delete;
XmlUnitTestResultPrinter& operator=(const XmlUnitTestResultPrinter&) = delete;
}; };
// Creates a new XmlUnitTestResultPrinter. // Creates a new XmlUnitTestResultPrinter.
@ -4491,7 +4493,9 @@ class JsonUnitTestResultPrinter : public EmptyTestEventListener {
// The output file. // The output file.
const std::string output_file_; const std::string output_file_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(JsonUnitTestResultPrinter); JsonUnitTestResultPrinter(const JsonUnitTestResultPrinter&) = delete;
JsonUnitTestResultPrinter& operator=(const JsonUnitTestResultPrinter&) =
delete;
}; };
// Creates a new JsonUnitTestResultPrinter. // Creates a new JsonUnitTestResultPrinter.
@ -5041,7 +5045,8 @@ class ScopedPrematureExitFile {
private: private:
const std::string premature_exit_filepath_; const std::string premature_exit_filepath_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile); ScopedPrematureExitFile(const ScopedPrematureExitFile&) = delete;
ScopedPrematureExitFile& operator=(const ScopedPrematureExitFile&) = delete;
}; };
} // namespace internal } // namespace internal

View File

@ -598,7 +598,9 @@ class TestGenerationEnvironment : public ::testing::Environment {
int tear_down_count_; int tear_down_count_;
int test_body_count_; int test_body_count_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationEnvironment); TestGenerationEnvironment(const TestGenerationEnvironment&) = delete;
TestGenerationEnvironment& operator=(const TestGenerationEnvironment&) =
delete;
}; };
const int test_generation_params[] = {36, 42, 72}; const int test_generation_params[] = {36, 42, 72};
@ -663,7 +665,8 @@ class TestGenerationTest : public TestWithParam<int> {
static vector<int> collected_parameters_; static vector<int> collected_parameters_;
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationTest); TestGenerationTest(const TestGenerationTest&) = delete;
TestGenerationTest& operator=(const TestGenerationTest&) = delete;
}; };
vector<int> TestGenerationTest::collected_parameters_; vector<int> TestGenerationTest::collected_parameters_;

View File

@ -1186,7 +1186,8 @@ class DestructorCall {
#endif #endif
static std::vector<DestructorCall*>* const list_; static std::vector<DestructorCall*>* const list_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(DestructorCall); DestructorCall(const DestructorCall&) = delete;
DestructorCall& operator=(const DestructorCall&) = delete;
}; };
std::vector<DestructorCall*>* const DestructorCall::list_ = std::vector<DestructorCall*>* const DestructorCall::list_ =

View File

@ -6884,7 +6884,8 @@ class SequenceTestingListener : public EmptyTestEventListener {
std::vector<std::string>* vector_; std::vector<std::string>* vector_;
const char* const id_; const char* const id_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(SequenceTestingListener); SequenceTestingListener(const SequenceTestingListener&) = delete;
SequenceTestingListener& operator=(const SequenceTestingListener&) = delete;
}; };
TEST(EventListenerTest, AppendKeepsOrder) { TEST(EventListenerTest, AppendKeepsOrder) {