mirror of
https://github.com/google/googletest.git
synced 2025-01-14 08:27:56 +08:00
Internal Code Change
PiperOrigin-RevId: 518810140 Change-Id: Id3f9471f827894761080bc9199b0a092dc829b5f
This commit is contained in:
parent
5fce13091d
commit
6f01e3dc12
@ -44,7 +44,7 @@ namespace testing {
|
|||||||
// Used in EXPECT_TRUE/FALSE(assertion_result).
|
// Used in EXPECT_TRUE/FALSE(assertion_result).
|
||||||
AssertionResult::AssertionResult(const AssertionResult& other)
|
AssertionResult::AssertionResult(const AssertionResult& other)
|
||||||
: success_(other.success_),
|
: success_(other.success_),
|
||||||
message_(other.message_.get() != nullptr
|
message_(other.message_ != nullptr
|
||||||
? new ::std::string(*other.message_)
|
? new ::std::string(*other.message_)
|
||||||
: static_cast< ::std::string*>(nullptr)) {}
|
: static_cast< ::std::string*>(nullptr)) {}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ void AssertionResult::swap(AssertionResult& other) {
|
|||||||
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
|
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
|
||||||
AssertionResult AssertionResult::operator!() const {
|
AssertionResult AssertionResult::operator!() const {
|
||||||
AssertionResult negation(!success_);
|
AssertionResult negation(!success_);
|
||||||
if (message_.get() != nullptr) negation << *message_;
|
if (message_ != nullptr) negation << *message_;
|
||||||
return negation;
|
return negation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1524,7 +1524,7 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
|
|||||||
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
|
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
|
||||||
// the flag is specified; otherwise returns NULL.
|
// the flag is specified; otherwise returns NULL.
|
||||||
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
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
|
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
|
||||||
// can use it here.
|
// can use it here.
|
||||||
|
@ -37,8 +37,6 @@
|
|||||||
|
|
||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
using internal::GetUnitTestImpl;
|
|
||||||
|
|
||||||
// Gets the summary of the failure message by omitting the stack trace
|
// Gets the summary of the failure message by omitting the stack trace
|
||||||
// in it.
|
// in it.
|
||||||
std::string TestPartResult::ExtractSummary(const char* message) {
|
std::string TestPartResult::ExtractSummary(const char* message) {
|
||||||
|
@ -90,7 +90,7 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string& errors_str = errors.GetString();
|
const std::string& errors_str = errors.GetString();
|
||||||
if (errors_str != "") {
|
if (!errors_str.empty()) {
|
||||||
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
|
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
|
||||||
errors_str.c_str());
|
errors_str.c_str());
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
@ -408,7 +408,7 @@ uint32_t Random::Generate(uint32_t range) {
|
|||||||
// GTestIsInitialized() returns true if and only if the user has initialized
|
// GTestIsInitialized() returns true if and only if the user has initialized
|
||||||
// Google Test. Useful for catching the user mistake of not initializing
|
// Google Test. Useful for catching the user mistake of not initializing
|
||||||
// Google Test before calling RUN_ALL_TESTS().
|
// 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
|
// Iterates over a vector of TestSuites, keeping a running sum of the
|
||||||
// results of calling a given int-returning method on each.
|
// results of calling a given int-returning method on each.
|
||||||
@ -5306,7 +5306,7 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
|
|||||||
msg << message;
|
msg << message;
|
||||||
|
|
||||||
internal::MutexLock lock(&mutex_);
|
internal::MutexLock lock(&mutex_);
|
||||||
if (impl_->gtest_trace_stack().size() > 0) {
|
if (!impl_->gtest_trace_stack().empty()) {
|
||||||
msg << "\n" << GTEST_NAME_ << " trace:";
|
msg << "\n" << GTEST_NAME_ << " trace:";
|
||||||
|
|
||||||
for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
|
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
|
// Disables event forwarding if the control is currently in a death test
|
||||||
// subprocess. Must not be called before InitGoogleTest.
|
// subprocess. Must not be called before InitGoogleTest.
|
||||||
void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
|
void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
|
||||||
if (internal_run_death_test_flag_.get() != nullptr)
|
if (internal_run_death_test_flag_ != nullptr)
|
||||||
listeners()->SuppressEventForwarding();
|
listeners()->SuppressEventForwarding();
|
||||||
}
|
}
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
@ -5622,7 +5622,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
|
|||||||
} else if (output_format == "json") {
|
} else if (output_format == "json") {
|
||||||
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
|
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
|
||||||
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
|
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
|
||||||
} else if (output_format != "") {
|
} else if (!output_format.empty()) {
|
||||||
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
|
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
|
||||||
<< output_format << "\" ignored.";
|
<< output_format << "\" ignored.";
|
||||||
}
|
}
|
||||||
@ -5804,8 +5804,7 @@ bool UnitTestImpl::RunAllTests() {
|
|||||||
bool in_subprocess_for_death_test = false;
|
bool in_subprocess_for_death_test = false;
|
||||||
|
|
||||||
#ifdef GTEST_HAS_DEATH_TEST
|
#ifdef GTEST_HAS_DEATH_TEST
|
||||||
in_subprocess_for_death_test =
|
in_subprocess_for_death_test = (internal_run_death_test_flag_ != nullptr);
|
||||||
(internal_run_death_test_flag_.get() != nullptr);
|
|
||||||
#if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
|
#if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
|
||||||
if (in_subprocess_for_death_test) {
|
if (in_subprocess_for_death_test) {
|
||||||
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
|
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user