Skip to content

Commit

Permalink
Use '=default' to define trivial constructor/destructors
Browse files Browse the repository at this point in the history
https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html

PiperOrigin-RevId: 526079054
Change-Id: Ia4db21e3e5f58b90de05d52fd94b291ed06d785d
  • Loading branch information
thughes authored and copybara-github committed Apr 21, 2023
1 parent baf182e commit 783d00f
Show file tree
Hide file tree
Showing 30 changed files with 96 additions and 96 deletions.
8 changes: 4 additions & 4 deletions googlemock/include/gmock/gmock-actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ class DefaultValue {
private:
class ValueProducer {
public:
virtual ~ValueProducer() {}
virtual ~ValueProducer() = default;
virtual T Produce() = 0;
};

Expand Down Expand Up @@ -699,8 +699,8 @@ class ActionInterface {
typedef typename internal::Function<F>::Result Result;
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;

ActionInterface() {}
virtual ~ActionInterface() {}
ActionInterface() = default;
virtual ~ActionInterface() = default;

// Performs the action. This method is not const, as in general an
// action can have side effects and be stateful. For example, a
Expand Down Expand Up @@ -749,7 +749,7 @@ class Action<R(Args...)> {

// Constructs a null Action. Needed for storing Action objects in
// STL containers.
Action() {}
Action() = default;

// Construct an Action from a specified callable.
// This cannot take std::function directly, because then Action would not be
Expand Down
4 changes: 2 additions & 2 deletions googlemock/include/gmock/gmock-cardinalities.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace testing {
// The implementation of a cardinality.
class CardinalityInterface {
public:
virtual ~CardinalityInterface() {}
virtual ~CardinalityInterface() = default;

// Conservative estimate on the lower/upper bound of the number of
// calls allowed.
Expand All @@ -92,7 +92,7 @@ class GTEST_API_ Cardinality {
public:
// Constructs a null cardinality. Needed for storing Cardinality
// objects in STL containers.
Cardinality() {}
Cardinality() = default;

// Constructs a Cardinality from its implementation.
explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
Expand Down
4 changes: 2 additions & 2 deletions googlemock/include/gmock/gmock-spec-builders.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class ExpectationSet {
typedef Expectation::Set::value_type value_type;

// Constructs an empty set.
ExpectationSet() {}
ExpectationSet() = default;

// This single-argument ctor must not be explicit, in order to support the
// ExpectationSet es = EXPECT_CALL(...);
Expand Down Expand Up @@ -1446,7 +1446,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
using ArgumentTuple = std::tuple<Args...>;
using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;

FunctionMocker() {}
FunctionMocker() = default;

// There is no generally useful and implementable semantics of
// copying a mock object, so copying a mock is usually a user error.
Expand Down
2 changes: 1 addition & 1 deletion googlemock/include/gmock/internal/gmock-internal-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class FailureReporterInterface {
// The type of a failure (either non-fatal or fatal).
enum FailureType { kNonfatal, kFatal };

virtual ~FailureReporterInterface() {}
virtual ~FailureReporterInterface() = default;

// Reports a failure that occurred at the given source file location.
virtual void ReportFailure(FailureType type, const char* file, int line,
Expand Down
8 changes: 4 additions & 4 deletions googlemock/src/gmock-spec-builders.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ExpectationBase::ExpectationBase(const char* a_file, int a_line,
action_count_checked_(false) {}

// Destructs an ExpectationBase object.
ExpectationBase::~ExpectationBase() {}
ExpectationBase::~ExpectationBase() = default;

// Explicitly specifies the cardinality of this expectation. Used by
// the subclasses to implement the .Times() clause.
Expand Down Expand Up @@ -309,7 +309,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) {
UntypedFunctionMockerBase::UntypedFunctionMockerBase()
: mock_obj_(nullptr), name_("") {}

UntypedFunctionMockerBase::~UntypedFunctionMockerBase() {}
UntypedFunctionMockerBase::~UntypedFunctionMockerBase() = default;

// Sets the mock object this mock method belongs to, and registers
// this information in the global mock registry. Will be called
Expand Down Expand Up @@ -746,13 +746,13 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj)
// needed by VerifyAndClearExpectationsLocked().
}

Expectation::Expectation() {}
Expectation::Expectation() = default;

Expectation::Expectation(
const std::shared_ptr<internal::ExpectationBase>& an_expectation_base)
: expectation_base_(an_expectation_base) {}

Expectation::~Expectation() {}
Expectation::~Expectation() = default;

// Adds an expectation to a sequence.
void Sequence::AddExpectation(const Expectation& expectation) const {
Expand Down
2 changes: 1 addition & 1 deletion googlemock/test/gmock-actions_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ TEST(ReturnRoundRobinTest, WorksForVector) {

class MockClass {
public:
MockClass() {}
MockClass() = default;

MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT
MOCK_METHOD0(Foo, MyNonDefaultConstructible());
Expand Down
2 changes: 1 addition & 1 deletion googlemock/test/gmock-cardinalities_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using testing::MakeCardinality;

class MockFoo {
public:
MockFoo() {}
MockFoo() = default;
MOCK_METHOD0(Bar, int()); // NOLINT

private:
Expand Down
24 changes: 12 additions & 12 deletions googlemock/test/gmock-function-mocker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ using testing::TypedEq;
template <typename T>
class TemplatedCopyable {
public:
TemplatedCopyable() {}
TemplatedCopyable() = default;

template <typename U>
TemplatedCopyable(const U& other) {} // NOLINT
};

class FooInterface {
public:
virtual ~FooInterface() {}
virtual ~FooInterface() = default;

virtual void VoidReturning(int x) = 0;

Expand Down Expand Up @@ -137,7 +137,7 @@ class FooInterface {
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4373)
class MockFoo : public FooInterface {
public:
MockFoo() {}
MockFoo() = default;

// Makes sure that a mock function parameter can be named.
MOCK_METHOD(void, VoidReturning, (int n)); // NOLINT
Expand Down Expand Up @@ -208,7 +208,7 @@ class MockFoo : public FooInterface {

class LegacyMockFoo : public FooInterface {
public:
LegacyMockFoo() {}
LegacyMockFoo() = default;

// Makes sure that a mock function parameter can be named.
MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT
Expand Down Expand Up @@ -487,7 +487,7 @@ TEST(FunctionMockerTest, RefQualified) {

class MockB {
public:
MockB() {}
MockB() = default;

MOCK_METHOD(void, DoB, ());

Expand All @@ -498,7 +498,7 @@ class MockB {

class LegacyMockB {
public:
LegacyMockB() {}
LegacyMockB() = default;

MOCK_METHOD0(DoB, void());

Expand Down Expand Up @@ -534,7 +534,7 @@ TYPED_TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
template <typename T>
class StackInterface {
public:
virtual ~StackInterface() {}
virtual ~StackInterface() = default;

// Template parameter appears in function parameter.
virtual void Push(const T& value) = 0;
Expand All @@ -547,7 +547,7 @@ class StackInterface {
template <typename T>
class MockStack : public StackInterface<T> {
public:
MockStack() {}
MockStack() = default;

MOCK_METHOD(void, Push, (const T& elem), ());
MOCK_METHOD(void, Pop, (), (final));
Expand All @@ -566,7 +566,7 @@ class MockStack : public StackInterface<T> {
template <typename T>
class LegacyMockStack : public StackInterface<T> {
public:
LegacyMockStack() {}
LegacyMockStack() = default;

MOCK_METHOD1_T(Push, void(const T& elem));
MOCK_METHOD0_T(Pop, void());
Expand Down Expand Up @@ -711,7 +711,7 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {

class MockOverloadedOnArgNumber {
public:
MockOverloadedOnArgNumber() {}
MockOverloadedOnArgNumber() = default;

MY_MOCK_METHODS1_;

Expand All @@ -723,7 +723,7 @@ class MockOverloadedOnArgNumber {

class LegacyMockOverloadedOnArgNumber {
public:
LegacyMockOverloadedOnArgNumber() {}
LegacyMockOverloadedOnArgNumber() = default;

LEGACY_MY_MOCK_METHODS1_;

Expand Down Expand Up @@ -758,7 +758,7 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {

class MockOverloadedOnConstness {
public:
MockOverloadedOnConstness() {}
MockOverloadedOnConstness() = default;

MY_MOCK_METHODS2_;

Expand Down
4 changes: 2 additions & 2 deletions googlemock/test/gmock-matchers-arithmetic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ TEST(AllArgsTest, WorksForNonTuple) {

class AllArgsHelper {
public:
AllArgsHelper() {}
AllArgsHelper() = default;

MOCK_METHOD2(Helper, int(char x, int y));

Expand All @@ -976,7 +976,7 @@ TEST(AllArgsTest, WorksInWithClause) {

class OptionalMatchersHelper {
public:
OptionalMatchersHelper() {}
OptionalMatchersHelper() = default;

MOCK_METHOD0(NoArgs, int());

Expand Down
4 changes: 2 additions & 2 deletions googlemock/test/gmock-matchers-comparisons_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ TEST(MatcherCastTest, ValueIsNotCopied) {

class Base {
public:
virtual ~Base() {}
Base() {}
virtual ~Base() = default;
Base() = default;

private:
Base(const Base&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion googlemock/test/gmock-matchers-containers_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,7 @@ TEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) {

class NativeArrayPassedAsPointerAndSize {
public:
NativeArrayPassedAsPointerAndSize() {}
NativeArrayPassedAsPointerAndSize() = default;

MOCK_METHOD(void, Helper, (int* array, int size));

Expand Down
8 changes: 4 additions & 4 deletions googlemock/test/gmock-nice-strict_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// clash with ::testing::Mock.
class Mock {
public:
Mock() {}
Mock() = default;

MOCK_METHOD0(DoThis, void());

Expand Down Expand Up @@ -78,15 +78,15 @@ class CallsMockMethodInDestructor {

class Foo {
public:
virtual ~Foo() {}
virtual ~Foo() = default;

virtual void DoThis() = 0;
virtual int DoThat(bool flag) = 0;
};

class MockFoo : public Foo {
public:
MockFoo() {}
MockFoo() = default;
void Delete() { delete this; }

MOCK_METHOD0(DoThis, void());
Expand All @@ -109,7 +109,7 @@ class MockBar {
(a10 ? 'T' : 'F');
}

virtual ~MockBar() {}
virtual ~MockBar() = default;

const std::string& str() const { return str_; }

Expand Down
14 changes: 7 additions & 7 deletions googlemock/test/gmock-spec-builders_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class NonDefaultConstructible {

class MockA {
public:
MockA() {}
MockA() = default;

MOCK_METHOD1(DoA, void(int n));
MOCK_METHOD1(ReturnResult, Result(int n));
Expand All @@ -113,7 +113,7 @@ class MockA {

class MockB {
public:
MockB() {}
MockB() = default;

MOCK_CONST_METHOD0(DoB, int()); // NOLINT
MOCK_METHOD1(DoB, int(int n)); // NOLINT
Expand All @@ -125,7 +125,7 @@ class MockB {

class ReferenceHoldingMock {
public:
ReferenceHoldingMock() {}
ReferenceHoldingMock() = default;

MOCK_METHOD1(AcceptReference, void(std::shared_ptr<MockA>*));

Expand All @@ -143,12 +143,12 @@ class ReferenceHoldingMock {

class CC {
public:
virtual ~CC() {}
virtual ~CC() = default;
virtual int Method() = 0;
};
class MockCC : public CC {
public:
MockCC() {}
MockCC() = default;

MOCK_METHOD0(Method, int());

Expand Down Expand Up @@ -1881,7 +1881,7 @@ struct Unprintable {

class MockC {
public:
MockC() {}
MockC() = default;

MOCK_METHOD6(VoidMethod, void(bool cond, int n, std::string s, void* p,
const Printable& x, Unprintable y));
Expand Down Expand Up @@ -2121,7 +2121,7 @@ void PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) {

class LogTestHelper {
public:
LogTestHelper() {}
LogTestHelper() = default;

MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));

Expand Down
4 changes: 2 additions & 2 deletions googlemock/test/gmock_leak_test_.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ using ::testing::Return;

class FooInterface {
public:
virtual ~FooInterface() {}
virtual ~FooInterface() = default;
virtual void DoThis() = 0;
};

class MockFoo : public FooInterface {
public:
MockFoo() {}
MockFoo() = default;

MOCK_METHOD0(DoThis, void());

Expand Down
Loading

0 comments on commit 783d00f

Please sign in to comment.