proxygen
testing::UnitTest Class Reference

#include <gtest.h>

Public Member Functions

int Run () GTEST_MUST_USE_RESULT_
 
const char * original_working_dir () const
 
const TestCasecurrent_test_case () const GTEST_LOCK_EXCLUDED_(mutex_)
 
const TestInfocurrent_test_info () const GTEST_LOCK_EXCLUDED_(mutex_)
 
int random_seed () const
 
int successful_test_case_count () const
 
int failed_test_case_count () const
 
int total_test_case_count () const
 
int test_case_to_run_count () const
 
int successful_test_count () const
 
int failed_test_count () const
 
int reportable_disabled_test_count () const
 
int disabled_test_count () const
 
int reportable_test_count () const
 
int total_test_count () const
 
int test_to_run_count () const
 
TimeInMillis start_timestamp () const
 
TimeInMillis elapsed_time () const
 
bool Passed () const
 
bool Failed () const
 
const TestCaseGetTestCase (int i) const
 
const TestResultad_hoc_test_result () const
 
TestEventListenerslisteners ()
 
int Run () GTEST_MUST_USE_RESULT_
 
const char * original_working_dir () const
 
const TestCasecurrent_test_case () const GTEST_LOCK_EXCLUDED_(mutex_)
 
const TestInfocurrent_test_info () const GTEST_LOCK_EXCLUDED_(mutex_)
 
int random_seed () const
 
int successful_test_case_count () const
 
int failed_test_case_count () const
 
int total_test_case_count () const
 
int test_case_to_run_count () const
 
int successful_test_count () const
 
int failed_test_count () const
 
int reportable_disabled_test_count () const
 
int disabled_test_count () const
 
int reportable_test_count () const
 
int total_test_count () const
 
int test_to_run_count () const
 
TimeInMillis start_timestamp () const
 
TimeInMillis elapsed_time () const
 
bool Passed () const
 
bool Failed () const
 
const TestCaseGetTestCase (int i) const
 
const TestResultad_hoc_test_result () const
 
TestEventListenerslisteners ()
 
int Run () GTEST_MUST_USE_RESULT_
 
const char * original_working_dir () const
 
const TestCasecurrent_test_case () const GTEST_LOCK_EXCLUDED_(mutex_)
 
const TestInfocurrent_test_info () const GTEST_LOCK_EXCLUDED_(mutex_)
 
int random_seed () const
 
int successful_test_case_count () const
 
int failed_test_case_count () const
 
int total_test_case_count () const
 
int test_case_to_run_count () const
 
int successful_test_count () const
 
int failed_test_count () const
 
int reportable_disabled_test_count () const
 
int disabled_test_count () const
 
int reportable_test_count () const
 
int total_test_count () const
 
int test_to_run_count () const
 
TimeInMillis start_timestamp () const
 
TimeInMillis elapsed_time () const
 
bool Passed () const
 
bool Failed () const
 
const TestCaseGetTestCase (int i) const
 
const TestResultad_hoc_test_result () const
 
TestEventListenerslisteners ()
 

Static Public Member Functions

static UnitTestGetInstance ()
 
static UnitTestGetInstance ()
 
static UnitTestGetInstance ()
 

Private Member Functions

EnvironmentAddEnvironment (Environment *env)
 
void AddTestPartResult (TestPartResult::Type result_type, const char *file_name, int line_number, const std::string &message, const std::string &os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_)
 
void RecordProperty (const std::string &key, const std::string &value)
 
TestCaseGetMutableTestCase (int i)
 
internal::UnitTestImplimpl ()
 
const internal::UnitTestImplimpl () const
 
 UnitTest ()
 
virtual ~UnitTest ()
 
void PushGTestTrace (const internal::TraceInfo &trace) GTEST_LOCK_EXCLUDED_(mutex_)
 
void PopGTestTrace () GTEST_LOCK_EXCLUDED_(mutex_)
 
 GTEST_DISALLOW_COPY_AND_ASSIGN_ (UnitTest)
 
EnvironmentAddEnvironment (Environment *env)
 
void AddTestPartResult (TestPartResult::Type result_type, const char *file_name, int line_number, const std::string &message, const std::string &os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_)
 
void RecordProperty (const std::string &key, const std::string &value)
 
TestCaseGetMutableTestCase (int i)
 
internal::UnitTestImplimpl ()
 
const internal::UnitTestImplimpl () const
 
 UnitTest ()
 
virtual ~UnitTest ()
 
void PushGTestTrace (const internal::TraceInfo &trace) GTEST_LOCK_EXCLUDED_(mutex_)
 
void PopGTestTrace () GTEST_LOCK_EXCLUDED_(mutex_)
 
 GTEST_DISALLOW_COPY_AND_ASSIGN_ (UnitTest)
 
EnvironmentAddEnvironment (Environment *env)
 
void AddTestPartResult (TestPartResult::Type result_type, const char *file_name, int line_number, const std::string &message, const std::string &os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_)
 
void RecordProperty (const std::string &key, const std::string &value)
 
TestCaseGetMutableTestCase (int i)
 
internal::UnitTestImplimpl ()
 
const internal::UnitTestImplimpl () const
 
 UnitTest ()
 
virtual ~UnitTest ()
 
void PushGTestTrace (const internal::TraceInfo &trace) GTEST_LOCK_EXCLUDED_(mutex_)
 
void PopGTestTrace () GTEST_LOCK_EXCLUDED_(mutex_)
 
 GTEST_DISALLOW_COPY_AND_ASSIGN_ (UnitTest)
 

Private Attributes

internal::Mutex mutex_
 
internal::UnitTestImplimpl_
 

Friends

class Test
 
class internal::AssertHelper
 
class internal::ScopedTrace
 
class internal::StreamingListenerTest
 
class internal::UnitTestRecordPropertyTestHelper
 
EnvironmentAddGlobalTestEnvironment (Environment *env)
 
internal::UnitTestImplinternal::GetUnitTestImpl ()
 
void internal::ReportFailureInUnknownLocation (TestPartResult::Type result_type, const std::string &message)
 
EnvironmentAddGlobalTestEnvironment (Environment *env)
 
internal::UnitTestImplinternal::GetUnitTestImpl ()
 
void internal::ReportFailureInUnknownLocation (TestPartResult::Type result_type, const std::string &message)
 
EnvironmentAddGlobalTestEnvironment (Environment *env)
 
internal::UnitTestImplinternal::GetUnitTestImpl ()
 
void internal::ReportFailureInUnknownLocation (TestPartResult::Type result_type, const std::string &message)
 

Detailed Description

Definition at line 1151 of file gtest.h.

Constructor & Destructor Documentation

testing::UnitTest::UnitTest ( )
private

Definition at line 4299 of file gtest.cc.

Referenced by testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4299  {
4300  impl_ = new internal::UnitTestImpl(this);
4301 }
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
testing::UnitTest::~UnitTest ( )
privatevirtual

Definition at line 4304 of file gtest.cc.

Referenced by testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4304  {
4305  delete impl_;
4306 }
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
testing::UnitTest::UnitTest ( )
private
virtual testing::UnitTest::~UnitTest ( )
privatevirtual
testing::UnitTest::UnitTest ( )
private
virtual testing::UnitTest::~UnitTest ( )
privatevirtual

Member Function Documentation

const TestResult & testing::UnitTest::ad_hoc_test_result ( ) const
const TestResult& testing::UnitTest::ad_hoc_test_result ( ) const
const TestResult& testing::UnitTest::ad_hoc_test_result ( ) const
Environment* testing::UnitTest::AddEnvironment ( Environment env)
private
Environment * testing::UnitTest::AddEnvironment ( Environment env)
private

Definition at line 4095 of file gtest.cc.

Referenced by testing::AddGlobalTestEnvironment(), impl(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4095  {
4096  if (env == NULL) {
4097  return NULL;
4098  }
4099 
4100  impl_->environments().push_back(env);
4101  return env;
4102 }
std::vector< Environment * > & environments()
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
Environment* testing::UnitTest::AddEnvironment ( Environment env)
private
void testing::UnitTest::AddTestPartResult ( TestPartResult::Type  result_type,
const char *  file_name,
int  line_number,
const std::string message,
const std::string os_stack_trace 
)
private
void testing::UnitTest::AddTestPartResult ( TestPartResult::Type  result_type,
const char *  file_name,
int  line_number,
const std::string message,
const std::string os_stack_trace 
)
private

Definition at line 4108 of file gtest.cc.

References testing::internal::TraceInfo::file, testing::internal::FormatFileLocation(), testing::Message::GetString(), GTEST_FLAG, GTEST_NAME_, i, testing::internal::kStackTraceMarker, testing::TestPartResult::kSuccess, testing::internal::TraceInfo::line, folly::detail::lock(), message, testing::internal::TraceInfo::message, and mutex_.

Referenced by testing::internal::ReportFailureInUnknownLocation(), testing::TestPartNonfatallyFailed(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4113  {
4114  Message msg;
4115  msg << message;
4116 
4118  if (impl_->gtest_trace_stack().size() > 0) {
4119  msg << "\n" << GTEST_NAME_ << " trace:";
4120 
4121  for (int i = static_cast<int>(impl_->gtest_trace_stack().size());
4122  i > 0; --i) {
4123  const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
4124  msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
4125  << " " << trace.message;
4126  }
4127  }
4128 
4129  if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) {
4130  msg << internal::kStackTraceMarker << os_stack_trace;
4131  }
4132 
4133  const TestPartResult result =
4134  TestPartResult(result_type, file_name, line_number,
4135  msg.GetString().c_str());
4137  ReportTestPartResult(result);
4138 
4139  if (result_type != TestPartResult::kSuccess) {
4140  // gtest_break_on_failure takes precedence over
4141  // gtest_throw_on_failure. This allows a user to set the latter
4142  // in the code (perhaps in order to use Google Test assertions
4143  // with another testing framework) and specify the former on the
4144  // command line for debugging.
4145  if (GTEST_FLAG(break_on_failure)) {
4146 #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
4147  // Using DebugBreak on Windows allows gtest to still break into a debugger
4148  // when a failure happens and both the --gtest_break_on_failure and
4149  // the --gtest_catch_exceptions flags are specified.
4150  DebugBreak();
4151 #else
4152  // Dereference NULL through a volatile pointer to prevent the compiler
4153  // from removing. We use this rather than abort() or __builtin_trap() for
4154  // portability: Symbian doesn't implement abort() well, and some debuggers
4155  // don't correctly trap abort().
4156  *static_cast<volatile int*>(NULL) = 1;
4157 #endif // GTEST_OS_WINDOWS
4158  } else if (GTEST_FLAG(throw_on_failure)) {
4159 #if GTEST_HAS_EXCEPTIONS
4160  throw internal::GoogleTestFailureException(result);
4161 #else
4162  // We cannot call abort() as it generates a pop-up in debug mode
4163  // that cannot be suppressed in VC 7.1 or below.
4164  exit(1);
4165 #endif
4166  }
4167  }
4168 }
TestPartResultReporterInterface * GetTestPartResultReporterForCurrentThread()
Definition: gtest.cc:719
#define GTEST_FLAG(name)
Definition: gtest-port.h:2504
::std::string FormatFileLocation(const char *file, int line)
Definition: gtest-port.cc:880
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
Definition: Synchronized.h:871
GTestMutexLock MutexLock
Definition: gtest-port.h:2159
std::string message
Definition: SPDYCodec.cpp:133
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
GTEST_API_ const char kStackTraceMarker[]
Definition: gtest.cc:184
internal::Mutex mutex_
Definition: gtest.h:1320
std::vector< TraceInfo > & gtest_trace_stack()
#define GTEST_NAME_
Definition: gtest-port.h:289
void testing::UnitTest::AddTestPartResult ( TestPartResult::Type  result_type,
const char *  file_name,
int  line_number,
const std::string message,
const std::string os_stack_trace 
)
private
const TestCase* testing::UnitTest::current_test_case ( ) const
const TestCase* testing::UnitTest::current_test_case ( ) const
const TestCase * testing::UnitTest::current_test_case ( ) const

Definition at line 4271 of file gtest.cc.

References folly::detail::lock().

Referenced by testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4272  {
4274  return impl_->current_test_case();
4275 }
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
Definition: Synchronized.h:871
GTestMutexLock MutexLock
Definition: gtest-port.h:2159
const TestCase * current_test_case() const
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
internal::Mutex mutex_
Definition: gtest.h:1320
const TestInfo* testing::UnitTest::current_test_info ( ) const
const TestInfo* testing::UnitTest::current_test_info ( ) const
const TestInfo * testing::UnitTest::current_test_info ( ) const

Definition at line 4279 of file gtest.cc.

References folly::detail::lock().

Referenced by testing::CurrentTestInfoTest::SetUpTestCase(), CommonTest< T >::TearDown(), testing::CurrentTestInfoTest::TearDownTestCase(), testing::TEST_F(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4280  {
4282  return impl_->current_test_info();
4283 }
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
Definition: Synchronized.h:871
GTestMutexLock MutexLock
Definition: gtest-port.h:2159
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
internal::Mutex mutex_
Definition: gtest.h:1320
int testing::UnitTest::disabled_test_count ( ) const
int testing::UnitTest::disabled_test_count ( ) const
int testing::UnitTest::disabled_test_count ( ) const
TimeInMillis testing::UnitTest::elapsed_time ( ) const
TimeInMillis testing::UnitTest::elapsed_time ( ) const
bool testing::UnitTest::Failed ( ) const
bool testing::UnitTest::Failed ( ) const
bool testing::UnitTest::Failed ( ) const
int testing::UnitTest::failed_test_case_count ( ) const

Definition at line 3999 of file gtest.cc.

Referenced by testing::internal::FinalSuccessChecker::TearDown(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

3999  {
4000  return impl()->failed_test_case_count();
4001 }
int failed_test_case_count() const
Definition: gtest.cc:735
internal::UnitTestImpl * impl()
Definition: gtest.h:1287
int testing::UnitTest::failed_test_case_count ( ) const
int testing::UnitTest::failed_test_case_count ( ) const
int testing::UnitTest::failed_test_count ( ) const
int testing::UnitTest::failed_test_count ( ) const
static UnitTest* testing::UnitTest::GetInstance ( )
static
static UnitTest* testing::UnitTest::GetInstance ( )
static
UnitTest * testing::UnitTest::GetInstance ( )
static

Definition at line 3972 of file gtest.cc.

Referenced by testing::AddGlobalTestEnvironment(), testing::internal::UnitTestHelper::FindTestCase(), testing::internal::UnitTestOptions::GetAbsolutePathToOutputFile(), testing::internal::UnitTestHelper::GetSortedTestCases(), testing::internal::UnitTestHelper::GetSortedTests(), testing::internal::GetUnitTestImpl(), impl(), testing::internal::Log(), main(), testing::internal::AssertHelper::operator=(), testing::internal::PortableLocaltime(), testing::Test::RecordProperty(), testing::internal::GoogleTestFailureReporter::ReportFailure(), testing::internal::ReportFailureInUnknownLocation(), testing::TestInfo::Run(), testing::TestCase::Run(), testing::internal::ScopedTrace::ScopedTrace(), testing::internal::UnitTestImpl::set_catch_exceptions(), testing::CurrentTestInfoTest::SetUpTestCase(), testing::internal::ShouldRunTestCase(), CommonTest< T >::TearDown(), testing::internal::FinalSuccessChecker::TearDown(), testing::CurrentTestInfoTest::TearDownTestCase(), testing::internal::TEST(), TEST(), testing::TEST_F(), testing::TestPartNonfatallyFailed(), testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile(), and testing::internal::ScopedTrace::~ScopedTrace().

3972  {
3973  // When compiled with MSVC 7.1 in optimized mode, destroying the
3974  // UnitTest object upon exiting the program messes up the exit code,
3975  // causing successful tests to appear failed. We have to use a
3976  // different implementation in this case to bypass the compiler bug.
3977  // This implementation makes the compiler happy, at the cost of
3978  // leaking the UnitTest object.
3979 
3980  // CodeGear C++Builder insists on a public destructor for the
3981  // default implementation. Use this implementation to keep good OO
3982  // design with private destructor.
3983 
3984 #if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
3985  static UnitTest* const instance = new UnitTest;
3986  return instance;
3987 #else
3988  static UnitTest instance;
3989  return &instance;
3990 #endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
3991 }
TestCase* testing::UnitTest::GetMutableTestCase ( int  i)
private
TestCase * testing::UnitTest::GetMutableTestCase ( int  i)
private

Definition at line 4075 of file gtest.cc.

Referenced by testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4075  {
4076  return impl()->GetMutableTestCase(i);
4077 }
internal::UnitTestImpl * impl()
Definition: gtest.h:1287
TestCase* testing::UnitTest::GetMutableTestCase ( int  i)
private
const TestCase* testing::UnitTest::GetTestCase ( int  i) const
const TestCase* testing::UnitTest::GetTestCase ( int  i) const
testing::UnitTest::GTEST_DISALLOW_COPY_AND_ASSIGN_ ( UnitTest  )
private
testing::UnitTest::GTEST_DISALLOW_COPY_AND_ASSIGN_ ( UnitTest  )
private
testing::UnitTest::GTEST_DISALLOW_COPY_AND_ASSIGN_ ( UnitTest  )
private
internal::UnitTestImpl* testing::UnitTest::impl ( )
inlineprivate

Definition at line 1287 of file gtest.h.

1287 { return impl_; }
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
internal::UnitTestImpl* testing::UnitTest::impl ( )
inlineprivate

Definition at line 1287 of file gtest.h.

1287 { return impl_; }
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
const internal::UnitTestImpl* testing::UnitTest::impl ( ) const
inlineprivate

Definition at line 1288 of file gtest.h.

1288 { return impl_; }
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
TestEventListeners& testing::UnitTest::listeners ( )
TestEventListeners & testing::UnitTest::listeners ( )

Definition at line 4081 of file gtest.cc.

Referenced by main(), testing::TestInfo::Run(), testing::TestCase::Run(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4081  {
4082  return *impl()->listeners();
4083 }
internal::UnitTestImpl * impl()
Definition: gtest.h:1287
TestEventListeners * listeners()
TestEventListeners& testing::UnitTest::listeners ( )
const char* testing::UnitTest::original_working_dir ( ) const
const char* testing::UnitTest::original_working_dir ( ) const
const char * testing::UnitTest::original_working_dir ( ) const

Definition at line 4265 of file gtest.cc.

Referenced by testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4265  {
4266  return impl_->original_working_dir_.c_str();
4267 }
internal::FilePath original_working_dir_
const char * c_str() const
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
bool testing::UnitTest::Passed ( ) const
bool testing::UnitTest::Passed ( ) const
void testing::UnitTest::PopGTestTrace ( )
private
void testing::UnitTest::PopGTestTrace ( )
private

Definition at line 4317 of file gtest.cc.

References folly::detail::lock().

Referenced by testing::internal::PortableLocaltime(), testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile(), and testing::internal::ScopedTrace::~ScopedTrace().

4318  {
4320  impl_->gtest_trace_stack().pop_back();
4321 }
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
Definition: Synchronized.h:871
GTestMutexLock MutexLock
Definition: gtest-port.h:2159
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
internal::Mutex mutex_
Definition: gtest.h:1320
std::vector< TraceInfo > & gtest_trace_stack()
void testing::UnitTest::PopGTestTrace ( )
private
void testing::UnitTest::PushGTestTrace ( const internal::TraceInfo trace)
private
void testing::UnitTest::PushGTestTrace ( const internal::TraceInfo trace)
private
void testing::UnitTest::PushGTestTrace ( const internal::TraceInfo trace)
private

Definition at line 4310 of file gtest.cc.

References folly::detail::lock(), and mutex_.

Referenced by testing::internal::PortableLocaltime(), testing::internal::ScopedTrace::ScopedTrace(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4311  {
4313  impl_->gtest_trace_stack().push_back(trace);
4314 }
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >
Definition: Synchronized.h:871
GTestMutexLock MutexLock
Definition: gtest-port.h:2159
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
internal::Mutex mutex_
Definition: gtest.h:1320
std::vector< TraceInfo > & gtest_trace_stack()
int testing::UnitTest::random_seed ( ) const
int testing::UnitTest::random_seed ( ) const
void testing::UnitTest::RecordProperty ( const std::string key,
const std::string value 
)
private
void testing::UnitTest::RecordProperty ( const std::string key,
const std::string value 
)
private

Definition at line 4175 of file gtest.cc.

Referenced by testing::Test::RecordProperty(), testing::TestPartNonfatallyFailed(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4176  {
4177  impl_->RecordProperty(TestProperty(key, value));
4178 }
void RecordProperty(const TestProperty &test_property)
Definition: gtest.cc:4372
static const char *const value
Definition: Conv.cpp:50
internal::UnitTestImpl * impl_
Definition: gtest.h:1326
void testing::UnitTest::RecordProperty ( const std::string key,
const std::string value 
)
private
int testing::UnitTest::reportable_disabled_test_count ( ) const
int testing::UnitTest::reportable_disabled_test_count ( ) const
int testing::UnitTest::reportable_test_count ( ) const
int testing::UnitTest::reportable_test_count ( ) const
int testing::UnitTest::reportable_test_count ( ) const
int testing::UnitTest::Run ( )
int testing::UnitTest::Run ( )
int testing::UnitTest::Run ( )

Definition at line 4185 of file gtest.cc.

References testing::internal::posix::GetEnv(), GTEST_FLAG, testing::internal::HandleExceptionsInMethodIfSupported(), and testing::internal::UnitTestImpl::RunAllTests().

Referenced by testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

4185  {
4186  const bool in_death_test_child_process =
4187  internal::GTEST_FLAG(internal_run_death_test).length() > 0;
4188 
4189  // Google Test implements this protocol for catching that a test
4190  // program exits before returning control to Google Test:
4191  //
4192  // 1. Upon start, Google Test creates a file whose absolute path
4193  // is specified by the environment variable
4194  // TEST_PREMATURE_EXIT_FILE.
4195  // 2. When Google Test has finished its work, it deletes the file.
4196  //
4197  // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before
4198  // running a Google-Test-based test program and check the existence
4199  // of the file at the end of the test execution to see if it has
4200  // exited prematurely.
4201 
4202  // If we are in the child process of a death test, don't
4203  // create/delete the premature exit file, as doing so is unnecessary
4204  // and will confuse the parent process. Otherwise, create/delete
4205  // the file upon entering/leaving this function. If the program
4206  // somehow exits before this function has a chance to return, the
4207  // premature-exit file will be left undeleted, causing a test runner
4208  // that understands the premature-exit-file protocol to report the
4209  // test as having failed.
4210  const internal::ScopedPrematureExitFile premature_exit_file(
4211  in_death_test_child_process ?
4212  NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
4213 
4214  // Captures the value of GTEST_FLAG(catch_exceptions). This value will be
4215  // used for the duration of the program.
4216  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
4217 
4218 #if GTEST_HAS_SEH
4219  // Either the user wants Google Test to catch exceptions thrown by the
4220  // tests or this is executing in the context of death test child
4221  // process. In either case the user does not want to see pop-up dialogs
4222  // about crashes - they are expected.
4223  if (impl()->catch_exceptions() || in_death_test_child_process) {
4224 # if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
4225  // SetErrorMode doesn't exist on CE.
4226  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
4227  SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
4228 # endif // !GTEST_OS_WINDOWS_MOBILE
4229 
4230 # if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
4231  // Death test children can be terminated with _abort(). On Windows,
4232  // _abort() can show a dialog with a warning message. This forces the
4233  // abort message to go to stderr instead.
4234  _set_error_mode(_OUT_TO_STDERR);
4235 # endif
4236 
4237 # if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
4238  // In the debug version, Visual Studio pops up a separate dialog
4239  // offering a choice to debug the aborted program. We need to suppress
4240  // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
4241  // executed. Google Test will notify the user of any unexpected
4242  // failure via stderr.
4243  //
4244  // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
4245  // Users of prior VC versions shall suffer the agony and pain of
4246  // clicking through the countless debug dialogs.
4247  // TODO(vladl@google.com): find a way to suppress the abort dialog() in the
4248  // debug mode when compiled with VC 7.1 or lower.
4249  if (!GTEST_FLAG(break_on_failure))
4250  _set_abort_behavior(
4251  0x0, // Clear the following flags:
4252  _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
4253 # endif
4254  }
4255 #endif // GTEST_HAS_SEH
4256 
4258  impl(),
4260  "auxiliary test code (environments or event listeners)") ? 0 : 1;
4261 }
#define GTEST_FLAG(name)
Definition: gtest-port.h:2504
Result HandleExceptionsInMethodIfSupported(T *object, Result(T::*method)(), const char *location)
Definition: gtest.cc:2410
internal::UnitTestImpl * impl()
Definition: gtest.h:1287
const char * GetEnv(const char *name)
Definition: gtest-port.h:2387
internal::TimeInMillis testing::UnitTest::start_timestamp ( ) const
TimeInMillis testing::UnitTest::start_timestamp ( ) const
TimeInMillis testing::UnitTest::start_timestamp ( ) const
int testing::UnitTest::successful_test_case_count ( ) const
int testing::UnitTest::successful_test_case_count ( ) const
int testing::UnitTest::successful_test_case_count ( ) const

Definition at line 3994 of file gtest.cc.

Referenced by testing::internal::FinalSuccessChecker::TearDown(), and testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile().

3994  {
3995  return impl()->successful_test_case_count();
3996 }
int successful_test_case_count() const
Definition: gtest.cc:730
internal::UnitTestImpl * impl()
Definition: gtest.h:1287
int testing::UnitTest::successful_test_count ( ) const
int testing::UnitTest::successful_test_count ( ) const
int testing::UnitTest::test_case_to_run_count ( ) const
int testing::UnitTest::test_case_to_run_count ( ) const
int testing::UnitTest::test_to_run_count ( ) const
int testing::UnitTest::test_to_run_count ( ) const
int testing::UnitTest::total_test_case_count ( ) const
int testing::UnitTest::total_test_case_count ( ) const
int testing::UnitTest::total_test_count ( ) const
int testing::UnitTest::total_test_count ( ) const
int testing::UnitTest::total_test_count ( ) const

Friends And Related Function Documentation

Environment* AddGlobalTestEnvironment ( Environment env)
friend

Definition at line 1350 of file gtest.h.

1350  {
1351  return UnitTest::GetInstance()->AddEnvironment(env);
1352 }
Environment * AddEnvironment(Environment *env)
Definition: gtest.cc:4095
static UnitTest * GetInstance()
Definition: gtest.cc:3972
Environment* AddGlobalTestEnvironment ( Environment env)
friend

Definition at line 1350 of file gtest.h.

1350  {
1351  return UnitTest::GetInstance()->AddEnvironment(env);
1352 }
Environment * AddEnvironment(Environment *env)
Definition: gtest.cc:4095
static UnitTest * GetInstance()
Definition: gtest.cc:3972
Environment* AddGlobalTestEnvironment ( Environment env)
friend

Definition at line 1350 of file gtest.h.

1350  {
1351  return UnitTest::GetInstance()->AddEnvironment(env);
1352 }
Environment * AddEnvironment(Environment *env)
Definition: gtest.cc:4095
static UnitTest * GetInstance()
Definition: gtest.cc:3972

Definition at line 1293 of file gtest.h.

void internal::ReportFailureInUnknownLocation ( TestPartResult::Type  result_type,
const std::string message 
)
friend
void internal::ReportFailureInUnknownLocation ( TestPartResult::Type  result_type,
const std::string message 
)
friend
void internal::ReportFailureInUnknownLocation ( TestPartResult::Type  result_type,
const std::string message 
)
friend

Definition at line 1294 of file gtest.h.

internal::StreamingListenerTest
friend

Definition at line 1295 of file gtest.h.

Definition at line 1296 of file gtest.h.

Test
friend

Definition at line 1292 of file gtest.h.

Member Data Documentation

internal::UnitTestImpl * testing::UnitTest::impl_
private

Definition at line 1326 of file gtest.h.

internal::Mutex testing::UnitTest::mutex_
mutableprivate

Definition at line 1320 of file gtest.h.

Referenced by testing::internal::PortableLocaltime().


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