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
......@@ -364,15 +364,13 @@ class NonFatalFailureInFixtureConstructorTest : public testing::Test {
ADD_FAILURE() << "Expected failure #1, in the test fixture c'tor.";
}
~NonFatalFailureInFixtureConstructorTest() {
~NonFatalFailureInFixtureConstructorTest() override {
ADD_FAILURE() << "Expected failure #5, in the test fixture d'tor.";
}
virtual void SetUp() {
ADD_FAILURE() << "Expected failure #2, in SetUp().";
}
void SetUp() override { ADD_FAILURE() << "Expected failure #2, in SetUp()."; }
virtual void TearDown() {
void TearDown() override {
ADD_FAILURE() << "Expected failure #4, in TearDown.";
}
};
......@@ -389,17 +387,17 @@ class FatalFailureInFixtureConstructorTest : public testing::Test {
Init();
}
~FatalFailureInFixtureConstructorTest() {
~FatalFailureInFixtureConstructorTest() override {
ADD_FAILURE() << "Expected failure #2, in the test fixture d'tor.";
}
virtual void SetUp() {
void SetUp() override {
ADD_FAILURE() << "UNEXPECTED failure in SetUp(). "
<< "We should never get here, as the test fixture c'tor "
<< "had a fatal failure.";
}
virtual void TearDown() {
void TearDown() override {
ADD_FAILURE() << "UNEXPECTED failure in TearDown(). "
<< "We should never get here, as the test fixture c'tor "
<< "had a fatal failure.";
......@@ -420,18 +418,15 @@ TEST_F(FatalFailureInFixtureConstructorTest, FailureInConstructor) {
// Tests non-fatal failures in SetUp().
class NonFatalFailureInSetUpTest : public testing::Test {
protected:
virtual ~NonFatalFailureInSetUpTest() {
Deinit();
}
~NonFatalFailureInSetUpTest() override { Deinit(); }
virtual void SetUp() {
void SetUp() override {
printf("(expecting 4 failures)\n");
ADD_FAILURE() << "Expected failure #1, in SetUp().";
}
virtual void TearDown() {
FAIL() << "Expected failure #3, in TearDown().";
}
void TearDown() override { FAIL() << "Expected failure #3, in TearDown()."; }
private:
void Deinit() {
FAIL() << "Expected failure #4, in the test fixture d'tor.";
......@@ -445,18 +440,15 @@ TEST_F(NonFatalFailureInSetUpTest, FailureInSetUp) {
// Tests fatal failures in SetUp().
class FatalFailureInSetUpTest : public testing::Test {
protected:
virtual ~FatalFailureInSetUpTest() {
Deinit();
}
~FatalFailureInSetUpTest() override { Deinit(); }
virtual void SetUp() {
void SetUp() override {
printf("(expecting 3 failures)\n");
FAIL() << "Expected failure #1, in SetUp().";
}
virtual void TearDown() {
FAIL() << "Expected failure #2, in TearDown().";
}
void TearDown() override { FAIL() << "Expected failure #2, in TearDown()."; }
private:
void Deinit() {
FAIL() << "Expected failure #3, in the test fixture d'tor.";
......@@ -508,7 +500,7 @@ static void ThreadRoutine(SpawnThreadNotifications* notifications) {
class DeathTestAndMultiThreadsTest : public testing::Test {
protected:
// Starts a thread and waits for it to begin.
virtual void SetUp() {
void SetUp() override {
thread_.reset(new ThreadWithParam<SpawnThreadNotifications*>(
&ThreadRoutine, &notifications_, nullptr));
notifications_.spawn_thread_started.WaitForNotification();
......@@ -518,7 +510,7 @@ class DeathTestAndMultiThreadsTest : public testing::Test {
// a manager thread might still be left running that will interfere
// with later death tests. This is unfortunate, but this class
// cleans up after itself as best it can.
virtual void TearDown() {
void TearDown() override {
notifications_.spawn_thread_ok_to_terminate.Notify();
}
......@@ -1037,11 +1029,9 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailureOnAllThreads) {
class FooEnvironment : public testing::Environment {
public:
virtual void SetUp() {
printf("%s", "FooEnvironment::SetUp() called.\n");
}
void SetUp() override { printf("%s", "FooEnvironment::SetUp() called.\n"); }
virtual void TearDown() {
void TearDown() override {
printf("%s", "FooEnvironment::TearDown() called.\n");
FAIL() << "Expected fatal failure.";
}
......@@ -1049,11 +1039,9 @@ class FooEnvironment : public testing::Environment {
class BarEnvironment : public testing::Environment {
public:
virtual void SetUp() {
printf("%s", "BarEnvironment::SetUp() called.\n");
}
void SetUp() override { printf("%s", "BarEnvironment::SetUp() called.\n"); }
virtual void TearDown() {
void TearDown() override {
printf("%s", "BarEnvironment::TearDown() called.\n");
ADD_FAILURE() << "Expected non-fatal failure.";
}
......
......@@ -562,7 +562,7 @@ class TestGenerationEnvironment : public ::testing::Environment {
void TearDownExecuted() { tear_down_count_++; }
void TestBodyExecuted() { test_body_count_++; }
virtual void TearDown() {
void TearDown() override {
// If all MultipleTestGenerationTest tests have been de-selected
// by the filter flag, the following checks make no sense.
bool perform_check = false;
......@@ -619,11 +619,11 @@ class TestGenerationTest : public TestWithParam<int> {
Environment::Instance()->FixtureConstructorExecuted();
current_parameter_ = GetParam();
}
virtual void SetUp() {
void SetUp() override {
Environment::Instance()->SetUpExecuted();
EXPECT_EQ(current_parameter_, GetParam());
}
virtual void TearDown() {
void TearDown() override {
Environment::Instance()->TearDownExecuted();
EXPECT_EQ(current_parameter_, GetParam());
}
......
......@@ -76,12 +76,12 @@ TEST(DISABLED_D, DISABLED_B) {}
// iteration with a "----" marker.
class TestNamePrinter : public EmptyTestEventListener {
public:
virtual void OnTestIterationStart(const UnitTest& /* unit_test */,
int /* iteration */) {
void OnTestIterationStart(const UnitTest& /* unit_test */,
int /* iteration */) override {
printf("----\n");
}
virtual void OnTestStart(const TestInfo& test_info) {
void OnTestStart(const TestInfo& test_info) override {
printf("%s.%s\n", test_info.test_case_name(), test_info.name());
}
};
......
......@@ -68,14 +68,14 @@ class CommonTest : public Test {
CommonTest() : value_(1) {}
virtual ~CommonTest() { EXPECT_EQ(3, value_); }
~CommonTest() override { EXPECT_EQ(3, value_); }
virtual void SetUp() {
void SetUp() override {
EXPECT_EQ(1, value_);
value_++;
}
virtual void TearDown() {
void TearDown() override {
EXPECT_EQ(2, value_);
value_++;
}
......@@ -215,7 +215,7 @@ using testing::internal::TypedTestCasePState;
class TypedTestCasePStateTest : public Test {
protected:
virtual void SetUp() {
void SetUp() override {
state_.AddTestName("foo.cc", 0, "FooTest", "A");
state_.AddTestName("foo.cc", 0, "FooTest", "B");
state_.AddTestName("foo.cc", 0, "FooTest", "C");
......
......@@ -232,7 +232,7 @@ TEST(DISABLED_Test, Dummy2) {}
class FinalSuccessChecker : public Environment {
protected:
virtual void TearDown() {
void TearDown() override {
UnitTest* unit_test = UnitTest::GetInstance();
EXPECT_EQ(1 + kTypedTestCases, unit_test->successful_test_case_count());
......
......@@ -53,7 +53,7 @@ class MyEnvironment : public testing::Environment {
// Depending on the value of failure_in_set_up_, SetUp() will
// generate a non-fatal failure, generate a fatal failure, or
// succeed.
virtual void SetUp() {
void SetUp() override {
set_up_was_run_ = true;
switch (failure_in_set_up_) {
......@@ -69,7 +69,7 @@ class MyEnvironment : public testing::Environment {
}
// Generates a non-fatal failure.
virtual void TearDown() {
void TearDown() override {
tear_down_was_run_ = true;
ADD_FAILURE() << "Expected non-fatal failure in global tear-down.";
}
......
......@@ -122,13 +122,13 @@ struct PredFormatFunctor1 {
class Predicate1Test : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
expected_to_finish_ = true;
finished_ = false;
n1_ = 0;
}
virtual void TearDown() {
void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ(1, n1_) <<
......@@ -514,13 +514,13 @@ struct PredFormatFunctor2 {
class Predicate2Test : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
expected_to_finish_ = true;
finished_ = false;
n1_ = n2_ = 0;
}
virtual void TearDown() {
void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ(1, n1_) <<
......@@ -948,13 +948,13 @@ struct PredFormatFunctor3 {
class Predicate3Test : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
expected_to_finish_ = true;
finished_ = false;
n1_ = n2_ = n3_ = 0;
}
virtual void TearDown() {
void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ(1, n1_) <<
......@@ -1424,13 +1424,13 @@ struct PredFormatFunctor4 {
class Predicate4Test : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
expected_to_finish_ = true;
finished_ = false;
n1_ = n2_ = n3_ = n4_ = 0;
}
virtual void TearDown() {
void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ(1, n1_) <<
......@@ -1942,13 +1942,13 @@ struct PredFormatFunctor5 {
class Predicate5Test : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
expected_to_finish_ = true;
finished_ = false;
n1_ = n2_ = n3_ = n4_ = n5_ = 0;
}
virtual void TearDown() {
void TearDown() override {
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ(1, n1_) <<
......
......@@ -74,8 +74,8 @@ int g_environment_tear_down_count = 0;
class MyEnvironment : public testing::Environment {
public:
MyEnvironment() {}
virtual void SetUp() { g_environment_set_up_count++; }
virtual void TearDown() { g_environment_tear_down_count++; }
void SetUp() override { g_environment_set_up_count++; }
void TearDown() override { g_environment_tear_down_count++; }
};
// A test that should fail.
......
......@@ -78,7 +78,7 @@ class StreamingListenerTest : public Test {
class FakeSocketWriter : public StreamingListener::AbstractSocketWriter {
public:
// Sends a string to the socket.
virtual void Send(const std::string& message) { output_ += message; }
void Send(const std::string& message) override { output_ += message; }
std::string output_;
};
......@@ -438,7 +438,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
static const TimeInMillis kMillisPerSec = 1000;
private:
virtual void SetUp() {
void SetUp() override {
saved_tz_ = nullptr;
GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */)
......@@ -452,7 +452,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
SetTimeZone("UTC+00");
}
virtual void TearDown() {
void TearDown() override {
SetTimeZone(saved_tz_);
free(const_cast<char*>(saved_tz_));
saved_tz_ = nullptr;
......@@ -1361,7 +1361,7 @@ class TestResultTest : public Test {
// ... and 3 TestResult objects.
TestResult * r0, * r1, * r2;
virtual void SetUp() {
void SetUp() override {
// pr1 is for success.
pr1 = new TestPartResult(TestPartResult::kSuccess,
"foo/bar.cc",
......@@ -1398,7 +1398,7 @@ class TestResultTest : public Test {
results2->push_back(*pr2);
}
virtual void TearDown() {
void TearDown() override {
delete pr1;
delete pr2;
......@@ -1826,12 +1826,12 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereIsOneShard) {
class ShouldShardTest : public testing::Test {
protected:
virtual void SetUp() {
void SetUp() override {
index_var_ = GTEST_FLAG_PREFIX_UPPER_ "INDEX";
total_var_ = GTEST_FLAG_PREFIX_UPPER_ "TOTAL";
}
virtual void TearDown() {
void TearDown() override {
SetEnv(index_var_, "");
SetEnv(total_var_, "");
}
......@@ -2094,7 +2094,7 @@ TEST_F(UnitTestRecordPropertyTest,
class UnitTestRecordPropertyTestEnvironment : public Environment {
public:
virtual void TearDown() {
void TearDown() override {
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
"tests");
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
......@@ -2707,7 +2707,7 @@ class FloatingPointTest : public Test {
typedef typename testing::internal::FloatingPoint<RawType> Floating;
typedef typename Floating::Bits Bits;
virtual void SetUp() {
void SetUp() override {
const size_t max_ulps = Floating::kMaxUlps;
// The bits that represent 0.0.
......@@ -5061,7 +5061,7 @@ class TestLifeCycleTest : public Test {
// Destructor. Decrements the number of test objects that uses this
// fixture.
~TestLifeCycleTest() { count_--; }
~TestLifeCycleTest() override { count_--; }
// Returns the number of live test objects that uses this fixture.
int count() const { return count_; }
......@@ -5448,7 +5448,7 @@ class SetUpTestCaseTest : public Test {
}
// This will be called before each test in this test case.
virtual void SetUp() {
void SetUp() override {
// SetUpTestCase() should be called only once, so counter_ should
// always be 1.
EXPECT_EQ(1, counter_);
......@@ -5628,7 +5628,7 @@ struct Flags {
class ParseFlagsTest : public Test {
protected:
// Clears the flags before each test.
virtual void SetUp() {
void SetUp() override {
GTEST_FLAG(also_run_disabled_tests) = false;
GTEST_FLAG(break_on_failure) = false;
GTEST_FLAG(catch_exceptions) = false;
......@@ -6316,12 +6316,8 @@ TEST(NestedTestingNamespaceTest, Failure) {
// successfully.
class ProtectedFixtureMethodsTest : public Test {
protected:
virtual void SetUp() {
Test::SetUp();
}
virtual void TearDown() {
Test::TearDown();
}
void SetUp() override { Test::SetUp(); }
void TearDown() override { Test::TearDown(); }
};
// StreamingAssertionsTest tests the streaming versions of a representative
......@@ -6699,13 +6695,13 @@ class TestListener : public EmptyTestEventListener {
: on_start_counter_(on_start_counter),
is_destroyed_(is_destroyed) {}
virtual ~TestListener() {
~TestListener() override {
if (is_destroyed_)
*is_destroyed_ = true;
}
protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {
void OnTestProgramStart(const UnitTest& /*unit_test*/) override {
if (on_start_counter_ != nullptr) (*on_start_counter_)++;
}
......@@ -6774,21 +6770,21 @@ class SequenceTestingListener : public EmptyTestEventListener {
: vector_(vector), id_(id) {}
protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {
void OnTestProgramStart(const UnitTest& /*unit_test*/) override {
vector_->push_back(GetEventDescription("OnTestProgramStart"));
}
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {
void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {
vector_->push_back(GetEventDescription("OnTestProgramEnd"));
}
virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
int /*iteration*/) {
void OnTestIterationStart(const UnitTest& /*unit_test*/,
int /*iteration*/) override {
vector_->push_back(GetEventDescription("OnTestIterationStart"));
}
virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int /*iteration*/) {
void OnTestIterationEnd(const UnitTest& /*unit_test*/,
int /*iteration*/) override {
vector_->push_back(GetEventDescription("OnTestIterationEnd"));
}
......
......@@ -34,12 +34,8 @@
class PropertyOne : public testing::Test {
protected:
virtual void SetUp() {
RecordProperty("SetUpProp", 1);
}
virtual void TearDown() {
RecordProperty("TearDownProp", 1);
}
void SetUp() override { RecordProperty("SetUpProp", 1); }
void TearDown() override { RecordProperty("TearDownProp", 1); }
};
TEST_F(PropertyOne, TestSomeProperties) {
......
......@@ -34,12 +34,8 @@
class PropertyTwo : public testing::Test {
protected:
virtual void SetUp() {
RecordProperty("SetUpProp", 2);
}
virtual void TearDown() {
RecordProperty("TearDownProp", 2);
}
void SetUp() override { RecordProperty("SetUpProp", 2); }
void TearDown() override { RecordProperty("TearDownProp", 2); }
};
TEST_F(PropertyTwo, TestSomeProperties) {
......
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