proxygen
testing::TestResult Class Reference

#include <gtest.h>

Public Member Functions

 TestResult ()
 
 ~TestResult ()
 
int total_part_count () const
 
int test_property_count () const
 
bool Passed () const
 
bool Failed () const
 
bool HasFatalFailure () const
 
bool HasNonfatalFailure () const
 
TimeInMillis elapsed_time () const
 
const TestPartResultGetTestPartResult (int i) const
 
const TestPropertyGetTestProperty (int i) const
 
 TestResult ()
 
 ~TestResult ()
 
int total_part_count () const
 
int test_property_count () const
 
bool Passed () const
 
bool Failed () const
 
bool HasFatalFailure () const
 
bool HasNonfatalFailure () const
 
TimeInMillis elapsed_time () const
 
const TestPartResultGetTestPartResult (int i) const
 
const TestPropertyGetTestProperty (int i) const
 
 TestResult ()
 
 ~TestResult ()
 
int total_part_count () const
 
int test_property_count () const
 
bool Passed () const
 
bool Failed () const
 
bool HasFatalFailure () const
 
bool HasNonfatalFailure () const
 
TimeInMillis elapsed_time () const
 
const TestPartResultGetTestPartResult (int i) const
 
const TestPropertyGetTestProperty (int i) const
 

Private Member Functions

const std::vector< TestPartResult > & test_part_results () const
 
const std::vector< TestProperty > & test_properties () const
 
void set_elapsed_time (TimeInMillis elapsed)
 
void RecordProperty (const std::string &xml_element, const TestProperty &test_property)
 
void AddTestPartResult (const TestPartResult &test_part_result)
 
int death_test_count () const
 
int increment_death_test_count ()
 
void ClearTestPartResults ()
 
void Clear ()
 
 GTEST_DISALLOW_COPY_AND_ASSIGN_ (TestResult)
 
const std::vector< TestPartResult > & test_part_results () const
 
const std::vector< TestProperty > & test_properties () const
 
void set_elapsed_time (TimeInMillis elapsed)
 
void RecordProperty (const std::string &xml_element, const TestProperty &test_property)
 
void AddTestPartResult (const TestPartResult &test_part_result)
 
int death_test_count () const
 
int increment_death_test_count ()
 
void ClearTestPartResults ()
 
void Clear ()
 
 GTEST_DISALLOW_COPY_AND_ASSIGN_ (TestResult)
 
const std::vector< TestPartResult > & test_part_results () const
 
const std::vector< TestProperty > & test_properties () const
 
void set_elapsed_time (TimeInMillis elapsed)
 
void RecordProperty (const std::string &xml_element, const TestProperty &test_property)
 
void AddTestPartResult (const TestPartResult &test_part_result)
 
int death_test_count () const
 
int increment_death_test_count ()
 
void ClearTestPartResults ()
 
void Clear ()
 
 GTEST_DISALLOW_COPY_AND_ASSIGN_ (TestResult)
 

Static Private Member Functions

static bool ValidateTestProperty (const std::string &xml_element, const TestProperty &test_property)
 
static bool ValidateTestProperty (const std::string &xml_element, const TestProperty &test_property)
 
static bool ValidateTestProperty (const std::string &xml_element, const TestProperty &test_property)
 

Private Attributes

internal::Mutex test_properites_mutex_
 
std::vector< TestPartResulttest_part_results_
 
std::vector< TestPropertytest_properties_
 
int death_test_count_
 
TimeInMillis elapsed_time_
 

Friends

class TestInfo
 
class TestCase
 
class UnitTest
 
class internal::DefaultGlobalTestPartResultReporter
 
class internal::ExecDeathTest
 
class internal::TestResultAccessor
 
class internal::UnitTestImpl
 
class internal::WindowsDeathTest
 

Detailed Description

Definition at line 523 of file gtest.h.

Constructor & Destructor Documentation

testing::TestResult::TestResult ( )

Definition at line 2017 of file gtest.cc.

2018  : death_test_count_(0),
2019  elapsed_time_(0) {
2020 }
int death_test_count_
Definition: gtest.h:625
TimeInMillis elapsed_time_
Definition: gtest.h:627
testing::TestResult::~TestResult ( )

Definition at line 2023 of file gtest.cc.

2023  {
2024 }
testing::TestResult::TestResult ( )
testing::TestResult::~TestResult ( )
testing::TestResult::TestResult ( )
testing::TestResult::~TestResult ( )

Member Function Documentation

void testing::TestResult::AddTestPartResult ( const TestPartResult test_part_result)
private

Definition at line 2050 of file gtest.cc.

References test_part_results_.

Referenced by testing::internal::DefaultGlobalTestPartResultReporter::ReportTestPartResult().

2050  {
2051  test_part_results_.push_back(test_part_result);
2052 }
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
void testing::TestResult::AddTestPartResult ( const TestPartResult test_part_result)
private
void testing::TestResult::AddTestPartResult ( const TestPartResult test_part_result)
private
void testing::TestResult::Clear ( )
private

Definition at line 2162 of file gtest.cc.

References death_test_count_, elapsed_time_, test_part_results_, and test_properties_.

Referenced by testing::TestCase::ClearResult(), testing::TestInfo::ClearTestResult(), and testing::FormatWordList().

2162  {
2163  test_part_results_.clear();
2164  test_properties_.clear();
2165  death_test_count_ = 0;
2166  elapsed_time_ = 0;
2167 }
int death_test_count_
Definition: gtest.h:625
std::vector< TestProperty > test_properties_
Definition: gtest.h:623
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
TimeInMillis elapsed_time_
Definition: gtest.h:627
void testing::TestResult::Clear ( )
private
void testing::TestResult::Clear ( )
private
void testing::TestResult::ClearTestPartResults ( )
private

Definition at line 2045 of file gtest.cc.

References test_part_results_.

Referenced by testing::internal::TestResultAccessor::ClearTestPartResults().

2045  {
2046  test_part_results_.clear();
2047 }
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
void testing::TestResult::ClearTestPartResults ( )
private
void testing::TestResult::ClearTestPartResults ( )
private
int testing::TestResult::death_test_count ( ) const
inlineprivate

Definition at line 605 of file gtest.h.

605 { return death_test_count_; }
int death_test_count_
Definition: gtest.h:625
int testing::TestResult::death_test_count ( ) const
inlineprivate

Definition at line 605 of file gtest.h.

605 { return death_test_count_; }
int death_test_count_
Definition: gtest.h:625
int testing::TestResult::death_test_count ( ) const
inlineprivate

Definition at line 605 of file gtest.h.

605 { return death_test_count_; }
int death_test_count_
Definition: gtest.h:625
TimeInMillis testing::TestResult::elapsed_time ( ) const
inline

Definition at line 551 of file gtest.h.

References i.

551 { return elapsed_time_; }
TimeInMillis elapsed_time_
Definition: gtest.h:627
TimeInMillis testing::TestResult::elapsed_time ( ) const
inline

Definition at line 551 of file gtest.h.

References i.

551 { return elapsed_time_; }
TimeInMillis elapsed_time_
Definition: gtest.h:627
bool testing::TestResult::Failed ( ) const
bool testing::TestResult::Failed ( ) const
bool testing::TestResult::Failed ( ) const

Definition at line 2170 of file gtest.cc.

References testing::TestPartResult::failed(), GetTestPartResult(), i, and total_part_count().

Referenced by testing::FormatWordList(), testing::internal::PrettyUnitTestResultPrinter::OnTestEnd(), testing::internal::PrettyUnitTestResultPrinter::OnTestProgramEnd(), and testing::TestCase::TestFailed().

2170  {
2171  for (int i = 0; i < total_part_count(); ++i) {
2172  if (GetTestPartResult(i).failed())
2173  return true;
2174  }
2175  return false;
2176 }
const TestPartResult & GetTestPartResult(int i) const
Definition: gtest.cc:2029
int total_part_count() const
Definition: gtest.cc:2200
const TestPartResult & testing::TestResult::GetTestPartResult ( int  i) const

Definition at line 2029 of file gtest.cc.

References testing::internal::posix::Abort(), test_part_results_, and total_part_count().

Referenced by Failed(), testing::internal::XmlUnitTestResultPrinter::OutputXmlTestInfo(), and testing::internal::PortableLocaltime().

2029  {
2030  if (i < 0 || i >= total_part_count())
2032  return test_part_results_.at(i);
2033 }
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
int total_part_count() const
Definition: gtest.cc:2200
const TestPartResult& testing::TestResult::GetTestPartResult ( int  i) const
const TestPartResult& testing::TestResult::GetTestPartResult ( int  i) const
const TestProperty& testing::TestResult::GetTestProperty ( int  i) const
const TestProperty & testing::TestResult::GetTestProperty ( int  i) const
const TestProperty& testing::TestResult::GetTestProperty ( int  i) const
testing::TestResult::GTEST_DISALLOW_COPY_AND_ASSIGN_ ( TestResult  )
private
testing::TestResult::GTEST_DISALLOW_COPY_AND_ASSIGN_ ( TestResult  )
private
testing::TestResult::GTEST_DISALLOW_COPY_AND_ASSIGN_ ( TestResult  )
private
bool testing::TestResult::HasFatalFailure ( ) const

Definition at line 2184 of file gtest.cc.

References testing::internal::CountIf(), test_part_results_, and testing::TestPartFatallyFailed().

Referenced by testing::Test::HasFatalFailure(), testing::TestPartFatallyFailed(), and testing::TestPartNonfatallyFailed().

2184  {
2186 }
static bool TestPartFatallyFailed(const TestPartResult &result)
Definition: gtest.cc:2179
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
int CountIf(const Container &c, Predicate predicate)
bool testing::TestResult::HasFatalFailure ( ) const
bool testing::TestResult::HasFatalFailure ( ) const
bool testing::TestResult::HasNonfatalFailure ( ) const
bool testing::TestResult::HasNonfatalFailure ( ) const
bool testing::TestResult::HasNonfatalFailure ( ) const

Definition at line 2194 of file gtest.cc.

References testing::internal::CountIf(), test_part_results_, and testing::TestPartNonfatallyFailed().

Referenced by testing::TestPartNonfatallyFailed().

2194  {
2196 }
static bool TestPartNonfatallyFailed(const TestPartResult &result)
Definition: gtest.cc:2189
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
int CountIf(const Container &c, Predicate predicate)
int testing::TestResult::increment_death_test_count ( )
inlineprivate

Definition at line 608 of file gtest.h.

608 { return ++death_test_count_; }
int death_test_count_
Definition: gtest.h:625
int testing::TestResult::increment_death_test_count ( )
inlineprivate

Definition at line 608 of file gtest.h.

References GTEST_API_, and GTEST_DISALLOW_COPY_AND_ASSIGN_.

608 { return ++death_test_count_; }
int death_test_count_
Definition: gtest.h:625
int testing::TestResult::increment_death_test_count ( )
inlineprivate

Definition at line 608 of file gtest.h.

References GTEST_API_, and GTEST_DISALLOW_COPY_AND_ASSIGN_.

608 { return ++death_test_count_; }
int death_test_count_
Definition: gtest.h:625
bool testing::TestResult::Passed ( ) const
inline

Definition at line 539 of file gtest.h.

539 { return !Failed(); }
bool Failed() const
Definition: gtest.cc:2170
bool testing::TestResult::Passed ( ) const
inline

Definition at line 539 of file gtest.h.

539 { return !Failed(); }
bool Failed() const
Definition: gtest.cc:2170
void testing::TestResult::RecordProperty ( const std::string xml_element,
const TestProperty test_property 
)
private
void testing::TestResult::RecordProperty ( const std::string xml_element,
const TestProperty test_property 
)
private

Definition at line 2057 of file gtest.cc.

References testing::TestProperty::key(), folly::detail::lock(), test_properites_mutex_, test_properties_, ValidateTestProperty(), and testing::TestProperty::value().

Referenced by testing::internal::UnitTestImpl::RecordProperty(), testing::internal::TestResultAccessor::RecordProperty(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

2058  {
2059  if (!ValidateTestProperty(xml_element, test_property)) {
2060  return;
2061  }
2063  const std::vector<TestProperty>::iterator property_with_matching_key =
2064  std::find_if(test_properties_.begin(), test_properties_.end(),
2065  internal::TestPropertyKeyIs(test_property.key()));
2066  if (property_with_matching_key == test_properties_.end()) {
2067  test_properties_.push_back(test_property);
2068  return;
2069  }
2070  property_with_matching_key->SetValue(test_property.value());
2071 }
internal::Mutex test_properites_mutex_
Definition: gtest.h:618
static bool ValidateTestProperty(const std::string &xml_element, const TestProperty &test_property)
Definition: gtest.cc:2155
std::vector< TestProperty > test_properties_
Definition: gtest.h:623
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
Definition: Synchronized.h:871
GTestMutexLock MutexLock
Definition: gtest-port.h:2159
void testing::TestResult::RecordProperty ( const std::string xml_element,
const TestProperty test_property 
)
private
void testing::TestResult::set_elapsed_time ( TimeInMillis  elapsed)
inlineprivate

Definition at line 584 of file gtest.h.

References string.

584 { elapsed_time_ = elapsed; }
TimeInMillis elapsed_time_
Definition: gtest.h:627
void testing::TestResult::set_elapsed_time ( TimeInMillis  elapsed)
inlineprivate

Definition at line 584 of file gtest.h.

References string.

584 { elapsed_time_ = elapsed; }
TimeInMillis elapsed_time_
Definition: gtest.h:627
void testing::TestResult::set_elapsed_time ( TimeInMillis  elapsed)
inlineprivate

Definition at line 584 of file gtest.h.

References string.

Referenced by testing::TestInfo::Run().

584 { elapsed_time_ = elapsed; }
TimeInMillis elapsed_time_
Definition: gtest.h:627
const std::vector<TestPartResult>& testing::TestResult::test_part_results ( ) const
inlineprivate

Definition at line 574 of file gtest.h.

Referenced by testing::internal::TestResultAccessor::test_part_results().

574  {
575  return test_part_results_;
576  }
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
const std::vector<TestPartResult>& testing::TestResult::test_part_results ( ) const
inlineprivate

Definition at line 574 of file gtest.h.

574  {
575  return test_part_results_;
576  }
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
const std::vector<TestPartResult>& testing::TestResult::test_part_results ( ) const
inlineprivate

Definition at line 574 of file gtest.h.

574  {
575  return test_part_results_;
576  }
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
const std::vector<TestProperty>& testing::TestResult::test_properties ( ) const
inlineprivate

Definition at line 579 of file gtest.h.

579  {
580  return test_properties_;
581  }
std::vector< TestProperty > test_properties_
Definition: gtest.h:623
const std::vector<TestProperty>& testing::TestResult::test_properties ( ) const
inlineprivate

Definition at line 579 of file gtest.h.

579  {
580  return test_properties_;
581  }
std::vector< TestProperty > test_properties_
Definition: gtest.h:623
const std::vector<TestProperty>& testing::TestResult::test_properties ( ) const
inlineprivate

Definition at line 579 of file gtest.h.

579  {
580  return test_properties_;
581  }
std::vector< TestProperty > test_properties_
Definition: gtest.h:623
int testing::TestResult::test_property_count ( ) const
int testing::TestResult::test_property_count ( ) const
int testing::TestResult::test_property_count ( ) const

Definition at line 2205 of file gtest.cc.

References test_properties_.

Referenced by GetTestProperty(), testing::internal::PortableLocaltime(), testing::TestPartNonfatallyFailed(), and testing::internal::XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes().

2205  {
2206  return static_cast<int>(test_properties_.size());
2207 }
std::vector< TestProperty > test_properties_
Definition: gtest.h:623
int testing::TestResult::total_part_count ( ) const
int testing::TestResult::total_part_count ( ) const
int testing::TestResult::total_part_count ( ) const

Definition at line 2200 of file gtest.cc.

References test_part_results_.

Referenced by Failed(), GetTestPartResult(), testing::internal::XmlUnitTestResultPrinter::OutputXmlTestInfo(), testing::internal::PortableLocaltime(), and testing::TestPartNonfatallyFailed().

2200  {
2201  return static_cast<int>(test_part_results_.size());
2202 }
std::vector< TestPartResult > test_part_results_
Definition: gtest.h:621
static bool testing::TestResult::ValidateTestProperty ( const std::string xml_element,
const TestProperty test_property 
)
staticprivate
bool testing::TestResult::ValidateTestProperty ( const std::string xml_element,
const TestProperty test_property 
)
staticprivate

Definition at line 2155 of file gtest.cc.

References testing::GetReservedAttributesForElement(), testing::TestProperty::key(), and testing::ValidateTestPropertyName().

Referenced by testing::FormatWordList(), and RecordProperty().

2156  {
2157  return ValidateTestPropertyName(test_property.key(),
2158  GetReservedAttributesForElement(xml_element));
2159 }
static std::vector< std::string > GetReservedAttributesForElement(const std::string &xml_element)
Definition: gtest.cc:2112
bool ValidateTestPropertyName(const std::string &property_name, const std::vector< std::string > &reserved_names)
Definition: gtest.cc:2141
static bool testing::TestResult::ValidateTestProperty ( const std::string xml_element,
const TestProperty test_property 
)
staticprivate

Friends And Related Function Documentation

Definition at line 567 of file gtest.h.

internal::ExecDeathTest
friend

Definition at line 568 of file gtest.h.

Definition at line 569 of file gtest.h.

Definition at line 570 of file gtest.h.

internal::WindowsDeathTest
friend

Definition at line 571 of file gtest.h.

TestCase
friend

Definition at line 565 of file gtest.h.

TestInfo
friend

Definition at line 564 of file gtest.h.

UnitTest
friend

Definition at line 566 of file gtest.h.

Member Data Documentation

int testing::TestResult::death_test_count_
private

Definition at line 625 of file gtest.h.

Referenced by Clear().

TimeInMillis testing::TestResult::elapsed_time_
private

Definition at line 627 of file gtest.h.

Referenced by Clear().

std::vector< TestPartResult > testing::TestResult::test_part_results_
private
internal::Mutex testing::TestResult::test_properites_mutex_
private

Definition at line 618 of file gtest.h.

Referenced by RecordProperty().

std::vector< TestProperty > testing::TestResult::test_properties_
private

Definition at line 623 of file gtest.h.

Referenced by Clear(), GetTestProperty(), RecordProperty(), and test_property_count().


The documentation for this class was generated from the following files: