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
...@@ -74,12 +74,12 @@ class CartesianProductGenerator$i ...@@ -74,12 +74,12 @@ class CartesianProductGenerator$i
CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]]) CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])
: $for j, [[g$(j)_(g$j)]] {} : $for j, [[g$(j)_(g$j)]] {}
virtual ~CartesianProductGenerator$i() {} ~CartesianProductGenerator$i() override {}
virtual ParamIteratorInterface<ParamType>* Begin() const { ParamIteratorInterface<ParamType>* Begin() const override {
return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]); return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);
} }
virtual ParamIteratorInterface<ParamType>* End() const { ParamIteratorInterface<ParamType>* End() const override {
return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]); return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);
} }
...@@ -97,14 +97,14 @@ $for j, [[ ...@@ -97,14 +97,14 @@ $for j, [[
]] { ]] {
ComputeCurrentValue(); ComputeCurrentValue();
} }
virtual ~Iterator() {} ~Iterator() override {}
virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const { const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
return base_; return base_;
} }
// Advance should not be called on beyond-of-range iterators // Advance should not be called on beyond-of-range iterators
// so no component iterators must be beyond end of range, either. // so no component iterators must be beyond end of range, either.
virtual void Advance() { void Advance() override {
assert(!AtEnd()); assert(!AtEnd());
++current$(i)_; ++current$(i)_;
...@@ -117,11 +117,11 @@ $for k [[ ...@@ -117,11 +117,11 @@ $for k [[
]] ]]
ComputeCurrentValue(); ComputeCurrentValue();
} }
virtual ParamIteratorInterface<ParamType>* Clone() const { ParamIteratorInterface<ParamType>* Clone() const override {
return new Iterator(*this); return new Iterator(*this);
} }
virtual const ParamType* Current() const { return current_value_.get(); } const ParamType* Current() const override { return current_value_.get(); }
virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
// Having the same base generator guarantees that the other // Having the same base generator guarantees that the other
// iterator is of the same type and we can downcast. // iterator is of the same type and we can downcast.
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
......
...@@ -206,12 +206,12 @@ class RangeGenerator : public ParamGeneratorInterface<T> { ...@@ -206,12 +206,12 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
RangeGenerator(T begin, T end, IncrementT step) RangeGenerator(T begin, T end, IncrementT step)
: begin_(begin), end_(end), : begin_(begin), end_(end),
step_(step), end_index_(CalculateEndIndex(begin, end, step)) {} step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
virtual ~RangeGenerator() {} ~RangeGenerator() override {}
virtual ParamIteratorInterface<T>* Begin() const { ParamIteratorInterface<T>* Begin() const override {
return new Iterator(this, begin_, 0, step_); return new Iterator(this, begin_, 0, step_);
} }
virtual ParamIteratorInterface<T>* End() const { ParamIteratorInterface<T>* End() const override {
return new Iterator(this, end_, end_index_, step_); return new Iterator(this, end_, end_index_, step_);
} }
...@@ -221,20 +221,20 @@ class RangeGenerator : public ParamGeneratorInterface<T> { ...@@ -221,20 +221,20 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
Iterator(const ParamGeneratorInterface<T>* base, T value, int index, Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
IncrementT step) IncrementT step)
: base_(base), value_(value), index_(index), step_(step) {} : base_(base), value_(value), index_(index), step_(step) {}
virtual ~Iterator() {} ~Iterator() override {}
virtual const ParamGeneratorInterface<T>* BaseGenerator() const { const ParamGeneratorInterface<T>* BaseGenerator() const override {
return base_; return base_;
} }
virtual void Advance() { void Advance() override {
value_ = static_cast<T>(value_ + step_); value_ = static_cast<T>(value_ + step_);
index_++; index_++;
} }
virtual ParamIteratorInterface<T>* Clone() const { ParamIteratorInterface<T>* Clone() const override {
return new Iterator(*this); return new Iterator(*this);
} }
virtual const T* Current() const { return &value_; } const T* Current() const override { return &value_; }
virtual bool Equals(const ParamIteratorInterface<T>& other) const { bool Equals(const ParamIteratorInterface<T>& other) const override {
// Having the same base generator guarantees that the other // Having the same base generator guarantees that the other
// iterator is of the same type and we can downcast. // iterator is of the same type and we can downcast.
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
...@@ -291,12 +291,12 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> { ...@@ -291,12 +291,12 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
template <typename ForwardIterator> template <typename ForwardIterator>
ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end) ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
: container_(begin, end) {} : container_(begin, end) {}
virtual ~ValuesInIteratorRangeGenerator() {} ~ValuesInIteratorRangeGenerator() override {}
virtual ParamIteratorInterface<T>* Begin() const { ParamIteratorInterface<T>* Begin() const override {
return new Iterator(this, container_.begin()); return new Iterator(this, container_.begin());
} }
virtual ParamIteratorInterface<T>* End() const { ParamIteratorInterface<T>* End() const override {
return new Iterator(this, container_.end()); return new Iterator(this, container_.end());
} }
...@@ -308,16 +308,16 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> { ...@@ -308,16 +308,16 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
Iterator(const ParamGeneratorInterface<T>* base, Iterator(const ParamGeneratorInterface<T>* base,
typename ContainerType::const_iterator iterator) typename ContainerType::const_iterator iterator)
: base_(base), iterator_(iterator) {} : base_(base), iterator_(iterator) {}
virtual ~Iterator() {} ~Iterator() override {}
virtual const ParamGeneratorInterface<T>* BaseGenerator() const { const ParamGeneratorInterface<T>* BaseGenerator() const override {
return base_; return base_;
} }
virtual void Advance() { void Advance() override {
++iterator_; ++iterator_;
value_.reset(); value_.reset();
} }
virtual ParamIteratorInterface<T>* Clone() const { ParamIteratorInterface<T>* Clone() const override {
return new Iterator(*this); return new Iterator(*this);
} }
// We need to use cached value referenced by iterator_ because *iterator_ // We need to use cached value referenced by iterator_ because *iterator_
...@@ -327,11 +327,11 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> { ...@@ -327,11 +327,11 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
// can advance iterator_ beyond the end of the range, and we cannot // can advance iterator_ beyond the end of the range, and we cannot
// detect that fact. The client code, on the other hand, is // detect that fact. The client code, on the other hand, is
// responsible for not calling Current() on an out-of-range iterator. // responsible for not calling Current() on an out-of-range iterator.
virtual const T* Current() const { const T* Current() const override {
if (value_.get() == nullptr) value_.reset(new T(*iterator_)); if (value_.get() == nullptr) value_.reset(new T(*iterator_));
return value_.get(); return value_.get();
} }
virtual bool Equals(const ParamIteratorInterface<T>& other) const { bool Equals(const ParamIteratorInterface<T>& other) const override {
// Having the same base generator guarantees that the other // Having the same base generator guarantees that the other
// iterator is of the same type and we can downcast. // iterator is of the same type and we can downcast.
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
...@@ -406,7 +406,7 @@ class ParameterizedTestFactory : public TestFactoryBase { ...@@ -406,7 +406,7 @@ class ParameterizedTestFactory : public TestFactoryBase {
typedef typename TestClass::ParamType ParamType; typedef typename TestClass::ParamType ParamType;
explicit ParameterizedTestFactory(ParamType parameter) : explicit ParameterizedTestFactory(ParamType parameter) :
parameter_(parameter) {} parameter_(parameter) {}
virtual Test* CreateTest() { Test* CreateTest() override {
TestClass::SetParam(&parameter_); TestClass::SetParam(&parameter_);
return new TestClass(); return new TestClass();
} }
...@@ -445,7 +445,7 @@ class TestMetaFactory ...@@ -445,7 +445,7 @@ class TestMetaFactory
TestMetaFactory() {} TestMetaFactory() {}
virtual TestFactoryBase* CreateTestFactory(ParamType parameter) { TestFactoryBase* CreateTestFactory(ParamType parameter) override {
return new ParameterizedTestFactory<TestCase>(parameter); return new ParameterizedTestFactory<TestCase>(parameter);
} }
...@@ -507,9 +507,11 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase { ...@@ -507,9 +507,11 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
: test_case_name_(name), code_location_(code_location) {} : test_case_name_(name), code_location_(code_location) {}
// Test case base name for display purposes. // Test case base name for display purposes.
virtual const std::string& GetTestCaseName() const { return test_case_name_; } const std::string& GetTestCaseName() const override {
return test_case_name_;
}
// Test case id to verify identity. // Test case id to verify identity.
virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); } TypeId GetTestCaseTypeId() const override { return GetTypeId<TestCase>(); }
// TEST_P macro uses AddTestPattern() to record information // TEST_P macro uses AddTestPattern() to record information
// about a single test in a LocalTestInfo structure. // about a single test in a LocalTestInfo structure.
// test_case_name is the base name of the test case (without invocation // test_case_name is the base name of the test case (without invocation
...@@ -537,7 +539,7 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase { ...@@ -537,7 +539,7 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
// This method should not be called more then once on any single // This method should not be called more then once on any single
// instance of a ParameterizedTestCaseInfoBase derived class. // instance of a ParameterizedTestCaseInfoBase derived class.
// UnitTest has a guard to prevent from calling this method more then once. // UnitTest has a guard to prevent from calling this method more then once.
virtual void RegisterTests() { void RegisterTests() override {
for (typename TestInfoContainer::iterator test_it = tests_.begin(); for (typename TestInfoContainer::iterator test_it = tests_.begin();
test_it != tests_.end(); ++test_it) { test_it != tests_.end(); ++test_it) {
std::shared_ptr<TestInfo> test_info = *test_it; std::shared_ptr<TestInfo> test_info = *test_it;
......
...@@ -1488,7 +1488,7 @@ class ThreadWithParam : public ThreadWithParamBase { ...@@ -1488,7 +1488,7 @@ class ThreadWithParam : public ThreadWithParamBase {
GTEST_CHECK_POSIX_SUCCESS_( GTEST_CHECK_POSIX_SUCCESS_(
pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base)); pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base));
} }
~ThreadWithParam() { Join(); } ~ThreadWithParam() override { Join(); }
void Join() { void Join() {
if (!finished_) { if (!finished_) {
...@@ -1497,7 +1497,7 @@ class ThreadWithParam : public ThreadWithParamBase { ...@@ -1497,7 +1497,7 @@ class ThreadWithParam : public ThreadWithParamBase {
} }
} }
virtual void Run() { void Run() override {
if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification(); if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification();
func_(param_); func_(param_);
} }
......
...@@ -54,7 +54,7 @@ class PrimeTable { ...@@ -54,7 +54,7 @@ class PrimeTable {
// Implementation #1 calculates the primes on-the-fly. // Implementation #1 calculates the primes on-the-fly.
class OnTheFlyPrimeTable : public PrimeTable { class OnTheFlyPrimeTable : public PrimeTable {
public: public:
virtual bool IsPrime(int n) const { bool IsPrime(int n) const override {
if (n <= 1) return false; if (n <= 1) return false;
for (int i = 2; i*i <= n; i++) { for (int i = 2; i*i <= n; i++) {
...@@ -65,7 +65,7 @@ class OnTheFlyPrimeTable : public PrimeTable { ...@@ -65,7 +65,7 @@ class OnTheFlyPrimeTable : public PrimeTable {
return true; return true;
} }
virtual int GetNextPrime(int p) const { int GetNextPrime(int p) const override {
for (int n = p + 1; n > 0; n++) { for (int n = p + 1; n > 0; n++) {
if (IsPrime(n)) return n; if (IsPrime(n)) return n;
} }
...@@ -83,13 +83,13 @@ class PreCalculatedPrimeTable : public PrimeTable { ...@@ -83,13 +83,13 @@ class PreCalculatedPrimeTable : public PrimeTable {
: is_prime_size_(max + 1), is_prime_(new bool[max + 1]) { : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) {
CalculatePrimesUpTo(max); CalculatePrimesUpTo(max);
} }
virtual ~PreCalculatedPrimeTable() { delete[] is_prime_; } ~PreCalculatedPrimeTable() override { delete[] is_prime_; }
virtual bool IsPrime(int n) const { bool IsPrime(int n) const override {
return 0 <= n && n < is_prime_size_ && is_prime_[n]; return 0 <= n && n < is_prime_size_ && is_prime_[n];
} }
virtual int GetNextPrime(int p) const { int GetNextPrime(int p) const override {
for (int n = p + 1; n < is_prime_size_; n++) { for (int n = p + 1; n < is_prime_size_; n++) {
if (is_prime_[n]) return n; if (is_prime_[n]) return n;
} }
......
...@@ -74,12 +74,12 @@ int Water::allocated_ = 0; ...@@ -74,12 +74,12 @@ int Water::allocated_ = 0;
class LeakChecker : public EmptyTestEventListener { class LeakChecker : public EmptyTestEventListener {
private: private:
// Called before a test starts. // Called before a test starts.
virtual void OnTestStart(const TestInfo& /* test_info */) { void OnTestStart(const TestInfo& /* test_info */) override {
initially_allocated_ = Water::allocated(); initially_allocated_ = Water::allocated();
} }
// Called after a test ends. // Called after a test ends.
virtual void OnTestEnd(const TestInfo& /* test_info */) { void OnTestEnd(const TestInfo& /* test_info */) override {
int difference = Water::allocated() - initially_allocated_; int difference = Water::allocated() - initially_allocated_;
// You can generate a failure in any event handler except // You can generate a failure in any event handler except
......
...@@ -71,7 +71,7 @@ class QueueTestSmpl3 : public testing::Test { ...@@ -71,7 +71,7 @@ class QueueTestSmpl3 : public testing::Test {
// virtual void SetUp() will be called before each test is run. You // virtual void SetUp() will be called before each test is run. You
// should define it if you need to initialize the variables. // should define it if you need to initialize the variables.
// Otherwise, this can be skipped. // Otherwise, this can be skipped.
virtual void SetUp() { void SetUp() override {
q1_.Enqueue(1); q1_.Enqueue(1);
q2_.Enqueue(2); q2_.Enqueue(2);
q2_.Enqueue(3); q2_.Enqueue(3);
......
...@@ -63,11 +63,11 @@ class QuickTest : public testing::Test { ...@@ -63,11 +63,11 @@ class QuickTest : public testing::Test {
protected: protected:
// Remember that SetUp() is run immediately before a test starts. // Remember that SetUp() is run immediately before a test starts.
// This is a good place to record the start time. // This is a good place to record the start time.
virtual void SetUp() { start_time_ = time(nullptr); } void SetUp() override { start_time_ = time(nullptr); }
// TearDown() is invoked immediately after a test finishes. Here we // TearDown() is invoked immediately after a test finishes. Here we
// check if the test was too slow. // check if the test was too slow.
virtual void TearDown() { void TearDown() override {
// Gets the time when the test finishes // Gets the time when the test finishes
const time_t end_time = time(nullptr); const time_t end_time = time(nullptr);
...@@ -140,7 +140,7 @@ TEST_F(IntegerFunctionTest, IsPrime) { ...@@ -140,7 +140,7 @@ TEST_F(IntegerFunctionTest, IsPrime) {
// stuff inside the body of the test fixture, as usual. // stuff inside the body of the test fixture, as usual.
class QueueTest : public QuickTest { class QueueTest : public QuickTest {
protected: protected:
virtual void SetUp() { void SetUp() override {
// First, we need to set up the super fixture (QuickTest). // First, we need to set up the super fixture (QuickTest).
QuickTest::SetUp(); QuickTest::SetUp();
......
...@@ -61,7 +61,7 @@ class PrimeTableTest : public testing::Test { ...@@ -61,7 +61,7 @@ class PrimeTableTest : public testing::Test {
// implemented by T. // implemented by T.
PrimeTableTest() : table_(CreatePrimeTable<T>()) {} PrimeTableTest() : table_(CreatePrimeTable<T>()) {}
virtual ~PrimeTableTest() { delete table_; } ~PrimeTableTest() override { delete table_; }
// Note that we test an implementation via the base interface // Note that we test an implementation via the base interface
// instead of the actual implementation class. This is important // instead of the actual implementation class. This is important
......
...@@ -65,9 +65,9 @@ PrimeTable* CreatePreCalculatedPrimeTable() { ...@@ -65,9 +65,9 @@ PrimeTable* CreatePreCalculatedPrimeTable() {
// create and store an instance of PrimeTable. // create and store an instance of PrimeTable.
class PrimeTableTestSmpl7 : public TestWithParam<CreatePrimeTableFunc*> { class PrimeTableTestSmpl7 : public TestWithParam<CreatePrimeTableFunc*> {
public: public:
virtual ~PrimeTableTestSmpl7() { delete table_; } ~PrimeTableTestSmpl7() override { delete table_; }
virtual void SetUp() { table_ = (*GetParam())(); } void SetUp() override { table_ = (*GetParam())(); }
virtual void TearDown() { void TearDown() override {
delete table_; delete table_;
table_ = nullptr; table_ = nullptr;
} }
......
...@@ -53,19 +53,19 @@ class HybridPrimeTable : public PrimeTable { ...@@ -53,19 +53,19 @@ class HybridPrimeTable : public PrimeTable {
? nullptr ? nullptr
: new PreCalculatedPrimeTable(max_precalculated)), : new PreCalculatedPrimeTable(max_precalculated)),
max_precalculated_(max_precalculated) {} max_precalculated_(max_precalculated) {}
virtual ~HybridPrimeTable() { ~HybridPrimeTable() override {
delete on_the_fly_impl_; delete on_the_fly_impl_;
delete precalc_impl_; delete precalc_impl_;
} }
virtual bool IsPrime(int n) const { bool IsPrime(int n) const override {
if (precalc_impl_ != nullptr && n < max_precalculated_) if (precalc_impl_ != nullptr && n < max_precalculated_)
return precalc_impl_->IsPrime(n); return precalc_impl_->IsPrime(n);
else else
return on_the_fly_impl_->IsPrime(n); return on_the_fly_impl_->IsPrime(n);
} }
virtual int GetNextPrime(int p) const { int GetNextPrime(int p) const override {
int next_prime = -1; int next_prime = -1;
if (precalc_impl_ != nullptr && p < max_precalculated_) if (precalc_impl_ != nullptr && p < max_precalculated_)
next_prime = precalc_impl_->GetNextPrime(p); next_prime = precalc_impl_->GetNextPrime(p);
...@@ -91,13 +91,13 @@ using ::testing::Combine; ...@@ -91,13 +91,13 @@ using ::testing::Combine;
// HybridPrimeTable instance. // HybridPrimeTable instance.
class PrimeTableTest : public TestWithParam< ::std::tuple<bool, int> > { class PrimeTableTest : public TestWithParam< ::std::tuple<bool, int> > {
protected: protected:
virtual void SetUp() { void SetUp() override {
bool force_on_the_fly; bool force_on_the_fly;
int max_precalculated; int max_precalculated;
std::tie(force_on_the_fly, max_precalculated) = GetParam(); std::tie(force_on_the_fly, max_precalculated) = GetParam();
table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated); table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated);
} }
virtual void TearDown() { void TearDown() override {
delete table_; delete table_;
table_ = nullptr; table_ = nullptr;
} }
......
...@@ -49,16 +49,16 @@ namespace { ...@@ -49,16 +49,16 @@ namespace {
class TersePrinter : public EmptyTestEventListener { class TersePrinter : public EmptyTestEventListener {
private: private:
// Called before any test activity starts. // Called before any test activity starts.
virtual void OnTestProgramStart(const UnitTest& /* unit_test */) {} void OnTestProgramStart(const UnitTest& /* unit_test */) override {}
// Called after all test activities have ended. // Called after all test activities have ended.
virtual void OnTestProgramEnd(const UnitTest& unit_test) { void OnTestProgramEnd(const UnitTest& unit_test) override {
fprintf(stdout, "TEST %s\n", unit_test.Passed() ? "PASSED" : "FAILED"); fprintf(stdout, "TEST %s\n", unit_test.Passed() ? "PASSED" : "FAILED");
fflush(stdout); fflush(stdout);
} }
// Called before a test starts. // Called before a test starts.
virtual void OnTestStart(const TestInfo& test_info) { void OnTestStart(const TestInfo& test_info) override {
fprintf(stdout, fprintf(stdout,
"*** Test %s.%s starting.\n", "*** Test %s.%s starting.\n",
test_info.test_case_name(), test_info.test_case_name(),
...@@ -67,7 +67,7 @@ class TersePrinter : public EmptyTestEventListener { ...@@ -67,7 +67,7 @@ class TersePrinter : public EmptyTestEventListener {
} }
// Called after a failed assertion or a SUCCEED() invocation. // Called after a failed assertion or a SUCCEED() invocation.
virtual void OnTestPartResult(const TestPartResult& test_part_result) { void OnTestPartResult(const TestPartResult& test_part_result) override {
fprintf(stdout, fprintf(stdout,
"%s in %s:%d\n%s\n", "%s in %s:%d\n%s\n",
test_part_result.failed() ? "*** Failure" : "Success", test_part_result.failed() ? "*** Failure" : "Success",
...@@ -78,7 +78,7 @@ class TersePrinter : public EmptyTestEventListener { ...@@ -78,7 +78,7 @@ class TersePrinter : public EmptyTestEventListener {
} }
// Called after a test ends. // Called after a test ends.
virtual void OnTestEnd(const TestInfo& test_info) { void OnTestEnd(const TestInfo& test_info) override {
fprintf(stdout, fprintf(stdout,
"*** Test %s.%s ending.\n", "*** Test %s.%s ending.\n",
test_info.test_case_name(), test_info.test_case_name(),
......
...@@ -407,10 +407,10 @@ class DeathTestImpl : public DeathTest { ...@@ -407,10 +407,10 @@ class DeathTestImpl : public DeathTest {
write_fd_(-1) {} write_fd_(-1) {}
// read_fd_ is expected to be closed and cleared by a derived class. // read_fd_ is expected to be closed and cleared by a derived class.
~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); } ~DeathTestImpl() override { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }
void Abort(AbortReason reason); void Abort(AbortReason reason) override;
virtual bool Passed(bool status_ok); bool Passed(bool status_ok) override;
const char* statement() const { return statement_; } const char* statement() const { return statement_; }
bool spawned() const { return spawned_; } bool spawned() const { return spawned_; }
...@@ -1065,7 +1065,7 @@ class ForkingDeathTest : public DeathTestImpl { ...@@ -1065,7 +1065,7 @@ class ForkingDeathTest : public DeathTestImpl {
ForkingDeathTest(const char* statement, Matcher<const std::string&> matcher); ForkingDeathTest(const char* statement, Matcher<const std::string&> matcher);
// All of these virtual functions are inherited from DeathTest. // All of these virtual functions are inherited from DeathTest.
virtual int Wait(); int Wait() override;
protected: protected:
void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; } void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }
...@@ -1101,7 +1101,7 @@ class NoExecDeathTest : public ForkingDeathTest { ...@@ -1101,7 +1101,7 @@ class NoExecDeathTest : public ForkingDeathTest {
public: public:
NoExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher) NoExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher)
: ForkingDeathTest(a_statement, std::move(matcher)) {} : ForkingDeathTest(a_statement, std::move(matcher)) {}
virtual TestRole AssumeRole(); TestRole AssumeRole() override;
}; };
// The AssumeRole process for a fork-and-run death test. It implements a // The AssumeRole process for a fork-and-run death test. It implements a
...@@ -1159,7 +1159,8 @@ class ExecDeathTest : public ForkingDeathTest { ...@@ -1159,7 +1159,8 @@ class ExecDeathTest : public ForkingDeathTest {
: ForkingDeathTest(a_statement, std::move(matcher)), : ForkingDeathTest(a_statement, std::move(matcher)),
file_(file), file_(file),
line_(line) {} line_(line) {}
virtual TestRole AssumeRole(); TestRole AssumeRole() override;
private: private:
static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() { static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() {
::std::vector<std::string> args = GetInjectableArgvs(); ::std::vector<std::string> args = GetInjectableArgvs();
......
...@@ -443,8 +443,8 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface { ...@@ -443,8 +443,8 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface {
public: public:
OsStackTraceGetter() {} OsStackTraceGetter() {}
virtual std::string CurrentStackTrace(int max_depth, int skip_count); std::string CurrentStackTrace(int max_depth, int skip_count) override;
virtual void UponLeavingGTest(); void UponLeavingGTest() override;
private: private:
#if GTEST_HAS_ABSL #if GTEST_HAS_ABSL
...@@ -475,7 +475,7 @@ class DefaultGlobalTestPartResultReporter ...@@ -475,7 +475,7 @@ class DefaultGlobalTestPartResultReporter
explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test); explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);
// Implements the TestPartResultReporterInterface. Reports the test part // Implements the TestPartResultReporterInterface. Reports the test part
// result in the current test. // result in the current test.
virtual void ReportTestPartResult(const TestPartResult& result); void ReportTestPartResult(const TestPartResult& result) override;
private: private:
UnitTestImpl* const unit_test_; UnitTestImpl* const unit_test_;
...@@ -491,7 +491,7 @@ class DefaultPerThreadTestPartResultReporter ...@@ -491,7 +491,7 @@ class DefaultPerThreadTestPartResultReporter
explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test); explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);
// Implements the TestPartResultReporterInterface. The implementation just // Implements the TestPartResultReporterInterface. The implementation just
// delegates to the current global test part result reporter of *unit_test_. // delegates to the current global test part result reporter of *unit_test_.
virtual void ReportTestPartResult(const TestPartResult& result); void ReportTestPartResult(const TestPartResult& result) override;
private: private:
UnitTestImpl* const unit_test_; UnitTestImpl* const unit_test_;
...@@ -1063,13 +1063,13 @@ class StreamingListener : public EmptyTestEventListener { ...@@ -1063,13 +1063,13 @@ class StreamingListener : public EmptyTestEventListener {
MakeConnection(); MakeConnection();
} }
virtual ~SocketWriter() { ~SocketWriter() override {
if (sockfd_ != -1) if (sockfd_ != -1)
CloseConnection(); CloseConnection();
} }
// Sends a string to the socket. // Sends a string to the socket.
virtual void Send(const std::string& message) { void Send(const std::string& message) override {
GTEST_CHECK_(sockfd_ != -1) GTEST_CHECK_(sockfd_ != -1)
<< "Send() can be called only when there is a connection."; << "Send() can be called only when there is a connection.";
...@@ -1086,7 +1086,7 @@ class StreamingListener : public EmptyTestEventListener { ...@@ -1086,7 +1086,7 @@ class StreamingListener : public EmptyTestEventListener {
void MakeConnection(); void MakeConnection();
// Closes the socket. // Closes the socket.
void CloseConnection() { void CloseConnection() override {
GTEST_CHECK_(sockfd_ != -1) GTEST_CHECK_(sockfd_ != -1)
<< "CloseConnection() can be called only when there is a connection."; << "CloseConnection() can be called only when there is a connection.";
...@@ -1112,11 +1112,11 @@ class StreamingListener : public EmptyTestEventListener { ...@@ -1112,11 +1112,11 @@ class StreamingListener : public EmptyTestEventListener {
explicit StreamingListener(AbstractSocketWriter* socket_writer) explicit StreamingListener(AbstractSocketWriter* socket_writer)
: socket_writer_(socket_writer) { Start(); } : socket_writer_(socket_writer) { Start(); }
void OnTestProgramStart(const UnitTest& /* unit_test */) { void OnTestProgramStart(const UnitTest& /* unit_test */) override {
SendLn("event=TestProgramStart"); SendLn("event=TestProgramStart");
} }
void OnTestProgramEnd(const UnitTest& unit_test) { void OnTestProgramEnd(const UnitTest& unit_test) override {
// Note that Google Test current only report elapsed time for each // Note that Google Test current only report elapsed time for each
// test iteration, not for the entire test program. // test iteration, not for the entire test program.
SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed())); SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed()));
...@@ -1125,39 +1125,41 @@ class StreamingListener : public EmptyTestEventListener { ...@@ -1125,39 +1125,41 @@ class StreamingListener : public EmptyTestEventListener {
socket_writer_->CloseConnection(); socket_writer_->CloseConnection();
} }
void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) { void OnTestIterationStart(const UnitTest& /* unit_test */,
int iteration) override {
SendLn("event=TestIterationStart&iteration=" + SendLn("event=TestIterationStart&iteration=" +
StreamableToString(iteration)); StreamableToString(iteration));
} }
void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) { void OnTestIterationEnd(const UnitTest& unit_test,
int /* iteration */) override {
SendLn("event=TestIterationEnd&passed=" + SendLn("event=TestIterationEnd&passed=" +
FormatBool(unit_test.Passed()) + "&elapsed_time=" + FormatBool(unit_test.Passed()) + "&elapsed_time=" +
StreamableToString(unit_test.elapsed_time()) + "ms"); StreamableToString(unit_test.elapsed_time()) + "ms");
} }
void OnTestCaseStart(const TestCase& test_case) { void OnTestCaseStart(const TestCase& test_case) override {
SendLn(std::string("event=TestCaseStart&name=") + test_case.name()); SendLn(std::string("event=TestCaseStart&name=") + test_case.name());
} }
void OnTestCaseEnd(const TestCase& test_case) { void OnTestCaseEnd(const TestCase& test_case) override {
SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed()) SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed())
+ "&elapsed_time=" + StreamableToString(test_case.elapsed_time()) + "&elapsed_time=" + StreamableToString(test_case.elapsed_time())
+ "ms"); + "ms");
} }
void OnTestStart(const TestInfo& test_info) { void OnTestStart(const TestInfo& test_info) override {
SendLn(std::string("event=TestStart&name=") + test_info.name()); SendLn(std::string("event=TestStart&name=") + test_info.name());
} }
void OnTestEnd(const TestInfo& test_info) { void OnTestEnd(const TestInfo& test_info) override {
SendLn("event=TestEnd&passed=" + SendLn("event=TestEnd&passed=" +
FormatBool((test_info.result())->Passed()) + FormatBool((test_info.result())->Passed()) +
"&elapsed_time=" + "&elapsed_time=" +
StreamableToString((test_info.result())->elapsed_time()) + "ms"); StreamableToString((test_info.result())->elapsed_time()) + "ms");
} }
void OnTestPartResult(const TestPartResult& test_part_result) { void OnTestPartResult(const TestPartResult& test_part_result) override {
const char* file_name = test_part_result.file_name(); const char* file_name = test_part_result.file_name();
if (file_name == nullptr) file_name = ""; if (file_name == nullptr) file_name = "";
SendLn("event=TestPartResult&file=" + UrlEncode(file_name) + SendLn("event=TestPartResult&file=" + UrlEncode(file_name) +
......
...@@ -3111,19 +3111,19 @@ class PrettyUnitTestResultPrinter : public TestEventListener { ...@@ -3111,19 +3111,19 @@ class PrettyUnitTestResultPrinter : public TestEventListener {
} }
// The following methods override what's in the TestEventListener class. // The following methods override what's in the TestEventListener class.
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {} void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); void OnTestIterationStart(const UnitTest& unit_test, 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& result); void OnTestPartResult(const TestPartResult& 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, int iteration); void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
private: private:
static void PrintFailedTests(const UnitTest& unit_test); static void PrintFailedTests(const UnitTest& unit_test);
...@@ -3352,7 +3352,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, ...@@ -3352,7 +3352,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
class TestEventRepeater : public TestEventListener { class TestEventRepeater : public TestEventListener {
public: public:
TestEventRepeater() : forwarding_enabled_(true) {} TestEventRepeater() : forwarding_enabled_(true) {}
virtual ~TestEventRepeater(); ~TestEventRepeater() override;
void Append(TestEventListener *listener); void Append(TestEventListener *listener);
TestEventListener* Release(TestEventListener* listener); TestEventListener* Release(TestEventListener* listener);
...@@ -3361,19 +3361,19 @@ class TestEventRepeater : public TestEventListener { ...@@ -3361,19 +3361,19 @@ class TestEventRepeater : public TestEventListener {
bool forwarding_enabled() const { return forwarding_enabled_; } bool forwarding_enabled() const { return forwarding_enabled_; }
void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; } void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
virtual void OnTestProgramStart(const UnitTest& unit_test); void OnTestProgramStart(const UnitTest& unit_test) override;
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); void OnTestIterationStart(const UnitTest& unit_test, 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& result); void OnTestPartResult(const TestPartResult& 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, int iteration); void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
virtual void OnTestProgramEnd(const UnitTest& unit_test); void OnTestProgramEnd(const UnitTest& unit_test) override;
private: private:
// Controls whether events will be forwarded to listeners_. Set to false // Controls whether events will be forwarded to listeners_. Set to false
...@@ -3466,7 +3466,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { ...@@ -3466,7 +3466,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
public: public:
explicit XmlUnitTestResultPrinter(const char* output_file); explicit XmlUnitTestResultPrinter(const char* output_file);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
void ListTestsMatchingFilter(const std::vector<TestCase*>& test_cases); void ListTestsMatchingFilter(const std::vector<TestCase*>& test_cases);
// Prints an XML summary of all unit tests. // Prints an XML summary of all unit tests.
...@@ -3924,7 +3924,7 @@ class JsonUnitTestResultPrinter : public EmptyTestEventListener { ...@@ -3924,7 +3924,7 @@ class JsonUnitTestResultPrinter : public EmptyTestEventListener {
public: public:
explicit JsonUnitTestResultPrinter(const char* output_file); explicit JsonUnitTestResultPrinter(const char* output_file);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
// Prints an JSON summary of all unit tests. // Prints an JSON summary of all unit tests.
static void PrintJsonTestList(::std::ostream* stream, static void PrintJsonTestList(::std::ostream* stream,
......
...@@ -116,17 +116,17 @@ class CxxExceptionInConstructorTest : public Test { ...@@ -116,17 +116,17 @@ class CxxExceptionInConstructorTest : public Test {
} }
protected: protected:
~CxxExceptionInConstructorTest() { ~CxxExceptionInConstructorTest() override {
ADD_FAILURE() << "CxxExceptionInConstructorTest destructor " ADD_FAILURE() << "CxxExceptionInConstructorTest destructor "
<< "called unexpectedly."; << "called unexpectedly.";
} }
virtual void SetUp() { void SetUp() override {
ADD_FAILURE() << "CxxExceptionInConstructorTest::SetUp() " ADD_FAILURE() << "CxxExceptionInConstructorTest::SetUp() "
<< "called unexpectedly."; << "called unexpectedly.";
} }
virtual void TearDown() { void TearDown() override {
ADD_FAILURE() << "CxxExceptionInConstructorTest::TearDown() " ADD_FAILURE() << "CxxExceptionInConstructorTest::TearDown() "
<< "called unexpectedly."; << "called unexpectedly.";
} }
...@@ -157,19 +157,19 @@ class CxxExceptionInSetUpTestCaseTest : public Test { ...@@ -157,19 +157,19 @@ class CxxExceptionInSetUpTestCaseTest : public Test {
} }
protected: protected:
~CxxExceptionInSetUpTestCaseTest() { ~CxxExceptionInSetUpTestCaseTest() override {
printf("%s", printf("%s",
"CxxExceptionInSetUpTestCaseTest destructor " "CxxExceptionInSetUpTestCaseTest destructor "
"called as expected.\n"); "called as expected.\n");
} }
virtual void SetUp() { void SetUp() override {
printf("%s", printf("%s",
"CxxExceptionInSetUpTestCaseTest::SetUp() " "CxxExceptionInSetUpTestCaseTest::SetUp() "
"called as expected.\n"); "called as expected.\n");
} }
virtual void TearDown() { void TearDown() override {
printf("%s", printf("%s",
"CxxExceptionInSetUpTestCaseTest::TearDown() " "CxxExceptionInSetUpTestCaseTest::TearDown() "
"called as expected.\n"); "called as expected.\n");
...@@ -200,15 +200,15 @@ class CxxExceptionInSetUpTest : public Test { ...@@ -200,15 +200,15 @@ class CxxExceptionInSetUpTest : public Test {
} }
protected: protected:
~CxxExceptionInSetUpTest() { ~CxxExceptionInSetUpTest() override {
printf("%s", printf("%s",
"CxxExceptionInSetUpTest destructor " "CxxExceptionInSetUpTest destructor "
"called as expected.\n"); "called as expected.\n");
} }
virtual void SetUp() { throw std::runtime_error("Standard C++ exception"); } void SetUp() override { throw std::runtime_error("Standard C++ exception"); }
virtual void TearDown() { void TearDown() override {
printf("%s", printf("%s",
"CxxExceptionInSetUpTest::TearDown() " "CxxExceptionInSetUpTest::TearDown() "
"called as expected.\n"); "called as expected.\n");
...@@ -229,13 +229,13 @@ class CxxExceptionInTearDownTest : public Test { ...@@ -229,13 +229,13 @@ class CxxExceptionInTearDownTest : public Test {
} }
protected: protected:
~CxxExceptionInTearDownTest() { ~CxxExceptionInTearDownTest() override {
printf("%s", printf("%s",
"CxxExceptionInTearDownTest destructor " "CxxExceptionInTearDownTest destructor "
"called as expected.\n"); "called as expected.\n");
} }
virtual void TearDown() { void TearDown() override {
throw std::runtime_error("Standard C++ exception"); throw std::runtime_error("Standard C++ exception");
} }
}; };
...@@ -251,13 +251,13 @@ class CxxExceptionInTestBodyTest : public Test { ...@@ -251,13 +251,13 @@ class CxxExceptionInTestBodyTest : public Test {
} }
protected: protected:
~CxxExceptionInTestBodyTest() { ~CxxExceptionInTestBodyTest() override {
printf("%s", printf("%s",
"CxxExceptionInTestBodyTest destructor " "CxxExceptionInTestBodyTest destructor "
"called as expected.\n"); "called as expected.\n");
} }
virtual void TearDown() { void TearDown() override {
printf("%s", printf("%s",
"CxxExceptionInTestBodyTest::TearDown() " "CxxExceptionInTestBodyTest::TearDown() "
"called as expected.\n"); "called as expected.\n");
......
...@@ -128,9 +128,7 @@ class TestForDeathTest : public testing::Test { ...@@ -128,9 +128,7 @@ class TestForDeathTest : public testing::Test {
protected: protected:
TestForDeathTest() : original_dir_(FilePath::GetCurrentDir()) {} TestForDeathTest() : original_dir_(FilePath::GetCurrentDir()) {}
virtual ~TestForDeathTest() { ~TestForDeathTest() override { posix::ChDir(original_dir_.c_str()); }
posix::ChDir(original_dir_.c_str());
}
// A static member function that's expected to die. // A static member function that's expected to die.
static void StaticMemberFunction() { DieInside("StaticMemberFunction"); } static void StaticMemberFunction() { DieInside("StaticMemberFunction"); }
...@@ -885,9 +883,9 @@ TEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) { ...@@ -885,9 +883,9 @@ TEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {
class MockDeathTestFactory : public DeathTestFactory { class MockDeathTestFactory : public DeathTestFactory {
public: public:
MockDeathTestFactory(); MockDeathTestFactory();
virtual bool Create(const char* statement, bool Create(const char* statement,
testing::Matcher<const std::string&> matcher, testing::Matcher<const std::string&> matcher, const char* file,
const char* file, int line, DeathTest** test); int line, DeathTest** test) override;
// Sets the parameters for subsequent calls to Create. // Sets the parameters for subsequent calls to Create.
void SetParameters(bool create, DeathTest::TestRole role, void SetParameters(bool create, DeathTest::TestRole role,
...@@ -942,22 +940,20 @@ class MockDeathTest : public DeathTest { ...@@ -942,22 +940,20 @@ class MockDeathTest : public DeathTest {
TestRole role, int status, bool passed) : TestRole role, int status, bool passed) :
parent_(parent), role_(role), status_(status), passed_(passed) { parent_(parent), role_(role), status_(status), passed_(passed) {
} }
virtual ~MockDeathTest() { ~MockDeathTest() override { parent_->test_deleted_ = true; }
parent_->test_deleted_ = true; TestRole AssumeRole() override {
}
virtual TestRole AssumeRole() {
++parent_->assume_role_calls_; ++parent_->assume_role_calls_;
return role_; return role_;
} }
virtual int Wait() { int Wait() override {
++parent_->wait_calls_; ++parent_->wait_calls_;
return status_; return status_;
} }
virtual bool Passed(bool exit_status_ok) { bool Passed(bool exit_status_ok) override {
parent_->passed_args_.push_back(exit_status_ok); parent_->passed_args_.push_back(exit_status_ok);
return passed_; return passed_;
} }
virtual void Abort(AbortReason reason) { void Abort(AbortReason reason) override {
parent_->abort_args_.push_back(reason); parent_->abort_args_.push_back(reason);
} }
......
...@@ -59,7 +59,7 @@ TEST(CxxExceptionDeathTest, ExceptionIsFailure) { ...@@ -59,7 +59,7 @@ TEST(CxxExceptionDeathTest, ExceptionIsFailure) {
class TestException : public std::exception { class TestException : public std::exception {
public: public:
virtual const char* what() const throw() { return "exceptional message"; } const char* what() const throw() override { return "exceptional message"; }
}; };
TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) { TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
......
...@@ -479,7 +479,7 @@ TEST(AssignmentOperatorTest, ConstAssignedToNonConst) { ...@@ -479,7 +479,7 @@ TEST(AssignmentOperatorTest, ConstAssignedToNonConst) {
class DirectoryCreationTest : public Test { class DirectoryCreationTest : public Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
testdata_path_.Set(FilePath( testdata_path_.Set(FilePath(
TempDir() + GetCurrentExecutableName().string() + TempDir() + GetCurrentExecutableName().string() +
"_directory_creation" GTEST_PATH_SEP_ "test" GTEST_PATH_SEP_)); "_directory_creation" GTEST_PATH_SEP_ "test" GTEST_PATH_SEP_));
...@@ -496,7 +496,7 @@ class DirectoryCreationTest : public Test { ...@@ -496,7 +496,7 @@ class DirectoryCreationTest : public Test {
posix::RmDir(testdata_path_.c_str()); posix::RmDir(testdata_path_.c_str());
} }
virtual void TearDown() { void TearDown() override {
remove(testdata_file_.c_str()); remove(testdata_file_.c_str());
remove(unique_file0_.c_str()); remove(unique_file0_.c_str());
remove(unique_file1_.c_str()); remove(unique_file1_.c_str());
......
...@@ -57,63 +57,63 @@ class EventRecordingListener : public TestEventListener { ...@@ -57,63 +57,63 @@ class EventRecordingListener : public TestEventListener {
explicit EventRecordingListener(const char* name) : name_(name) {} explicit EventRecordingListener(const char* name) : name_(name) {}
protected: protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { void OnTestProgramStart(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnTestProgramStart")); g_events->push_back(GetFullMethodName("OnTestProgramStart"));
} }
virtual void OnTestIterationStart(const UnitTest& /*unit_test*/, void OnTestIterationStart(const UnitTest& /*unit_test*/,
int iteration) { int iteration) override {
Message message; Message message;
message << GetFullMethodName("OnTestIterationStart") message << GetFullMethodName("OnTestIterationStart")
<< "(" << iteration << ")"; << "(" << iteration << ")";
g_events->push_back(message.GetString()); g_events->push_back(message.GetString());
} }
virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) { void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpStart")); g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpStart"));
} }
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) { void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpEnd")); g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpEnd"));
} }
virtual void OnTestCaseStart(const TestCase& /*test_case*/) { void OnTestCaseStart(const TestCase& /*test_case*/) override {
g_events->push_back(GetFullMethodName("OnTestCaseStart")); g_events->push_back(GetFullMethodName("OnTestCaseStart"));
} }
virtual void OnTestStart(const TestInfo& /*test_info*/) { void OnTestStart(const TestInfo& /*test_info*/) override {
g_events->push_back(GetFullMethodName("OnTestStart")); g_events->push_back(GetFullMethodName("OnTestStart"));
} }
virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) { void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {
g_events->push_back(GetFullMethodName("OnTestPartResult")); g_events->push_back(GetFullMethodName("OnTestPartResult"));
} }
virtual void OnTestEnd(const TestInfo& /*test_info*/) { void OnTestEnd(const TestInfo& /*test_info*/) override {
g_events->push_back(GetFullMethodName("OnTestEnd")); g_events->push_back(GetFullMethodName("OnTestEnd"));
} }
virtual void OnTestCaseEnd(const TestCase& /*test_case*/) { void OnTestCaseEnd(const TestCase& /*test_case*/) override {
g_events->push_back(GetFullMethodName("OnTestCaseEnd")); g_events->push_back(GetFullMethodName("OnTestCaseEnd"));
} }
virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) { void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownStart")); g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownStart"));
} }
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) { void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownEnd")); g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownEnd"));
} }
virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/, void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int iteration) { int iteration) override {
Message message; Message message;
message << GetFullMethodName("OnTestIterationEnd") message << GetFullMethodName("OnTestIterationEnd")
<< "(" << iteration << ")"; << "(" << iteration << ")";
g_events->push_back(message.GetString()); g_events->push_back(message.GetString());
} }
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) { void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {
g_events->push_back(GetFullMethodName("OnTestProgramEnd")); g_events->push_back(GetFullMethodName("OnTestProgramEnd"));
} }
...@@ -127,13 +127,9 @@ class EventRecordingListener : public TestEventListener { ...@@ -127,13 +127,9 @@ class EventRecordingListener : public TestEventListener {
class EnvironmentInvocationCatcher : public Environment { class EnvironmentInvocationCatcher : public Environment {
protected: protected:
virtual void SetUp() { void SetUp() override { g_events->push_back("Environment::SetUp"); }
g_events->push_back("Environment::SetUp");
}
virtual void TearDown() { void TearDown() override { g_events->push_back("Environment::TearDown"); }
g_events->push_back("Environment::TearDown");
}
}; };
class ListenerTest : public Test { class ListenerTest : public Test {
...@@ -146,13 +142,9 @@ class ListenerTest : public Test { ...@@ -146,13 +142,9 @@ class ListenerTest : public Test {
g_events->push_back("ListenerTest::TearDownTestCase"); g_events->push_back("ListenerTest::TearDownTestCase");
} }
virtual void SetUp() { void SetUp() override { g_events->push_back("ListenerTest::SetUp"); }
g_events->push_back("ListenerTest::SetUp");
}
virtual void TearDown() { void TearDown() override { g_events->push_back("ListenerTest::TearDown"); }
g_events->push_back("ListenerTest::TearDown");
}
}; };
TEST_F(ListenerTest, DoesFoo) { TEST_F(ListenerTest, DoesFoo) {
......
...@@ -126,7 +126,7 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) { ...@@ -126,7 +126,7 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
class XmlOutputChangeDirTest : public Test { class XmlOutputChangeDirTest : public Test {
protected: protected:
virtual void SetUp() { void SetUp() override {
original_working_dir_ = FilePath::GetCurrentDir(); original_working_dir_ = FilePath::GetCurrentDir();
posix::ChDir(".."); posix::ChDir("..");
// This will make the test fail if run from the root directory. // This will make the test fail if run from the root directory.
...@@ -134,7 +134,7 @@ class XmlOutputChangeDirTest : public Test { ...@@ -134,7 +134,7 @@ class XmlOutputChangeDirTest : public Test {
FilePath::GetCurrentDir().string()); FilePath::GetCurrentDir().string());
} }
virtual void TearDown() { void TearDown() override {
posix::ChDir(original_working_dir_.string().c_str()); posix::ChDir(original_working_dir_.string().c_str());
} }
......
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