Googletest export

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

PiperOrigin-RevId: 223800219
This commit is contained in:
Abseil Team
2018-12-03 11:30:02 -05:00
committed by Gennadiy Civil
parent 9ddcb0b4dd
commit adba5a751f
51 changed files with 507 additions and 555 deletions

View File

@@ -54,7 +54,7 @@ class PrimeTable {
// Implementation #1 calculates the primes on-the-fly.
class OnTheFlyPrimeTable : public PrimeTable {
public:
virtual bool IsPrime(int n) const {
bool IsPrime(int n) const override {
if (n <= 1) return false;
for (int i = 2; i*i <= n; i++) {
@@ -65,7 +65,7 @@ class OnTheFlyPrimeTable : public PrimeTable {
return true;
}
virtual int GetNextPrime(int p) const {
int GetNextPrime(int p) const override {
for (int n = p + 1; n > 0; n++) {
if (IsPrime(n)) return n;
}
@@ -83,13 +83,13 @@ class PreCalculatedPrimeTable : public PrimeTable {
: is_prime_size_(max + 1), is_prime_(new bool[max + 1]) {
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];
}
virtual int GetNextPrime(int p) const {
int GetNextPrime(int p) const override {
for (int n = p + 1; n < is_prime_size_; n++) {
if (is_prime_[n]) return n;
}

View File

@@ -74,12 +74,12 @@ int Water::allocated_ = 0;
class LeakChecker : public EmptyTestEventListener {
private:
// Called before a test starts.
virtual void OnTestStart(const TestInfo& /* test_info */) {
void OnTestStart(const TestInfo& /* test_info */) override {
initially_allocated_ = Water::allocated();
}
// 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_;
// You can generate a failure in any event handler except

View File

@@ -71,7 +71,7 @@ class QueueTestSmpl3 : public testing::Test {
// virtual void SetUp() will be called before each test is run. You
// should define it if you need to initialize the variables.
// Otherwise, this can be skipped.
virtual void SetUp() {
void SetUp() override {
q1_.Enqueue(1);
q2_.Enqueue(2);
q2_.Enqueue(3);

View File

@@ -63,11 +63,11 @@ class QuickTest : public testing::Test {
protected:
// Remember that SetUp() is run immediately before a test starts.
// 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
// check if the test was too slow.
virtual void TearDown() {
void TearDown() override {
// Gets the time when the test finishes
const time_t end_time = time(nullptr);
@@ -140,7 +140,7 @@ TEST_F(IntegerFunctionTest, IsPrime) {
// stuff inside the body of the test fixture, as usual.
class QueueTest : public QuickTest {
protected:
virtual void SetUp() {
void SetUp() override {
// First, we need to set up the super fixture (QuickTest).
QuickTest::SetUp();

View File

@@ -61,7 +61,7 @@ class PrimeTableTest : public testing::Test {
// implemented by T.
PrimeTableTest() : table_(CreatePrimeTable<T>()) {}
virtual ~PrimeTableTest() { delete table_; }
~PrimeTableTest() override { delete table_; }
// Note that we test an implementation via the base interface
// instead of the actual implementation class. This is important

View File

@@ -65,9 +65,9 @@ PrimeTable* CreatePreCalculatedPrimeTable() {
// create and store an instance of PrimeTable.
class PrimeTableTestSmpl7 : public TestWithParam<CreatePrimeTableFunc*> {
public:
virtual ~PrimeTableTestSmpl7() { delete table_; }
virtual void SetUp() { table_ = (*GetParam())(); }
virtual void TearDown() {
~PrimeTableTestSmpl7() override { delete table_; }
void SetUp() override { table_ = (*GetParam())(); }
void TearDown() override {
delete table_;
table_ = nullptr;
}

View File

@@ -53,19 +53,19 @@ class HybridPrimeTable : public PrimeTable {
? nullptr
: new PreCalculatedPrimeTable(max_precalculated)),
max_precalculated_(max_precalculated) {}
virtual ~HybridPrimeTable() {
~HybridPrimeTable() override {
delete on_the_fly_impl_;
delete precalc_impl_;
}
virtual bool IsPrime(int n) const {
bool IsPrime(int n) const override {
if (precalc_impl_ != nullptr && n < max_precalculated_)
return precalc_impl_->IsPrime(n);
else
return on_the_fly_impl_->IsPrime(n);
}
virtual int GetNextPrime(int p) const {
int GetNextPrime(int p) const override {
int next_prime = -1;
if (precalc_impl_ != nullptr && p < max_precalculated_)
next_prime = precalc_impl_->GetNextPrime(p);
@@ -91,13 +91,13 @@ using ::testing::Combine;
// HybridPrimeTable instance.
class PrimeTableTest : public TestWithParam< ::std::tuple<bool, int> > {
protected:
virtual void SetUp() {
void SetUp() override {
bool force_on_the_fly;
int max_precalculated;
std::tie(force_on_the_fly, max_precalculated) = GetParam();
table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated);
}
virtual void TearDown() {
void TearDown() override {
delete table_;
table_ = nullptr;
}

View File

@@ -49,16 +49,16 @@ namespace {
class TersePrinter : public EmptyTestEventListener {
private:
// 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.
virtual void OnTestProgramEnd(const UnitTest& unit_test) {
void OnTestProgramEnd(const UnitTest& unit_test) override {
fprintf(stdout, "TEST %s\n", unit_test.Passed() ? "PASSED" : "FAILED");
fflush(stdout);
}
// Called before a test starts.
virtual void OnTestStart(const TestInfo& test_info) {
void OnTestStart(const TestInfo& test_info) override {
fprintf(stdout,
"*** Test %s.%s starting.\n",
test_info.test_case_name(),
@@ -67,7 +67,7 @@ class TersePrinter : public EmptyTestEventListener {
}
// 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,
"%s in %s:%d\n%s\n",
test_part_result.failed() ? "*** Failure" : "Success",
@@ -78,7 +78,7 @@ class TersePrinter : public EmptyTestEventListener {
}
// Called after a test ends.
virtual void OnTestEnd(const TestInfo& test_info) {
void OnTestEnd(const TestInfo& test_info) override {
fprintf(stdout,
"*** Test %s.%s ending.\n",
test_info.test_case_name(),