summaryrefslogtreecommitdiffstats
path: root/googletest/samples
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-12-03 16:30:02 (GMT)
committerGennadiy Civil <misterg@google.com>2018-12-03 17:54:11 (GMT)
commit26743363be8f579ee7d637e5b15cbf73e9e18a4a (patch)
treefb89238693dad174c6ddaf57f04bae3c8f41d7fb /googletest/samples
parenta42cdf2abdc0ab7ddfbafc098cafdd6152ae1b70 (diff)
downloadgoogletest-26743363be8f579ee7d637e5b15cbf73e9e18a4a.zip
googletest-26743363be8f579ee7d637e5b15cbf73e9e18a4a.tar.gz
googletest-26743363be8f579ee7d637e5b15cbf73e9e18a4a.tar.bz2
Googletest export
Applied fixes for ClangTidy modernize-use-override and modernize-use-using. PiperOrigin-RevId: 223800219
Diffstat (limited to 'googletest/samples')
-rw-r--r--googletest/samples/prime_tables.h10
-rw-r--r--googletest/samples/sample10_unittest.cc4
-rw-r--r--googletest/samples/sample3_unittest.cc2
-rw-r--r--googletest/samples/sample5_unittest.cc6
-rw-r--r--googletest/samples/sample6_unittest.cc2
-rw-r--r--googletest/samples/sample7_unittest.cc6
-rw-r--r--googletest/samples/sample8_unittest.cc10
-rw-r--r--googletest/samples/sample9_unittest.cc10
8 files changed, 25 insertions, 25 deletions
diff --git a/googletest/samples/prime_tables.h b/googletest/samples/prime_tables.h
index 523c50b..119545a 100644
--- a/googletest/samples/prime_tables.h
+++ b/googletest/samples/prime_tables.h
@@ -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;
}
diff --git a/googletest/samples/sample10_unittest.cc b/googletest/samples/sample10_unittest.cc
index 3da2158..36cdac2 100644
--- a/googletest/samples/sample10_unittest.cc
+++ b/googletest/samples/sample10_unittest.cc
@@ -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
diff --git a/googletest/samples/sample3_unittest.cc b/googletest/samples/sample3_unittest.cc
index 97ce55d..b19416d 100644
--- a/googletest/samples/sample3_unittest.cc
+++ b/googletest/samples/sample3_unittest.cc
@@ -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);
diff --git a/googletest/samples/sample5_unittest.cc b/googletest/samples/sample5_unittest.cc
index e71b903..0a21dd2 100644
--- a/googletest/samples/sample5_unittest.cc
+++ b/googletest/samples/sample5_unittest.cc
@@ -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();
diff --git a/googletest/samples/sample6_unittest.cc b/googletest/samples/sample6_unittest.cc
index ddf2f1c..d234429 100644
--- a/googletest/samples/sample6_unittest.cc
+++ b/googletest/samples/sample6_unittest.cc
@@ -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
diff --git a/googletest/samples/sample7_unittest.cc b/googletest/samples/sample7_unittest.cc
index e1e09b0..7e6e35e 100644
--- a/googletest/samples/sample7_unittest.cc
+++ b/googletest/samples/sample7_unittest.cc
@@ -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;
}
diff --git a/googletest/samples/sample8_unittest.cc b/googletest/samples/sample8_unittest.cc
index a3eacc7..39163a8 100644
--- a/googletest/samples/sample8_unittest.cc
+++ b/googletest/samples/sample8_unittest.cc
@@ -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;
}
diff --git a/googletest/samples/sample9_unittest.cc b/googletest/samples/sample9_unittest.cc
index 53f9af5..c0d8ff2 100644
--- a/googletest/samples/sample9_unittest.cc
+++ b/googletest/samples/sample9_unittest.cc
@@ -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(),