summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2023-03-23 03:07:47 -0700
committerCopybara-Service <copybara-worker@google.com>2023-03-23 03:08:22 -0700
commit6f01e3dc125e82f2d3d87839a8be52f610c732ea (patch)
treefb29b3bd62b7b9af04d21920fbac6cfe97f76882
parent5fce13091d223069436ad7a5aad53f026b0f2041 (diff)
downloadgoogletest-git-6f01e3dc125e82f2d3d87839a8be52f610c732ea.tar.gz
Internal Code Change
PiperOrigin-RevId: 518810140 Change-Id: Id3f9471f827894761080bc9199b0a092dc829b5f
-rw-r--r--googletest/src/gtest-assertion-result.cc4
-rw-r--r--googletest/src/gtest-death-test.cc2
-rw-r--r--googletest/src/gtest-test-part.cc2
-rw-r--r--googletest/src/gtest-typed-test.cc2
-rw-r--r--googletest/src/gtest.cc11
5 files changed, 9 insertions, 12 deletions
diff --git a/googletest/src/gtest-assertion-result.cc b/googletest/src/gtest-assertion-result.cc
index f1c0b10d..39989216 100644
--- a/googletest/src/gtest-assertion-result.cc
+++ b/googletest/src/gtest-assertion-result.cc
@@ -44,7 +44,7 @@ namespace testing {
// Used in EXPECT_TRUE/FALSE(assertion_result).
AssertionResult::AssertionResult(const AssertionResult& other)
: success_(other.success_),
- message_(other.message_.get() != nullptr
+ message_(other.message_ != nullptr
? new ::std::string(*other.message_)
: static_cast< ::std::string*>(nullptr)) {}
@@ -58,7 +58,7 @@ void AssertionResult::swap(AssertionResult& other) {
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
AssertionResult AssertionResult::operator!() const {
AssertionResult negation(!success_);
- if (message_.get() != nullptr) negation << *message_;
+ if (message_ != nullptr) negation << *message_;
return negation;
}
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index df04111e..0b87ba5b 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -1524,7 +1524,7 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
// the flag is specified; otherwise returns NULL.
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
- if (GTEST_FLAG_GET(internal_run_death_test) == "") return nullptr;
+ if (GTEST_FLAG_GET(internal_run_death_test).empty()) return nullptr;
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
// can use it here.
diff --git a/googletest/src/gtest-test-part.cc b/googletest/src/gtest-test-part.cc
index eb7c8d1c..df677e6f 100644
--- a/googletest/src/gtest-test-part.cc
+++ b/googletest/src/gtest-test-part.cc
@@ -37,8 +37,6 @@
namespace testing {
-using internal::GetUnitTestImpl;
-
// Gets the summary of the failure message by omitting the stack trace
// in it.
std::string TestPartResult::ExtractSummary(const char* message) {
diff --git a/googletest/src/gtest-typed-test.cc b/googletest/src/gtest-typed-test.cc
index a2828b83..9941306f 100644
--- a/googletest/src/gtest-typed-test.cc
+++ b/googletest/src/gtest-typed-test.cc
@@ -90,7 +90,7 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
}
const std::string& errors_str = errors.GetString();
- if (errors_str != "") {
+ if (!errors_str.empty()) {
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
errors_str.c_str());
fflush(stderr);
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 897c0cd9..7832492d 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -408,7 +408,7 @@ uint32_t Random::Generate(uint32_t range) {
// GTestIsInitialized() returns true if and only if the user has initialized
// Google Test. Useful for catching the user mistake of not initializing
// Google Test before calling RUN_ALL_TESTS().
-static bool GTestIsInitialized() { return GetArgvs().size() > 0; }
+static bool GTestIsInitialized() { return !GetArgvs().empty(); }
// Iterates over a vector of TestSuites, keeping a running sum of the
// results of calling a given int-returning method on each.
@@ -5306,7 +5306,7 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
msg << message;
internal::MutexLock lock(&mutex_);
- if (impl_->gtest_trace_stack().size() > 0) {
+ if (!impl_->gtest_trace_stack().empty()) {
msg << "\n" << GTEST_NAME_ << " trace:";
for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
@@ -5606,7 +5606,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
// Disables event forwarding if the control is currently in a death test
// subprocess. Must not be called before InitGoogleTest.
void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
- if (internal_run_death_test_flag_.get() != nullptr)
+ if (internal_run_death_test_flag_ != nullptr)
listeners()->SuppressEventForwarding();
}
#endif // GTEST_HAS_DEATH_TEST
@@ -5622,7 +5622,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
} else if (output_format == "json") {
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
- } else if (output_format != "") {
+ } else if (!output_format.empty()) {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format << "\" ignored.";
}
@@ -5804,8 +5804,7 @@ bool UnitTestImpl::RunAllTests() {
bool in_subprocess_for_death_test = false;
#ifdef GTEST_HAS_DEATH_TEST
- in_subprocess_for_death_test =
- (internal_run_death_test_flag_.get() != nullptr);
+ in_subprocess_for_death_test = (internal_run_death_test_flag_ != nullptr);
#if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
if (in_subprocess_for_death_test) {
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();