Commit 26743363 authored by Abseil Team's avatar Abseil Team Committed by Gennadiy Civil
Browse files

Googletest export

Applied fixes for ClangTidy modernize-use-override and modernize-use-using.

PiperOrigin-RevId: 223800219
parent a42cdf2a
...@@ -257,7 +257,7 @@ class DefaultValue { ...@@ -257,7 +257,7 @@ class DefaultValue {
class FixedValueProducer : public ValueProducer { class FixedValueProducer : public ValueProducer {
public: public:
explicit FixedValueProducer(T value) : value_(value) {} explicit FixedValueProducer(T value) : value_(value) {}
virtual T Produce() { return value_; } T Produce() override { return value_; }
private: private:
const T value_; const T value_;
...@@ -268,7 +268,7 @@ class DefaultValue { ...@@ -268,7 +268,7 @@ class DefaultValue {
public: public:
explicit FactoryValueProducer(FactoryFunction factory) explicit FactoryValueProducer(FactoryFunction factory)
: factory_(factory) {} : factory_(factory) {}
virtual T Produce() { return factory_(); } T Produce() override { return factory_(); }
private: private:
const FactoryFunction factory_; const FactoryFunction factory_;
...@@ -472,7 +472,7 @@ class PolymorphicAction { ...@@ -472,7 +472,7 @@ class PolymorphicAction {
explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
virtual Result Perform(const ArgumentTuple& args) { Result Perform(const ArgumentTuple& args) override {
return impl_.template Perform<Result>(args); return impl_.template Perform<Result>(args);
} }
...@@ -518,7 +518,7 @@ class ActionAdaptor : public ActionInterface<F1> { ...@@ -518,7 +518,7 @@ class ActionAdaptor : public ActionInterface<F1> {
explicit ActionAdaptor(const Action<F2>& from) : impl_(from.impl_) {} explicit ActionAdaptor(const Action<F2>& from) : impl_(from.impl_) {}
virtual Result Perform(const ArgumentTuple& args) { Result Perform(const ArgumentTuple& args) override {
return impl_->Perform(args); return impl_->Perform(args);
} }
...@@ -609,7 +609,7 @@ class ReturnAction { ...@@ -609,7 +609,7 @@ class ReturnAction {
: value_before_cast_(*value), : value_before_cast_(*value),
value_(ImplicitCast_<Result>(value_before_cast_)) {} value_(ImplicitCast_<Result>(value_before_cast_)) {}
virtual Result Perform(const ArgumentTuple&) { return value_; } Result Perform(const ArgumentTuple&) override { return value_; }
private: private:
GTEST_COMPILE_ASSERT_(!is_reference<Result>::value, GTEST_COMPILE_ASSERT_(!is_reference<Result>::value,
...@@ -633,7 +633,7 @@ class ReturnAction { ...@@ -633,7 +633,7 @@ class ReturnAction {
explicit Impl(const std::shared_ptr<R>& wrapper) explicit Impl(const std::shared_ptr<R>& wrapper)
: performed_(false), wrapper_(wrapper) {} : performed_(false), wrapper_(wrapper) {}
virtual Result Perform(const ArgumentTuple&) { Result Perform(const ArgumentTuple&) override {
GTEST_CHECK_(!performed_) GTEST_CHECK_(!performed_)
<< "A ByMove() action should only be performed once."; << "A ByMove() action should only be performed once.";
performed_ = true; performed_ = true;
...@@ -712,9 +712,7 @@ class ReturnRefAction { ...@@ -712,9 +712,7 @@ class ReturnRefAction {
explicit Impl(T& ref) : ref_(ref) {} // NOLINT explicit Impl(T& ref) : ref_(ref) {} // NOLINT
virtual Result Perform(const ArgumentTuple&) { Result Perform(const ArgumentTuple&) override { return ref_; }
return ref_;
}
private: private:
T& ref_; T& ref_;
...@@ -761,9 +759,7 @@ class ReturnRefOfCopyAction { ...@@ -761,9 +759,7 @@ class ReturnRefOfCopyAction {
explicit Impl(const T& value) : value_(value) {} // NOLINT explicit Impl(const T& value) : value_(value) {} // NOLINT
virtual Result Perform(const ArgumentTuple&) { Result Perform(const ArgumentTuple&) override { return value_; }
return value_;
}
private: private:
T value_; T value_;
...@@ -973,7 +969,7 @@ class IgnoreResultAction { ...@@ -973,7 +969,7 @@ class IgnoreResultAction {
explicit Impl(const A& action) : action_(action) {} explicit Impl(const A& action) : action_(action) {}
virtual void Perform(const ArgumentTuple& args) { void Perform(const ArgumentTuple& args) override {
// Performs the action and ignores its result. // Performs the action and ignores its result.
action_.Perform(args); action_.Perform(args);
} }
...@@ -1048,7 +1044,7 @@ class DoBothAction { ...@@ -1048,7 +1044,7 @@ class DoBothAction {
Impl(const Action<VoidResult>& action1, const Action<F>& action2) Impl(const Action<VoidResult>& action1, const Action<F>& action2)
: action1_(action1), action2_(action2) {} : action1_(action1), action2_(action2) {}
virtual Result Perform(const ArgumentTuple& args) { Result Perform(const ArgumentTuple& args) override {
action1_.Perform(args); action1_.Perform(args);
return action2_.Perform(args); return action2_.Perform(args);
} }
......
...@@ -181,7 +181,7 @@ class NiceMock : public MockClass { ...@@ -181,7 +181,7 @@ class NiceMock : public MockClass {
#endif // GTEST_LANG_CXX11 #endif // GTEST_LANG_CXX11
~NiceMock() { ~NiceMock() { // NOLINT
::testing::Mock::UnregisterCallReaction( ::testing::Mock::UnregisterCallReaction(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
...@@ -299,7 +299,7 @@ class NaggyMock : public MockClass { ...@@ -299,7 +299,7 @@ class NaggyMock : public MockClass {
#endif // GTEST_LANG_CXX11 #endif // GTEST_LANG_CXX11
~NaggyMock() { ~NaggyMock() { // NOLINT
::testing::Mock::UnregisterCallReaction( ::testing::Mock::UnregisterCallReaction(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
...@@ -417,7 +417,7 @@ class StrictMock : public MockClass { ...@@ -417,7 +417,7 @@ class StrictMock : public MockClass {
#endif // GTEST_LANG_CXX11 #endif // GTEST_LANG_CXX11
~StrictMock() { ~StrictMock() { // NOLINT
::testing::Mock::UnregisterCallReaction( ::testing::Mock::UnregisterCallReaction(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
......
...@@ -135,7 +135,7 @@ $range j 1..i ...@@ -135,7 +135,7 @@ $range j 1..i
]] ]]
#endif // GTEST_LANG_CXX11 #endif // GTEST_LANG_CXX11
~$clazz() { ~$clazz() { // NOLINT
::testing::Mock::UnregisterCallReaction( ::testing::Mock::UnregisterCallReaction(
internal::ImplicitCast_<MockClass*>(this)); internal::ImplicitCast_<MockClass*>(this));
} }
......
This diff is collapsed.
...@@ -903,7 +903,7 @@ class TypedExpectation : public ExpectationBase { ...@@ -903,7 +903,7 @@ class TypedExpectation : public ExpectationBase {
extra_matcher_(A<const ArgumentTuple&>()), extra_matcher_(A<const ArgumentTuple&>()),
repeated_action_(DoDefault()) {} repeated_action_(DoDefault()) {}
virtual ~TypedExpectation() { ~TypedExpectation() override {
// Check the validity of the action count if it hasn't been done // Check the validity of the action count if it hasn't been done
// yet (for example, if the expectation was never used). // yet (for example, if the expectation was never used).
CheckActionCountIfNotDone(); CheckActionCountIfNotDone();
...@@ -1069,7 +1069,7 @@ class TypedExpectation : public ExpectationBase { ...@@ -1069,7 +1069,7 @@ class TypedExpectation : public ExpectationBase {
// If this mock method has an extra matcher (i.e. .With(matcher)), // If this mock method has an extra matcher (i.e. .With(matcher)),
// describes it to the ostream. // describes it to the ostream.
virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) { void MaybeDescribeExtraMatcherTo(::std::ostream* os) override {
if (extra_matcher_specified_) { if (extra_matcher_specified_) {
*os << " Expected args: "; *os << " Expected args: ";
extra_matcher_.DescribeTo(os); extra_matcher_.DescribeTo(os);
...@@ -1083,9 +1083,7 @@ class TypedExpectation : public ExpectationBase { ...@@ -1083,9 +1083,7 @@ class TypedExpectation : public ExpectationBase {
// Returns an Expectation object that references and co-owns this // Returns an Expectation object that references and co-owns this
// expectation. // expectation.
virtual Expectation GetHandle() { Expectation GetHandle() override { return owner_->GetHandleOf(this); }
return owner_->GetHandleOf(this);
}
// The following methods will be called only after the EXPECT_CALL() // The following methods will be called only after the EXPECT_CALL()
// statement finishes and when the current thread holds // statement finishes and when the current thread holds
...@@ -1387,7 +1385,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase { ...@@ -1387,7 +1385,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
} }
// Prints the held value as an action's result to os. // Prints the held value as an action's result to os.
virtual void PrintAsActionResult(::std::ostream* os) const { void PrintAsActionResult(::std::ostream* os) const override {
*os << "\n Returns: "; *os << "\n Returns: ";
// T may be a reference type, so we don't use UniversalPrint(). // T may be a reference type, so we don't use UniversalPrint().
UniversalPrinter<T>::Print(result_.Peek(), os); UniversalPrinter<T>::Print(result_.Peek(), os);
...@@ -1431,7 +1429,7 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase { ...@@ -1431,7 +1429,7 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
public: public:
void Unwrap() { } void Unwrap() { }
virtual void PrintAsActionResult(::std::ostream* /* os */) const {} void PrintAsActionResult(::std::ostream* /* os */) const override {}
// Performs the given mock function's default action and returns ownership // Performs the given mock function's default action and returns ownership
// of an empty ActionResultHolder*. // of an empty ActionResultHolder*.
...@@ -1490,8 +1488,7 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase { ...@@ -1490,8 +1488,7 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase {
// The destructor verifies that all expectations on this mock // The destructor verifies that all expectations on this mock
// function have been satisfied. If not, it will report Google Test // function have been satisfied. If not, it will report Google Test
// non-fatal failures for the violations. // non-fatal failures for the violations.
virtual ~FunctionMocker() ~FunctionMocker() override GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
MutexLock l(&g_gmock_mutex); MutexLock l(&g_gmock_mutex);
VerifyAndClearExpectationsLocked(); VerifyAndClearExpectationsLocked();
Mock::UnregisterLocked(this); Mock::UnregisterLocked(this);
...@@ -1547,9 +1544,9 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase { ...@@ -1547,9 +1544,9 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase {
// the error message to describe the call in the case the default // the error message to describe the call in the case the default
// action fails. The caller is responsible for deleting the result. // action fails. The caller is responsible for deleting the result.
// L = * // L = *
virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction( UntypedActionResultHolderBase* UntypedPerformDefaultAction(
void* untyped_args, // must point to an ArgumentTuple void* untyped_args, // must point to an ArgumentTuple
const std::string& call_description) const { const std::string& call_description) const override {
ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args); ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args);
return ResultHolder::PerformDefaultAction(this, std::move(*args), return ResultHolder::PerformDefaultAction(this, std::move(*args),
call_description); call_description);
...@@ -1559,8 +1556,8 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase { ...@@ -1559,8 +1556,8 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase {
// the action's result. The caller is responsible for deleting the // the action's result. The caller is responsible for deleting the
// result. // result.
// L = * // L = *
virtual UntypedActionResultHolderBase* UntypedPerformAction( UntypedActionResultHolderBase* UntypedPerformAction(
const void* untyped_action, void* untyped_args) const { const void* untyped_action, void* untyped_args) const override {
// Make a copy of the action before performing it, in case the // Make a copy of the action before performing it, in case the
// action deletes the mock object (and thus deletes itself). // action deletes the mock object (and thus deletes itself).
const Action<F> action = *static_cast<const Action<F>*>(untyped_action); const Action<F> action = *static_cast<const Action<F>*>(untyped_action);
...@@ -1570,7 +1567,7 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase { ...@@ -1570,7 +1567,7 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase {
// Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked(): // Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():
// clears the ON_CALL()s set on this mock function. // clears the ON_CALL()s set on this mock function.
virtual void ClearDefaultActionsLocked() void ClearDefaultActionsLocked() override
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
...@@ -1674,9 +1671,8 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase { ...@@ -1674,9 +1671,8 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase {
// Writes a message that the call is uninteresting (i.e. neither // Writes a message that the call is uninteresting (i.e. neither
// explicitly expected nor explicitly unexpected) to the given // explicitly expected nor explicitly unexpected) to the given
// ostream. // ostream.
virtual void UntypedDescribeUninterestingCall( void UntypedDescribeUninterestingCall(const void* untyped_args,
const void* untyped_args, ::std::ostream* os) const override
::std::ostream* os) const
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
const ArgumentTuple& args = const ArgumentTuple& args =
*static_cast<const ArgumentTuple*>(untyped_args); *static_cast<const ArgumentTuple*>(untyped_args);
...@@ -1702,10 +1698,9 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase { ...@@ -1702,10 +1698,9 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase {
// section. The reason is that we have no control on what the // section. The reason is that we have no control on what the
// action does (it can invoke an arbitrary user function or even a // action does (it can invoke an arbitrary user function or even a
// mock function) and excessive locking could cause a dead lock. // mock function) and excessive locking could cause a dead lock.
virtual const ExpectationBase* UntypedFindMatchingExpectation( const ExpectationBase* UntypedFindMatchingExpectation(
const void* untyped_args, const void* untyped_args, const void** untyped_action, bool* is_excessive,
const void** untyped_action, bool* is_excessive, ::std::ostream* what, ::std::ostream* why) override
::std::ostream* what, ::std::ostream* why)
GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
const ArgumentTuple& args = const ArgumentTuple& args =
*static_cast<const ArgumentTuple*>(untyped_args); *static_cast<const ArgumentTuple*>(untyped_args);
...@@ -1728,8 +1723,8 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase { ...@@ -1728,8 +1723,8 @@ class FunctionMocker<R(Args...)> : public UntypedFunctionMockerBase {
} }
// Prints the given function arguments to the ostream. // Prints the given function arguments to the ostream.
virtual void UntypedPrintArgs(const void* untyped_args, void UntypedPrintArgs(const void* untyped_args,
::std::ostream* os) const { ::std::ostream* os) const override {
const ArgumentTuple& args = const ArgumentTuple& args =
*static_cast<const ArgumentTuple*>(untyped_args); *static_cast<const ArgumentTuple*>(untyped_args);
UniversalPrint(args, os); UniversalPrint(args, os);
......
...@@ -70,18 +70,18 @@ class BetweenCardinalityImpl : public CardinalityInterface { ...@@ -70,18 +70,18 @@ class BetweenCardinalityImpl : public CardinalityInterface {
// Conservative estimate on the lower/upper bound of the number of // Conservative estimate on the lower/upper bound of the number of
// calls allowed. // calls allowed.
virtual int ConservativeLowerBound() const { return min_; } int ConservativeLowerBound() const override { return min_; }
virtual int ConservativeUpperBound() const { return max_; } int ConservativeUpperBound() const override { return max_; }
virtual bool IsSatisfiedByCallCount(int call_count) const { bool IsSatisfiedByCallCount(int call_count) const override {
return min_ <= call_count && call_count <= max_; return min_ <= call_count && call_count <= max_;
} }
virtual bool IsSaturatedByCallCount(int call_count) const { bool IsSaturatedByCallCount(int call_count) const override {
return call_count >= max_; return call_count >= max_;
} }
virtual void DescribeTo(::std::ostream* os) const; void DescribeTo(::std::ostream* os) const override;
private: private:
const int min_; const int min_;
......
...@@ -93,8 +93,8 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) { ...@@ -93,8 +93,8 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
// use Google Mock with a testing framework other than Google Test. // use Google Mock with a testing framework other than Google Test.
class GoogleTestFailureReporter : public FailureReporterInterface { class GoogleTestFailureReporter : public FailureReporterInterface {
public: public:
virtual void ReportFailure(FailureType type, const char* file, int line, void ReportFailure(FailureType type, const char* file, int line,
const std::string& message) { const std::string& message) override {
AssertHelper(type == kFatal ? AssertHelper(type == kFatal ?
TestPartResult::kFatalFailure : TestPartResult::kFatalFailure :
TestPartResult::kNonFatalFailure, TestPartResult::kNonFatalFailure,
......
...@@ -379,7 +379,7 @@ typedef int MyGlobalFunction(bool, int); ...@@ -379,7 +379,7 @@ typedef int MyGlobalFunction(bool, int);
class MyActionImpl : public ActionInterface<MyGlobalFunction> { class MyActionImpl : public ActionInterface<MyGlobalFunction> {
public: public:
virtual int Perform(const std::tuple<bool, int>& args) { int Perform(const std::tuple<bool, int>& args) override {
return std::get<0>(args) ? std::get<1>(args) : 0; return std::get<0>(args) ? std::get<1>(args) : 0;
} }
}; };
...@@ -443,7 +443,7 @@ TEST(ActionTest, IsCopyable) { ...@@ -443,7 +443,7 @@ TEST(ActionTest, IsCopyable) {
class IsNotZero : public ActionInterface<bool(int)> { // NOLINT class IsNotZero : public ActionInterface<bool(int)> { // NOLINT
public: public:
virtual bool Perform(const std::tuple<int>& arg) { bool Perform(const std::tuple<int>& arg) override {
return std::get<0>(arg) != 0; return std::get<0>(arg) != 0;
} }
}; };
...@@ -1087,7 +1087,7 @@ TEST(WithArgsTest, TenArgs) { ...@@ -1087,7 +1087,7 @@ TEST(WithArgsTest, TenArgs) {
// Tests using WithArgs with an action that is not Invoke(). // Tests using WithArgs with an action that is not Invoke().
class SubtractAction : public ActionInterface<int(int, int)> { class SubtractAction : public ActionInterface<int(int, int)> {
public: public:
virtual int Perform(const std::tuple<int, int>& args) { int Perform(const std::tuple<int, int>& args) override {
return std::get<0>(args) - std::get<1>(args); return std::get<0>(args) - std::get<1>(args);
} }
}; };
...@@ -1155,8 +1155,8 @@ TEST(WithArgsTest, InnerActionWithConversion) { ...@@ -1155,8 +1155,8 @@ TEST(WithArgsTest, InnerActionWithConversion) {
class SetErrnoAndReturnTest : public testing::Test { class SetErrnoAndReturnTest : public testing::Test {
protected: protected:
virtual void SetUp() { errno = 0; } void SetUp() override { errno = 0; }
virtual void TearDown() { errno = 0; } void TearDown() override { errno = 0; }
}; };
TEST_F(SetErrnoAndReturnTest, Int) { TEST_F(SetErrnoAndReturnTest, Int) {
......
...@@ -396,17 +396,17 @@ TEST(ExactlyTest, HasCorrectBounds) { ...@@ -396,17 +396,17 @@ TEST(ExactlyTest, HasCorrectBounds) {
class EvenCardinality : public CardinalityInterface { class EvenCardinality : public CardinalityInterface {
public: public:
// Returns true iff call_count calls will satisfy this cardinality. // Returns true iff call_count calls will satisfy this cardinality.
virtual bool IsSatisfiedByCallCount(int call_count) const { bool IsSatisfiedByCallCount(int call_count) const override {
return (call_count % 2 == 0); return (call_count % 2 == 0);
} }
// Returns true iff call_count calls will saturate this cardinality. // Returns true iff call_count calls will saturate this cardinality.
virtual bool IsSaturatedByCallCount(int /* call_count */) const { bool IsSaturatedByCallCount(int /* call_count */) const override {
return false; return false;
} }
// Describes self to an ostream. // Describes self to an ostream.
virtual void DescribeTo(::std::ostream* ss) const { void DescribeTo(::std::ostream* ss) const override {
*ss << "called even number of times"; *ss << "called even number of times";
} }
}; };
......
...@@ -117,12 +117,11 @@ class GreaterThanMatcher : public MatcherInterface<int> { ...@@ -117,12 +117,11 @@ class GreaterThanMatcher : public MatcherInterface<int> {
public: public:
explicit GreaterThanMatcher(int rhs) : rhs_(rhs) {} explicit GreaterThanMatcher(int rhs) : rhs_(rhs) {}
virtual void DescribeTo(::std::ostream* os) const { void DescribeTo(::std::ostream* os) const override {
*os << "is greater than " << rhs_; *os << "is greater than " << rhs_;
} }
virtual bool MatchAndExplain(int lhs, bool MatchAndExplain(int lhs, MatchResultListener* listener) const override {
MatchResultListener* listener) const {
const int diff = lhs - rhs_; const int diff = lhs - rhs_;
if (diff > 0) { if (diff > 0) {
*listener << "which is " << diff << " more than " << rhs_; *listener << "which is " << diff << " more than " << rhs_;
......
...@@ -379,11 +379,9 @@ TEST(ExpectTest, FailsNonfatallyOnFalse) { ...@@ -379,11 +379,9 @@ TEST(ExpectTest, FailsNonfatallyOnFalse) {
class LogIsVisibleTest : public ::testing::Test { class LogIsVisibleTest : public ::testing::Test {
protected: protected:
virtual void SetUp() { void SetUp() override { original_verbose_ = GMOCK_FLAG(verbose); }
original_verbose_ = GMOCK_FLAG(verbose);
}
virtual void TearDown() { GMOCK_FLAG(verbose) = original_verbose_; } void TearDown() override { GMOCK_FLAG(verbose) = original_verbose_; }
std::string original_verbose_; std::string original_verbose_;
}; };
...@@ -442,11 +440,11 @@ TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) { ...@@ -442,11 +440,11 @@ TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
} }
struct MockStackTraceGetter : testing::internal::OsStackTraceGetterInterface { struct MockStackTraceGetter : testing::internal::OsStackTraceGetterInterface {
virtual std::string CurrentStackTrace(int max_depth, int skip_count) { std::string CurrentStackTrace(int max_depth, int skip_count) override {
return (testing::Message() << max_depth << "::" << skip_count << "\n") return (testing::Message() << max_depth << "::" << skip_count << "\n")
.GetString(); .GetString();
} }
virtual void UponLeavingGTest() {} void UponLeavingGTest() override {}
}; };
// Tests that in opt mode, a positive stack_frames_to_skip argument is // Tests that in opt mode, a positive stack_frames_to_skip argument is
......
...@@ -162,12 +162,9 @@ class GreaterThanMatcher : public MatcherInterface<int> { ...@@ -162,12 +162,9 @@ class GreaterThanMatcher : public MatcherInterface<int> {
public: public:
explicit GreaterThanMatcher(int rhs) : rhs_(rhs) {} explicit GreaterThanMatcher(int rhs) : rhs_(rhs) {}
virtual void DescribeTo(ostream* os) const { void DescribeTo(ostream* os) const override { *os << "is > " << rhs_; }
*os << "is > " << rhs_;
}
virtual bool MatchAndExplain(int lhs, bool MatchAndExplain(int lhs, MatchResultListener* listener) const override {
MatchResultListener* listener) const {
const int diff = lhs - rhs_; const int diff = lhs - rhs_;
if (diff > 0) { if (diff > 0) {
*listener << "which is " << diff << " more than " << rhs_; *listener << "which is " << diff << " more than " << rhs_;
...@@ -257,14 +254,12 @@ TEST(MatchResultListenerTest, IsInterestedWorks) { ...@@ -257,14 +254,12 @@ TEST(MatchResultListenerTest, IsInterestedWorks) {
// change. // change.
class EvenMatcherImpl : public MatcherInterface<int> { class EvenMatcherImpl : public MatcherInterface<int> {
public: public:
virtual bool MatchAndExplain(int x, bool MatchAndExplain(int x,
MatchResultListener* /* listener */) const { MatchResultListener* /* listener */) const override {
return x % 2 == 0; return x % 2 == 0;
} }
virtual void DescribeTo(ostream* os) const { void DescribeTo(ostream* os) const override { *os << "is an even number"; }
*os << "is an even number";
}
// We deliberately don't define DescribeNegationTo() and // We deliberately don't define DescribeNegationTo() and
// ExplainMatchResultTo() here, to make sure the definition of these // ExplainMatchResultTo() here, to make sure the definition of these
...@@ -280,7 +275,7 @@ TEST(MatcherInterfaceTest, CanBeImplementedUsingPublishedAPI) { ...@@ -280,7 +275,7 @@ TEST(MatcherInterfaceTest, CanBeImplementedUsingPublishedAPI) {
class NewEvenMatcherImpl : public MatcherInterface<int> { class NewEvenMatcherImpl : public MatcherInterface<int> {
public: public:
virtual bool MatchAndExplain(int x, MatchResultListener* listener) const { bool MatchAndExplain(int x, MatchResultListener* listener) const override {
const bool match = x % 2 == 0; const bool match = x % 2 == 0;
// Verifies that we can stream to a listener directly. // Verifies that we can stream to a listener directly.
*listener << "value % " << 2; *listener << "value % " << 2;
...@@ -292,9 +287,7 @@ class NewEvenMatcherImpl : public MatcherInterface<int> { ...@@ -292,9 +287,7 @@ class NewEvenMatcherImpl : public MatcherInterface<int> {
return match; return match;
} }
virtual void DescribeTo(ostream* os) const { void DescribeTo(ostream* os) const override { *os << "is an even number"; }
*os << "is an even number";
}
}; };
TEST(MatcherInterfaceTest, CanBeImplementedUsingNewAPI) { TEST(MatcherInterfaceTest, CanBeImplementedUsingNewAPI) {
......
...@@ -1952,17 +1952,17 @@ TEST(DeletingMockEarlyTest, Failure2) { ...@@ -1952,17 +1952,17 @@ TEST(DeletingMockEarlyTest, Failure2) {
class EvenNumberCardinality : public CardinalityInterface { class EvenNumberCardinality : public CardinalityInterface {
public: public:
// Returns true iff call_count calls will satisfy this cardinality. // Returns true iff call_count calls will satisfy this cardinality.
virtual bool IsSatisfiedByCallCount(int call_count) const { bool IsSatisfiedByCallCount(int call_count) const override {
return call_count % 2 == 0; return call_count % 2 == 0;
} }
// Returns true iff call_count calls will saturate this cardinality. // Returns true iff call_count calls will saturate this cardinality.
virtual bool IsSaturatedByCallCount(int /* call_count */) const { bool IsSaturatedByCallCount(int /* call_count */) const override {
return false; return false;
} }
// Describes self to an ostream. // Describes self to an ostream.
virtual void DescribeTo(::std::ostream* os) const { void DescribeTo(::std::ostream* os) const override {
*os << "called even number of times"; *os << "called even number of times";
} }
}; };
...@@ -2023,7 +2023,9 @@ class VerboseFlagPreservingFixture : public testing::Test { ...@@ -2023,7 +2023,9 @@ class VerboseFlagPreservingFixture : public testing::Test {
VerboseFlagPreservingFixture() VerboseFlagPreservingFixture()
: saved_verbose_flag_(GMOCK_FLAG(verbose)) {} : saved_verbose_flag_(GMOCK_FLAG(verbose)) {}
~VerboseFlagPreservingFixture() { GMOCK_FLAG(verbose) = saved_verbose_flag_; } ~VerboseFlagPreservingFixture() override {
GMOCK_FLAG(verbose) = saved_verbose_flag_;
}
private: private:
const std::string saved_verbose_flag_; const std::string saved_verbose_flag_;
......
...@@ -183,16 +183,16 @@ class MatcherInterfaceAdapter : public MatcherInterface<const T&> { ...@@ -183,16 +183,16 @@ class MatcherInterfaceAdapter : public MatcherInterface<const T&> {
public: public:
explicit MatcherInterfaceAdapter(const MatcherInterface<T>* impl) explicit MatcherInterfaceAdapter(const MatcherInterface<T>* impl)
: impl_(impl) {} : impl_(impl) {}
virtual ~MatcherInterfaceAdapter() { delete impl_; } ~MatcherInterfaceAdapter() override { delete impl_; }
virtual void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } void DescribeTo(::std::ostream* os) const override { impl_->DescribeTo(os); }
virtual void DescribeNegationTo(::std::ostream* os) const { void DescribeNegationTo(::std::ostream* os) const override {
impl_->DescribeNegationTo(os); impl_->DescribeNegationTo(os);
} }
virtual bool MatchAndExplain(const T& x, bool MatchAndExplain(const T& x,
MatchResultListener* listener) const { MatchResultListener* listener) const override {
return impl_->MatchAndExplain(x, listener); return impl_->MatchAndExplain(x, listener);
} }
...@@ -614,18 +614,19 @@ class ComparisonBase { ...@@ -614,18 +614,19 @@ class ComparisonBase {
class Impl : public MatcherInterface<Lhs> { class Impl : public MatcherInterface<Lhs> {
public: public:
explicit Impl(const Rhs& rhs) : rhs_(rhs) {} explicit Impl(const Rhs& rhs) : rhs_(rhs) {}
virtual bool MatchAndExplain( bool MatchAndExplain(Lhs lhs,
Lhs lhs, MatchResultListener* /* listener */) const { MatchResultListener* /* listener */) const override {
return Op()(lhs, rhs_); return Op()(lhs, rhs_);
} }
virtual void DescribeTo(::std::ostream* os) const { void DescribeTo(::std::ostream* os) const override {
*os << D::Desc() << " "; *os << D::Desc() << " ";
UniversalPrint(rhs_, os); UniversalPrint(rhs_, os);
} }
virtual void DescribeNegationTo(::std::ostream* os) const { void DescribeNegationTo(::std::ostream* os) const override {
*os << D::NegatedDesc() << " "; *os << D::NegatedDesc() << " ";
UniversalPrint(rhs_, os); UniversalPrint(rhs_, os);
} }
private: private:
Rhs rhs_; Rhs rhs_;
GTEST_DISALLOW_ASSIGN_(Impl); GTEST_DISALLOW_ASSIGN_(Impl);
......
...@@ -72,14 +72,15 @@ class GTEST_API_ ScopedFakeTestPartResultReporter ...@@ -72,14 +72,15 @@ class GTEST_API_ ScopedFakeTestPartResultReporter
TestPartResultArray* result); TestPartResultArray* result);
// The d'tor restores the previous test part result reporter. // The d'tor restores the previous test part result reporter.
virtual ~ScopedFakeTestPartResultReporter(); ~ScopedFakeTestPartResultReporter() override;
// Appends the TestPartResult object to the TestPartResultArray // Appends the TestPartResult object to the TestPartResultArray
// received in the constructor. // received in the constructor.
// //
// This method is from the TestPartResultReporterInterface // This method is from the TestPartResultReporterInterface
// interface. // interface.
virtual void ReportTestPartResult(const TestPartResult& result); void ReportTestPartResult(const TestPartResult& result) override;
private: private:
void Init(); void Init();
......
...@@ -165,8 +165,8 @@ class GTEST_API_ HasNewFatalFailureHelper ...@@ -165,8 +165,8 @@ class GTEST_API_ HasNewFatalFailureHelper
: public TestPartResultReporterInterface { : public TestPartResultReporterInterface {
public: public:
HasNewFatalFailureHelper(); HasNewFatalFailureHelper();
virtual ~HasNewFatalFailureHelper(); ~HasNewFatalFailureHelper() override;
virtual void ReportTestPartResult(const TestPartResult& result); void ReportTestPartResult(const TestPartResult& result) override;
bool has_new_fatal_failure() const { return has_new_fatal_failure_; } bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
private: private:
bool has_new_fatal_failure_; bool has_new_fatal_failure_;
......
...@@ -1111,21 +1111,21 @@ class TestEventListener { ...@@ -1111,21 +1111,21 @@ class TestEventListener {
// above. // above.
class EmptyTestEventListener : public TestEventListener { class EmptyTestEventListener : public TestEventListener {
public: public:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {} void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
virtual void OnTestIterationStart(const UnitTest& /*unit_test*/, void OnTestIterationStart(const UnitTest& /*unit_test*/,
int /*iteration*/) {} int /*iteration*/) override {}
virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {} void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {} void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
virtual void OnTestCaseStart(const TestCase& /*test_case*/) {} void OnTestCaseStart(const TestCase& /*test_case*/) override {}
virtual void OnTestStart(const TestInfo& /*test_info*/) {} void OnTestStart(const TestInfo& /*test_info*/) override {}
virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {} void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {}
virtual void OnTestEnd(const TestInfo& /*test_info*/) {} void OnTestEnd(const TestInfo& /*test_info*/) override {}
virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {} void OnTestCaseEnd(const TestCase& /*test_case*/) override {}
virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {} void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {} void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/, void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int /*iteration*/) {} int /*iteration*/) override {}
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
}; };
// TestEventListeners lets users add listeners to track events in Google Test. // TestEventListeners lets users add listeners to track events in Google Test.
......
...@@ -154,9 +154,8 @@ class DeathTestFactory { ...@@ -154,9 +154,8 @@ class DeathTestFactory {
// A concrete DeathTestFactory implementation for normal use. // A concrete DeathTestFactory implementation for normal use.
class DefaultDeathTestFactory : public DeathTestFactory { class DefaultDeathTestFactory : public DeathTestFactory {
public: public:
virtual bool Create(const char* statement, bool Create(const char* statement, Matcher<const std::string&> matcher,
Matcher<const std::string&> matcher, const char* file, const char* file, int line, DeathTest** test) override;
int line, DeathTest** test);
}; };
// Returns true if exit_status describes a process that was terminated // Returns true if exit_status describes a process that was terminated
......
...@@ -469,7 +469,7 @@ class TestFactoryBase { ...@@ -469,7 +469,7 @@ class TestFactoryBase {
template <class TestClass> template <class TestClass>
class TestFactoryImpl : public TestFactoryBase { class TestFactoryImpl : public TestFactoryBase {
public: public:
virtual Test* CreateTest() { return new TestClass; } Test* CreateTest() override { return new TestClass; }
}; };
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment