Skip to content

Commit bf66935

Browse files
derekmaurocopybara-github
authored andcommitted
Remove the legacy internal GTEST_DISALLOW_* macros
PiperOrigin-RevId: 443715444 Change-Id: I3ffd54b63d2728ae4a668ee7875c8c3c8188087c
1 parent b85864c commit bf66935

32 files changed

+290
-159
lines changed

googlemock/include/gmock/gmock-actions.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ class DefaultValue {
393393

394394
private:
395395
const T value_;
396-
GTEST_DISALLOW_COPY_AND_ASSIGN_(FixedValueProducer);
396+
FixedValueProducer(const FixedValueProducer&) = delete;
397+
FixedValueProducer& operator=(const FixedValueProducer&) = delete;
397398
};
398399

399400
class FactoryValueProducer : public ValueProducer {
@@ -404,7 +405,8 @@ class DefaultValue {
404405

405406
private:
406407
const FactoryFunction factory_;
407-
GTEST_DISALLOW_COPY_AND_ASSIGN_(FactoryValueProducer);
408+
FactoryValueProducer(const FactoryValueProducer&) = delete;
409+
FactoryValueProducer& operator=(const FactoryValueProducer&) = delete;
408410
};
409411

410412
static ValueProducer* producer_;
@@ -478,7 +480,8 @@ class ActionInterface {
478480
virtual Result Perform(const ArgumentTuple& args) = 0;
479481

480482
private:
481-
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);
483+
ActionInterface(const ActionInterface&) = delete;
484+
ActionInterface& operator=(const ActionInterface&) = delete;
482485
};
483486

484487
// An Action<F> is a copyable and IMMUTABLE (except by assignment)
@@ -951,7 +954,8 @@ class ReturnAction {
951954
R value_before_cast_;
952955
Result value_;
953956

954-
GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);
957+
Impl(const Impl&) = delete;
958+
Impl& operator=(const Impl&) = delete;
955959
};
956960

957961
// Partially specialize for ByMoveWrapper. This version of ReturnAction will

googlemock/include/gmock/gmock-matchers.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ class StringMatchResultListener : public MatchResultListener {
313313
private:
314314
::std::stringstream ss_;
315315

316-
GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener);
316+
StringMatchResultListener(const StringMatchResultListener&) = delete;
317+
StringMatchResultListener& operator=(const StringMatchResultListener&) =
318+
delete;
317319
};
318320

319321
// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
@@ -2555,7 +2557,8 @@ class WhenSortedByMatcher {
25552557
const Comparator comparator_;
25562558
const Matcher<const ::std::vector<LhsValue>&> matcher_;
25572559

2558-
GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);
2560+
Impl(const Impl&) = delete;
2561+
Impl& operator=(const Impl&) = delete;
25592562
};
25602563

25612564
private:

googlemock/include/gmock/gmock-nice-strict.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ class GTEST_INTERNAL_EMPTY_BASE_CLASS NiceMock
169169
}
170170

171171
private:
172-
GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
172+
NiceMock(const NiceMock&) = delete;
173+
NiceMock& operator=(const NiceMock&) = delete;
173174
};
174175

175176
template <class MockClass>
@@ -210,7 +211,8 @@ class GTEST_INTERNAL_EMPTY_BASE_CLASS NaggyMock
210211
}
211212

212213
private:
213-
GTEST_DISALLOW_COPY_AND_ASSIGN_(NaggyMock);
214+
NaggyMock(const NaggyMock&) = delete;
215+
NaggyMock& operator=(const NaggyMock&) = delete;
214216
};
215217

216218
template <class MockClass>
@@ -251,7 +253,8 @@ class GTEST_INTERNAL_EMPTY_BASE_CLASS StrictMock
251253
}
252254

253255
private:
254-
GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
256+
StrictMock(const StrictMock&) = delete;
257+
StrictMock& operator=(const StrictMock&) = delete;
255258
};
256259

257260
#undef GTEST_INTERNAL_EMPTY_BASE_CLASS

googlemock/include/gmock/gmock-spec-builders.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,8 @@ class GTEST_API_ InSequence {
677677
private:
678678
bool sequence_created_;
679679

680-
GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence); // NOLINT
680+
InSequence(const InSequence&) = delete;
681+
InSequence& operator=(const InSequence&) = delete;
681682
} GTEST_ATTRIBUTE_UNUSED_;
682683

683684
namespace internal {
@@ -1219,7 +1220,8 @@ class TypedExpectation : public ExpectationBase {
12191220
Matcher<const ArgumentTuple&> extra_matcher_;
12201221
Action<F> repeated_action_;
12211222

1222-
GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
1223+
TypedExpectation(const TypedExpectation&) = delete;
1224+
TypedExpectation& operator=(const TypedExpectation&) = delete;
12231225
}; // class TypedExpectation
12241226

12251227
// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
@@ -1392,7 +1394,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
13921394

13931395
Wrapper result_;
13941396

1395-
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);
1397+
ActionResultHolder(const ActionResultHolder&) = delete;
1398+
ActionResultHolder& operator=(const ActionResultHolder&) = delete;
13961399
};
13971400

13981401
// Specialization for T = void.
@@ -1425,7 +1428,8 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
14251428

14261429
private:
14271430
ActionResultHolder() {}
1428-
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);
1431+
ActionResultHolder(const ActionResultHolder&) = delete;
1432+
ActionResultHolder& operator=(const ActionResultHolder&) = delete;
14291433
};
14301434

14311435
template <typename F>

googlemock/src/gmock-cardinalities.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class BetweenCardinalityImpl : public CardinalityInterface {
8686
const int min_;
8787
const int max_;
8888

89-
GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl);
89+
BetweenCardinalityImpl(const BetweenCardinalityImpl&) = delete;
90+
BetweenCardinalityImpl& operator=(const BetweenCardinalityImpl&) = delete;
9091
};
9192

9293
// Formats "n times" in a human-friendly way.

googlemock/test/gmock-actions_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,8 @@ class MockClass {
869869
int(const std::unique_ptr<int>&, std::unique_ptr<int>));
870870

871871
private:
872-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockClass);
872+
MockClass(const MockClass&) = delete;
873+
MockClass& operator=(const MockClass&) = delete;
873874
};
874875

875876
// Tests that DoDefault() returns the built-in default value for the

googlemock/test/gmock-cardinalities_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class MockFoo {
5454
MOCK_METHOD0(Bar, int()); // NOLINT
5555

5656
private:
57-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
57+
MockFoo(const MockFoo&) = delete;
58+
MockFoo& operator=(const MockFoo&) = delete;
5859
};
5960

6061
// Tests that Cardinality objects can be default constructed.

googlemock/test/gmock-function-mocker_test.cc

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ class MockFoo : public FooInterface {
202202
MOCK_METHOD(int, RefQualifiedOverloaded, (), (ref(&&), override));
203203

204204
private:
205-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
205+
MockFoo(const MockFoo&) = delete;
206+
MockFoo& operator=(const MockFoo&) = delete;
206207
};
207208

208209
class LegacyMockFoo : public FooInterface {
@@ -274,7 +275,8 @@ class LegacyMockFoo : public FooInterface {
274275
int RefQualifiedOverloaded() && override { return 0; }
275276

276277
private:
277-
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockFoo);
278+
LegacyMockFoo(const LegacyMockFoo&) = delete;
279+
LegacyMockFoo& operator=(const LegacyMockFoo&) = delete;
278280
};
279281

280282
#ifdef _MSC_VER
@@ -492,7 +494,8 @@ class MockB {
492494
MOCK_METHOD(void, DoB, ());
493495

494496
private:
495-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);
497+
MockB(const MockB&) = delete;
498+
MockB& operator=(const MockB&) = delete;
496499
};
497500

498501
class LegacyMockB {
@@ -502,7 +505,8 @@ class LegacyMockB {
502505
MOCK_METHOD0(DoB, void());
503506

504507
private:
505-
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockB);
508+
LegacyMockB(const LegacyMockB&) = delete;
509+
LegacyMockB& operator=(const LegacyMockB&) = delete;
506510
};
507511

508512
template <typename T>
@@ -557,7 +561,8 @@ class MockStack : public StackInterface<T> {
557561
MOCK_METHOD((std::map<int, int>), ReturnTypeWithComma, (int), (const));
558562

559563
private:
560-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack);
564+
MockStack(const MockStack&) = delete;
565+
MockStack& operator=(const MockStack&) = delete;
561566
};
562567

563568
template <typename T>
@@ -575,7 +580,8 @@ class LegacyMockStack : public StackInterface<T> {
575580
MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int)); // NOLINT
576581

577582
private:
578-
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStack);
583+
LegacyMockStack(const LegacyMockStack&) = delete;
584+
LegacyMockStack& operator=(const LegacyMockStack&) = delete;
579585
};
580586

581587
template <typename T>
@@ -645,7 +651,8 @@ class MockStackWithCallType : public StackInterfaceWithCallType<T> {
645651
(Calltype(STDMETHODCALLTYPE), override, const));
646652

647653
private:
648-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStackWithCallType);
654+
MockStackWithCallType(const MockStackWithCallType&) = delete;
655+
MockStackWithCallType& operator=(const MockStackWithCallType&) = delete;
649656
};
650657

651658
template <typename T>
@@ -659,7 +666,9 @@ class LegacyMockStackWithCallType : public StackInterfaceWithCallType<T> {
659666
MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&());
660667

661668
private:
662-
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockStackWithCallType);
669+
LegacyMockStackWithCallType(const LegacyMockStackWithCallType&) = delete;
670+
LegacyMockStackWithCallType& operator=(const LegacyMockStackWithCallType&) =
671+
delete;
663672
};
664673

665674
template <typename T>
@@ -709,7 +718,9 @@ class MockOverloadedOnArgNumber {
709718
MY_MOCK_METHODS1_;
710719

711720
private:
712-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnArgNumber);
721+
MockOverloadedOnArgNumber(const MockOverloadedOnArgNumber&) = delete;
722+
MockOverloadedOnArgNumber& operator=(const MockOverloadedOnArgNumber&) =
723+
delete;
713724
};
714725

715726
class LegacyMockOverloadedOnArgNumber {
@@ -719,7 +730,10 @@ class LegacyMockOverloadedOnArgNumber {
719730
LEGACY_MY_MOCK_METHODS1_;
720731

721732
private:
722-
GTEST_DISALLOW_COPY_AND_ASSIGN_(LegacyMockOverloadedOnArgNumber);
733+
LegacyMockOverloadedOnArgNumber(const LegacyMockOverloadedOnArgNumber&) =
734+
delete;
735+
LegacyMockOverloadedOnArgNumber& operator=(
736+
const LegacyMockOverloadedOnArgNumber&) = delete;
723737
};
724738

725739
template <typename T>
@@ -751,7 +765,9 @@ class MockOverloadedOnConstness {
751765
MY_MOCK_METHODS2_;
752766

753767
private:
754-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnConstness);
768+
MockOverloadedOnConstness(const MockOverloadedOnConstness&) = delete;
769+
MockOverloadedOnConstness& operator=(const MockOverloadedOnConstness&) =
770+
delete;
755771
};
756772

757773
TEST(MockMethodOverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody) {

googlemock/test/gmock-matchers-arithmetic_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ class AllArgsHelper {
955955
MOCK_METHOD2(Helper, int(char x, int y));
956956

957957
private:
958-
GTEST_DISALLOW_COPY_AND_ASSIGN_(AllArgsHelper);
958+
AllArgsHelper(const AllArgsHelper&) = delete;
959+
AllArgsHelper& operator=(const AllArgsHelper&) = delete;
959960
};
960961

961962
TEST(AllArgsTest, WorksInWithClause) {
@@ -982,7 +983,8 @@ class OptionalMatchersHelper {
982983
MOCK_METHOD2(Overloaded, int(char x, int y));
983984

984985
private:
985-
GTEST_DISALLOW_COPY_AND_ASSIGN_(OptionalMatchersHelper);
986+
OptionalMatchersHelper(const OptionalMatchersHelper&) = delete;
987+
OptionalMatchersHelper& operator=(const OptionalMatchersHelper&) = delete;
986988
};
987989

988990
TEST(AllArgsTest, WorksWithoutMatchers) {

googlemock/test/gmock-matchers-comparisons_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ class Base {
579579
Base() {}
580580

581581
private:
582-
GTEST_DISALLOW_COPY_AND_ASSIGN_(Base);
582+
Base(const Base&) = delete;
583+
Base& operator=(const Base&) = delete;
583584
};
584585

585586
class Derived : public Base {

googlemock/test/gmock-matchers-containers_test.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ class Uncopyable {
342342

343343
private:
344344
int value_;
345-
GTEST_DISALLOW_COPY_AND_ASSIGN_(Uncopyable);
345+
Uncopyable(const Uncopyable&) = delete;
346+
Uncopyable& operator=(const Uncopyable&) = delete;
346347
};
347348

348349
// Returns true if and only if x.value() is positive.
@@ -2764,7 +2765,10 @@ class NativeArrayPassedAsPointerAndSize {
27642765
MOCK_METHOD(void, Helper, (int* array, int size));
27652766

27662767
private:
2767-
GTEST_DISALLOW_COPY_AND_ASSIGN_(NativeArrayPassedAsPointerAndSize);
2768+
NativeArrayPassedAsPointerAndSize(const NativeArrayPassedAsPointerAndSize&) =
2769+
delete;
2770+
NativeArrayPassedAsPointerAndSize& operator=(
2771+
const NativeArrayPassedAsPointerAndSize&) = delete;
27682772
};
27692773

27702774
TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {

googlemock/test/gmock-matchers-misc_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class NotCopyable {
106106
private:
107107
int value_;
108108

109-
GTEST_DISALLOW_COPY_AND_ASSIGN_(NotCopyable);
109+
NotCopyable(const NotCopyable&) = delete;
110+
NotCopyable& operator=(const NotCopyable&) = delete;
110111
};
111112

112113
TEST(ByRefTest, AllowsNotCopyableConstValueInMatchers) {

googlemock/test/gmock-nice-strict_test.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class Mock {
4545
MOCK_METHOD0(DoThis, void());
4646

4747
private:
48-
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock);
48+
Mock(const Mock&) = delete;
49+
Mock& operator=(const Mock&) = delete;
4950
};
5051

5152
namespace testing {
@@ -93,7 +94,8 @@ class MockFoo : public Foo {
9394
MOCK_METHOD0(ReturnNonDefaultConstructible, NotDefaultConstructible());
9495

9596
private:
96-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
97+
MockFoo(const MockFoo&) = delete;
98+
MockFoo& operator=(const MockFoo&) = delete;
9799
};
98100

99101
class MockBar {
@@ -117,7 +119,8 @@ class MockBar {
117119
private:
118120
std::string str_;
119121

120-
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar);
122+
MockBar(const MockBar&) = delete;
123+
MockBar& operator=(const MockBar&) = delete;
121124
};
122125

123126
class MockBaz {

0 commit comments

Comments
 (0)