- 3.0.1 core module.
gtest-port.h File Reference
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory>
#include <type_traits>
#include <sys/types.h>
#include <sys/stat.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "gtest/internal/gtest-port-arch.h"
#include "gtest/internal/custom/gtest-port.h"
#include <unistd.h>
#include <strings.h>
#include <regex.h>
#include <typeinfo>

Go to the source code of this file.

Classes

struct  testing::internal::StaticAssertTypeEqHelper< T1, T2 >
 
struct  testing::internal::StaticAssertTypeEqHelper< T, T >
 
struct  testing::internal::IsSame< T, U >
 
struct  testing::internal::IsSame< T, T >
 
class  testing::internal::RE
 
class  testing::internal::GTestLog
 
struct  testing::internal::AddReference< T >
 
struct  testing::internal::AddReference< T & >
 
struct  testing::internal::ConstRef< T >
 
struct  testing::internal::ConstRef< T & >
 
class  testing::internal::Mutex
 
class  testing::internal::GTestMutexLock
 
class  testing::internal::ThreadLocal< T >
 
struct  testing::internal::bool_constant< bool_value >
 
struct  testing::internal::is_same< T, U >
 
struct  testing::internal::is_same< T, T >
 
struct  testing::internal::IteratorTraits< Iterator >
 
struct  testing::internal::IteratorTraits< T * >
 
struct  testing::internal::IteratorTraits< const T * >
 
class  testing::internal::TypeWithSize< size >
 
class  testing::internal::TypeWithSize< 4 >
 
class  testing::internal::TypeWithSize< 8 >
 

Namespaces

 testing
 
 testing::internal
 
 testing::internal::posix
 

Macros

#define GTEST_DEV_EMAIL_   "googletestframework@@googlegroups.com"
 
#define GTEST_FLAG_PREFIX_   "gtest_"
 
#define GTEST_FLAG_PREFIX_DASH_   "gtest-"
 
#define GTEST_FLAG_PREFIX_UPPER_   "GTEST_"
 
#define GTEST_NAME_   "Google Test"
 
#define GTEST_PROJECT_URL_   "https://github.com/google/googletest/"
 
#define GTEST_INIT_GOOGLE_TEST_NAME_   "testing::InitGoogleTest"
 
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
 
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
 
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_()   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
 
#define GTEST_DISABLE_MSC_DEPRECATED_POP_()   GTEST_DISABLE_MSC_WARNINGS_POP_()
 
#define GTEST_HAS_POSIX_RE   (!GTEST_OS_WINDOWS)
 
#define GTEST_USES_POSIX_RE   1
 
#define GTEST_HAS_EXCEPTIONS   0
 
#define GTEST_HAS_STD_STRING   1
 
#define GTEST_HAS_STD_WSTRING
 
#define GTEST_HAS_RTTI   1
 
#define GTEST_HAS_PTHREAD
 
#define GTEST_HAS_CLONE   0
 
#define GTEST_HAS_STREAM_REDIRECTION   1
 
#define GTEST_WIDE_STRING_USES_UTF16_   (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2)
 
#define GTEST_AMBIGUOUS_ELSE_BLOCKER_   switch (0) case 0: default:
 
#define GTEST_ATTRIBUTE_UNUSED_
 
#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
 
#define GTEST_DISALLOW_ASSIGN_(type)   void operator=(type const &) = delete
 
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
 
#define GTEST_MUST_USE_RESULT_
 
#define GTEST_INTENTIONAL_CONST_COND_PUSH_()   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)
 
#define GTEST_INTENTIONAL_CONST_COND_POP_()   GTEST_DISABLE_MSC_WARNINGS_POP_()
 
#define GTEST_HAS_SEH   0
 
#define GTEST_IS_THREADSAFE
 
#define GTEST_API_
 
#define GTEST_DEFAULT_DEATH_TEST_STYLE   "fast"
 
#define GTEST_NO_INLINE_
 
#define GTEST_HAS_CXXABI_H_   0
 
#define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
 
#define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
 
#define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
 
#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
 
#define GTEST_COMPILE_ASSERT_(expr, msg)   static_assert(expr, #msg)
 
#define GTEST_ARRAY_SIZE_(array)   (sizeof(array) / sizeof(array[0]))
 
#define GTEST_LOG_(severity)
 
#define GTEST_CHECK_(condition)
 
#define GTEST_CHECK_POSIX_SUCCESS_(posix_call)
 
#define GTEST_ADD_REFERENCE_(T)   typename ::testing::internal::AddReference<T>::type
 
#define GTEST_REFERENCE_TO_CONST_(T)   typename ::testing::internal::ConstRef<T>::type
 
#define GTEST_DECLARE_STATIC_MUTEX_(mutex)   extern ::testing::internal::Mutex mutex
 
#define GTEST_DEFINE_STATIC_MUTEX_(mutex)   ::testing::internal::Mutex mutex
 
#define GTEST_PATH_SEP_   "/"
 
#define GTEST_HAS_ALT_PATH_SEP_   0
 
#define GTEST_SNPRINTF_   snprintf
 
#define GTEST_FLAG(name)   FLAGS_gtest_##name
 
#define GTEST_USE_OWN_FLAGFILE_FLAG_   1
 
#define GTEST_FLAG_SAVER_   ::testing::internal::GTestFlagSaver
 
#define GTEST_DECLARE_bool_(name)   GTEST_API_ extern bool GTEST_FLAG(name)
 
#define GTEST_DECLARE_int32_(name)   GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
 
#define GTEST_DECLARE_string_(name)   GTEST_API_ extern ::std::string GTEST_FLAG(name)
 
#define GTEST_DEFINE_bool_(name, default_val, doc)   GTEST_API_ bool GTEST_FLAG(name) = (default_val)
 
#define GTEST_DEFINE_int32_(name, default_val, doc)   GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
 
#define GTEST_DEFINE_string_(name, default_val, doc)   GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
 
#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
 
#define GTEST_LOCK_EXCLUDED_(locks)
 
#define GTEST_INTERNAL_DEPRECATED(message)
 

Typedefs

typedef GTestMutexLock testing::internal::MutexLock
 
typedef bool_constant< false > testing::internal::false_type
 
typedef bool_constant< true > testing::internal::true_type
 
typedef long long testing::internal::BiggestInt
 
typedef struct stat testing::internal::posix::StatStruct
 
typedef TypeWithSize< 4 >::Int testing::internal::Int32
 
typedef TypeWithSize< 4 >::UInt testing::internal::UInt32
 
typedef TypeWithSize< 8 >::Int testing::internal::Int64
 
typedef TypeWithSize< 8 >::UInt testing::internal::UInt64
 
typedef TypeWithSize< 8 >::Int testing::internal::TimeInMillis
 

Enumerations

Functions

GTEST_API_ bool testing::internal::IsTrue (bool condition)
 
GTEST_API_::std::string testing::internal::FormatFileLocation (const char *file, int line)
 
GTEST_API_::std::string testing::internal::FormatCompilerIndependentFileLocation (const char *file, int line)
 
void testing::internal::LogToStderr ()
 
void testing::internal::FlushInfoLog ()
 
template<typename To >
To testing::internal::ImplicitCast_ (To x)
 
template<typename To , typename From >
To testing::internal::DownCast_ (From *f)
 
template<class Derived , class Base >
Derived * testing::internal::CheckedDowncastToActualType (Base *base)
 
GTEST_API_ void testing::internal::CaptureStdout ()
 
GTEST_API_ std::string testing::internal::GetCapturedStdout ()
 
GTEST_API_ void testing::internal::CaptureStderr ()
 
GTEST_API_ std::string testing::internal::GetCapturedStderr ()
 
GTEST_API_ size_t testing::internal::GetFileSize (FILE *file)
 
GTEST_API_ std::string testing::internal::ReadEntireFile (FILE *file)
 
GTEST_API_ std::vector< std::string > testing::internal::GetArgvs ()
 
GTEST_API_ size_t testing::internal::GetThreadCount ()
 
bool testing::internal::IsAlpha (char ch)
 
bool testing::internal::IsAlNum (char ch)
 
bool testing::internal::IsDigit (char ch)
 
bool testing::internal::IsLower (char ch)
 
bool testing::internal::IsSpace (char ch)
 
bool testing::internal::IsUpper (char ch)
 
bool testing::internal::IsXDigit (char ch)
 
bool testing::internal::IsXDigit (wchar_t ch)
 
char testing::internal::ToLower (char ch)
 
char testing::internal::ToUpper (char ch)
 
std::string testing::internal::StripTrailingSpaces (std::string str)
 
int testing::internal::posix::FileNo (FILE *file)
 
int testing::internal::posix::IsATTY (int fd)
 
int testing::internal::posix::Stat (const char *path, StatStruct *buf)
 
int testing::internal::posix::StrCaseCmp (const char *s1, const char *s2)
 
char * testing::internal::posix::StrDup (const char *src)
 
int testing::internal::posix::RmDir (const char *dir)
 
bool testing::internal::posix::IsDir (const StatStruct &st)
 
const char * testing::internal::posix::StrNCpy (char *dest, const char *src, size_t n)
 
int testing::internal::posix::ChDir (const char *dir)
 
FILEtesting::internal::posix::FOpen (const char *path, const char *mode)
 
FILEtesting::internal::posix::FReopen (const char *path, const char *mode, FILE *stream)
 
FILEtesting::internal::posix::FDOpen (int fd, const char *mode)
 
int testing::internal::posix::FClose (FILE *fp)
 
int testing::internal::posix::Read (int fd, void *buf, unsigned int count)
 
int testing::internal::posix::Write (int fd, const void *buf, unsigned int count)
 
int testing::internal::posix::Close (int fd)
 
const char * testing::internal::posix::StrError (int errnum)
 
const char * testing::internal::posix::GetEnv (const char *name)
 
void testing::internal::posix::Abort ()
 
bool testing::internal::ParseInt32 (const Message &src_text, const char *str, Int32 *value)
 
bool testing::internal::BoolFromGTestEnv (const char *flag, bool default_val)
 
GTEST_API_ Int32 testing::internal::Int32FromGTestEnv (const char *flag, Int32 default_val)
 
std::string testing::internal::OutputFlagAlsoCheckEnvVar ()
 
const char * testing::internal::StringFromGTestEnv (const char *flag, const char *default_val)
 

Variables

const BiggestInt testing::internal::kMaxBiggestInt
 

Macro Definition Documentation

#define GTEST_DEV_EMAIL_   "googletestframework@@googlegroups.com"
#define GTEST_FLAG_PREFIX_DASH_   "gtest-"
#define GTEST_FLAG_PREFIX_UPPER_   "GTEST_"
#define GTEST_PROJECT_URL_   "https://github.com/google/googletest/"
#define GTEST_INIT_GOOGLE_TEST_NAME_   "testing::InitGoogleTest"
#define GTEST_HAS_POSIX_RE   (!GTEST_OS_WINDOWS)
#define GTEST_USES_POSIX_RE   1

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

#define GTEST_HAS_EXCEPTIONS   0
#define GTEST_HAS_STD_STRING   1
#define GTEST_HAS_STD_WSTRING
Value:
(!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
GTEST_OS_HAIKU))
#define GTEST_HAS_RTTI   1
#define GTEST_HAS_PTHREAD
Value:
(GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD || \
GTEST_OS_HAIKU)

Referenced by if().

#define GTEST_HAS_CLONE   0
#define GTEST_HAS_STREAM_REDIRECTION   1
#define GTEST_WIDE_STRING_USES_UTF16_   (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2)
#define GTEST_AMBIGUOUS_ELSE_BLOCKER_   switch (0) case 0: default:
static bool dummy2 GTEST_ATTRIBUTE_UNUSED_
Value:
=
StaticAssertTypeEq<const int, const int>()

Referenced by GTEST_DISABLE_MSC_WARNINGS_PUSH_(), and testing::ScopedTrace::ScopedTrace().

#define GTEST_ATTRIBUTE_PRINTF_ (   string_index,
  first_to_check 
)
#define GTEST_DISALLOW_COPY_AND_ASSIGN_ (   type)
Value:
type(type const &) = delete; \
#define GTEST_DISALLOW_ASSIGN_(type)
Definition: gtest-port.h:683
type
Definition: upload.py:443

Referenced by testing::internal::CheckedDowncastToActualType(), testing::internal::ParameterizedTestFactory< TestClass >::CreateTest(), testing::internal::TestMetaFactory< TestSuite >::CreateTestFactory(), testing::gmock_nice_strict_test::MockFoo::Delete(), testing::DefaultValue< T >::Get(), testing::internal::GTestLog::GetStream(), testing::internal::ParameterizedTestSuiteRegistry::GetTestCasePatternHolder(), testing::internal::GetThreadCount(), GTEST_DISABLE_MSC_WARNINGS_PUSH_(), testing::Test::HasFailure(), Mock::Mock(), testing::gmock_function_mocker_test::MockB::MockB(), testing::gmock_generated_function_mockers_test::MockB::MockB(), MockFoo::MockFoo(), testing::gmock_function_mocker_test::MockFoo::MockFoo(), testing::gmock_generated_function_mockers_test::MockFoo::MockFoo(), testing::gmock_function_mocker_test::MockStack< T >::MockStack(), testing::gmock_generated_function_mockers_test::MockStack< T >::MockStack(), SequenceTestingListener::OnTestIterationEnd(), testing::internal::ReturnAction< R >::operator Action< F >(), testing::internal::ParameterizedTestSuiteInfoBase::ParameterizedTestSuiteInfoBase(), testing::internal::ParameterizedTestSuiteInfo< TestSuite >::RegisterTests(), testing::internal::Random::Reseed(), testing::ScopedTrace::ScopedTrace(), testing::internal::TestEventRepeater::set_forwarding_enabled(), testing::internal::ExpectationTester::SetCallCount(), testing::gmock_nice_strict_test::MockBar::str(), TestGenerationEnvironment< kExpectedCalls >::TearDown(), testing::gmock_function_mocker_test::TEST(), testing::gmock_generated_function_mockers_test::TEST(), TEST(), testing::internal::TEST(), testing::internal::TestFactoryBase::TestFactoryBase(), testing::ActionInterface< F >::~ActionInterface(), testing::internal::GTestLog::~GTestLog(), testing::NaggyMock< MockFoo >::~NaggyMock(), testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile(), and testing::StrictMock< MockClass >::~StrictMock().

#define GTEST_MUST_USE_RESULT_

Referenced by testing::RegisterTest().

#define GTEST_HAS_SEH   0
#define GTEST_IS_THREADSAFE
Value:
(GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \
(GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \
#define GTEST_HAS_PTHREAD
Definition: gtest-port.h:538
#define GTEST_DEFAULT_DEATH_TEST_STYLE   "fast"
#define GTEST_NO_INLINE_
#define GTEST_HAS_CXXABI_H_   0
#define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
#define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
#define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
#define GTEST_ARRAY_SIZE_ (   array)    (sizeof(array) / sizeof(array[0]))
#define GTEST_CHECK_ (   condition)
Value:
; \
GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
GTEST_API_ bool IsTrue(bool condition)
Definition: gtest.cc:5653
#define GTEST_LOG_(severity)
Definition: gtest-port.h:990
cmake hermetic_build cmake OPTIONAL if(COMMAND pre_project_set_up_hermetic_build) pre_project_set_up_hermetic_build() endif() if(CMAKE_VERSION VERSION_LESS 3.0) project(gmock CXX C) else() cmake_policy(SET CMP0048 NEW) project(gmock VERSION $
Definition: CMakeLists.txt:23

Referenced by testing::ArrayAsVector(), testing::internal::CheckedDowncastToActualType(), testing::internal::MaxBipartiteMatchState::Compute(), testing::internal::DownCast_(), testing::internal::RangeGenerator< T, IncrementT >::End(), testing::internal::ValuesInIteratorRangeGenerator< T >::End(), testing::internal::CartesianProductGenerator< T >::End(), testing::internal::FormatEpochTimeInMillisAsIso8601(), testing::internal::Random::Generate(), testing::WithParamInterface< MyEnums >::GetParam(), testing::internal::SuiteApiResolver< T >::GetSetUpCaseOrSuite(), testing::internal::SuiteApiResolver< T >::GetTearDownCaseOrSuite(), testing::internal::GetThreadCount(), GTEST_DISABLE_MSC_WARNINGS_PUSH_(), main(), testing::internal::JsonUnitTestResultPrinter::OnTestIterationEnd(), testing::internal::ReturnAction< R >::operator Action< F >(), testing::internal::JsonUnitTestResultPrinter::PrintJsonTestList(), testing::internal::ParameterizedTestSuiteInfo< TestSuite >::RegisterTests(), testing::internal::TEST(), TEST(), and testing::internal::GTestLog::~GTestLog().

#define GTEST_CHECK_POSIX_SUCCESS_ (   posix_call)
Value:
if (const int gtest_error = (posix_call)) \
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
<< gtest_error
#define GTEST_LOG_(severity)
Definition: gtest-port.h:990

Referenced by testing::internal::CheckedDowncastToActualType(), and testing::internal::TEST().

#define GTEST_ADD_REFERENCE_ (   T)    typename ::testing::internal::AddReference<T>::type
#define GTEST_REFERENCE_TO_CONST_ (   T)    typename ::testing::internal::ConstRef<T>::type
#define GTEST_DECLARE_STATIC_MUTEX_ (   mutex)    extern ::testing::internal::Mutex mutex
#define GTEST_DEFINE_STATIC_MUTEX_ (   mutex)    ::testing::internal::Mutex mutex
#define GTEST_PATH_SEP_   "/"
#define GTEST_HAS_ALT_PATH_SEP_   0
#define GTEST_SNPRINTF_   snprintf
#define GTEST_USE_OWN_FLAGFILE_FLAG_   1
#define GTEST_FLAG_SAVER_   ::testing::internal::GTestFlagSaver
#define GTEST_DECLARE_bool_ (   name)    GTEST_API_ extern bool GTEST_FLAG(name)
#define GTEST_DECLARE_int32_ (   name)    GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
#define GTEST_DECLARE_string_ (   name)    GTEST_API_ extern ::std::string GTEST_FLAG(name)
#define GTEST_DEFINE_bool_ (   name,
  default_val,
  doc 
)    GTEST_API_ bool GTEST_FLAG(name) = (default_val)
#define GTEST_DEFINE_int32_ (   name,
  default_val,
  doc 
)    GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
#define GTEST_DEFINE_string_ (   name,
  default_val,
  doc 
)    GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
#define GTEST_EXCLUSIVE_LOCK_REQUIRED_ (   locks)
#define GTEST_INTERNAL_DEPRECATED (   message)