45 #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
46 #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
271 #if defined(_MSVC_LANG)
272 #define GTEST_INTERNAL_CPLUSPLUS_LANG _MSVC_LANG
273 #elif defined(__cplusplus)
274 #define GTEST_INTERNAL_CPLUSPLUS_LANG __cplusplus
277 #if !defined(GTEST_INTERNAL_CPLUSPLUS_LANG) || \
278 GTEST_INTERNAL_CPLUSPLUS_LANG < 201402L
279 #error C++ versions less than C++14 are not supported.
284 #define GTEST_INTERNAL_HAS_INCLUDE __has_include
286 #define GTEST_INTERNAL_HAS_INCLUDE(...) 0
291 #if GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L && \
292 (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE(<version>))
294 #elif (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE(<ciso646>))
315 #include <type_traits>
319 #include <sys/stat.h>
320 #include <sys/types.h>
321 #endif // !_WIN32_WCE
323 #if defined __APPLE__
324 #include <AvailabilityMacros.h>
325 #include <TargetConditionals.h>
331 #ifndef GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
332 #define GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ 0
335 #ifndef GTEST_HAS_NOTIFICATION_
336 #define GTEST_HAS_NOTIFICATION_ 0
339 #if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
340 #define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file.
341 #include "absl/flags/declare.h"
342 #include "absl/flags/flag.h"
343 #include "absl/flags/reflection.h"
346 #if !defined(GTEST_DEV_EMAIL_)
347 #define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
348 #define GTEST_FLAG_PREFIX_ "gtest_"
349 #define GTEST_FLAG_PREFIX_DASH_ "gtest-"
350 #define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
351 #define GTEST_NAME_ "Google Test"
352 #define GTEST_PROJECT_URL_ "https://github.com/google/googletest/"
353 #endif // !defined(GTEST_DEV_EMAIL_)
355 #if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
356 #define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest"
357 #endif // !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
362 #define GTEST_GCC_VER_ \
363 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
371 #if defined(_MSC_VER)
372 #define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
373 __pragma(warning(push)) __pragma(warning(disable : warnings))
374 #define GTEST_DISABLE_MSC_WARNINGS_POP_() __pragma(warning(pop))
377 #define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
378 #define GTEST_DISABLE_MSC_WARNINGS_POP_()
384 #define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
385 _Pragma("clang diagnostic push") \
386 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
387 _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
388 #define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
390 #define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
391 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
392 #define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
398 #ifdef GTEST_OS_WINDOWS
399 #ifndef GTEST_OS_WINDOWS_MOBILE
404 #if defined(GTEST_OS_WINDOWS_MINGW) && !defined(__MINGW64_VERSION_MAJOR)
407 typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
412 typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
414 #elif defined(GTEST_OS_XTENSA)
424 #endif // GTEST_OS_WINDOWS
426 #ifdef GTEST_OS_LINUX_ANDROID
428 #include <android/api-level.h>
433 #ifndef GTEST_HAS_POSIX_RE
434 #ifdef GTEST_OS_LINUX_ANDROID
436 #define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
438 #if !(defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_XTENSA) || \
439 defined(GTEST_OS_QURT))
440 #define GTEST_HAS_POSIX_RE 1
442 #define GTEST_HAS_POSIX_RE 0
444 #endif // GTEST_OS_LINUX_ANDROID
448 #ifdef GTEST_HAS_ABSL
450 #include "absl/strings/string_view.h"
452 #define GTEST_USES_RE2 1
453 #elif GTEST_HAS_POSIX_RE
455 #define GTEST_USES_POSIX_RE 1
458 #define GTEST_USES_SIMPLE_RE 1
461 #ifndef GTEST_HAS_EXCEPTIONS
464 #if defined(_MSC_VER) && defined(_CPPUNWIND)
466 #define GTEST_HAS_EXCEPTIONS 1
467 #elif defined(__BORLANDC__)
471 #ifndef _HAS_EXCEPTIONS
472 #define _HAS_EXCEPTIONS 1
473 #endif // _HAS_EXCEPTIONS
474 #define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
475 #elif defined(__clang__)
484 #if defined(__EXCEPTIONS) && __EXCEPTIONS && __has_feature(cxx_exceptions)
485 #define GTEST_HAS_EXCEPTIONS 1
487 #define GTEST_HAS_EXCEPTIONS 0
489 #elif defined(__GNUC__) && defined(__EXCEPTIONS) && __EXCEPTIONS
491 #define GTEST_HAS_EXCEPTIONS 1
492 #elif defined(__SUNPRO_CC)
496 #define GTEST_HAS_EXCEPTIONS 1
497 #elif defined(__IBMCPP__) && defined(__EXCEPTIONS) && __EXCEPTIONS
499 #define GTEST_HAS_EXCEPTIONS 1
500 #elif defined(__HP_aCC)
503 #define GTEST_HAS_EXCEPTIONS 1
507 #define GTEST_HAS_EXCEPTIONS 0
508 #endif // defined(_MSC_VER) || defined(__BORLANDC__)
509 #endif // GTEST_HAS_EXCEPTIONS
511 #ifndef GTEST_HAS_STD_WSTRING
517 #if (!(defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_CYGWIN) || \
518 defined(GTEST_OS_SOLARIS) || defined(GTEST_OS_HAIKU) || \
519 defined(GTEST_OS_ESP32) || defined(GTEST_OS_ESP8266) || \
520 defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) || \
521 defined(GTEST_OS_NXP_QN9090) || defined(GTEST_OS_NRF52)))
522 #define GTEST_HAS_STD_WSTRING 1
524 #define GTEST_HAS_STD_WSTRING 0
526 #endif // GTEST_HAS_STD_WSTRING
528 #ifndef GTEST_HAS_FILE_SYSTEM
530 #define GTEST_HAS_FILE_SYSTEM 1
531 #endif // GTEST_HAS_FILE_SYSTEM
534 #ifndef GTEST_HAS_RTTI
540 #ifdef _CPPRTTI // MSVC defines this macro if and only if RTTI is enabled.
541 #define GTEST_HAS_RTTI 1
543 #define GTEST_HAS_RTTI 0
548 #elif defined(__GNUC__)
555 #if defined(GTEST_OS_LINUX_ANDROID) && defined(_STLPORT_MAJOR) && \
556 !defined(__EXCEPTIONS)
557 #define GTEST_HAS_RTTI 0
559 #define GTEST_HAS_RTTI 1
560 #endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS
562 #define GTEST_HAS_RTTI 0
568 #elif defined(__clang__)
570 #define GTEST_HAS_RTTI __has_feature(cxx_rtti)
574 #elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
577 #define GTEST_HAS_RTTI 1
579 #define GTEST_HAS_RTTI 0
585 #define GTEST_HAS_RTTI 1
589 #endif // GTEST_HAS_RTTI
598 #ifndef GTEST_HAS_PTHREAD
604 #if (defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || \
605 defined(GTEST_OS_HPUX) || defined(GTEST_OS_QNX) || \
606 defined(GTEST_OS_FREEBSD) || defined(GTEST_OS_NACL) || \
607 defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \
608 defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \
609 defined(GTEST_OS_OPENBSD) || defined(GTEST_OS_HAIKU) || \
610 defined(GTEST_OS_GNU_HURD) || defined(GTEST_OS_SOLARIS) || \
611 defined(GTEST_OS_AIX) || defined(GTEST_OS_ZOS))
612 #define GTEST_HAS_PTHREAD 1
614 #define GTEST_HAS_PTHREAD 0
616 #endif // GTEST_HAS_PTHREAD
618 #if GTEST_HAS_PTHREAD
631 #ifndef GTEST_HAS_CLONE
634 #if defined(GTEST_OS_LINUX) && !defined(__ia64__)
635 #if defined(GTEST_OS_LINUX_ANDROID)
638 #if defined(__LP64__) || (defined(__arm__) && __ANDROID_API__ >= 9) || \
639 (defined(__mips__) && __ANDROID_API__ >= 12) || \
640 (defined(__i386__) && __ANDROID_API__ >= 17)
641 #define GTEST_HAS_CLONE 1
643 #define GTEST_HAS_CLONE 0
646 #define GTEST_HAS_CLONE 1
649 #define GTEST_HAS_CLONE 0
650 #endif // GTEST_OS_LINUX && !defined(__ia64__)
652 #endif // GTEST_HAS_CLONE
656 #ifndef GTEST_HAS_STREAM_REDIRECTION
660 #if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
661 defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_WINDOWS_GAMES) || \
662 defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
663 defined(GTEST_OS_QURT) || !GTEST_HAS_FILE_SYSTEM
664 #define GTEST_HAS_STREAM_REDIRECTION 0
666 #define GTEST_HAS_STREAM_REDIRECTION 1
667 #endif // !GTEST_OS_WINDOWS_MOBILE
668 #endif // GTEST_HAS_STREAM_REDIRECTION
672 #if (defined(GTEST_OS_LINUX) || defined(GTEST_OS_CYGWIN) || \
673 defined(GTEST_OS_SOLARIS) || defined(GTEST_OS_ZOS) || \
674 (defined(GTEST_OS_MAC) && !defined(GTEST_OS_IOS)) || \
675 (defined(GTEST_OS_WINDOWS_DESKTOP) && _MSC_VER) || \
676 defined(GTEST_OS_WINDOWS_MINGW) || defined(GTEST_OS_AIX) || \
677 defined(GTEST_OS_HPUX) || defined(GTEST_OS_OPENBSD) || \
678 defined(GTEST_OS_QNX) || defined(GTEST_OS_FREEBSD) || \
679 defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \
680 defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \
681 defined(GTEST_OS_HAIKU) || defined(GTEST_OS_GNU_HURD))
683 #if GTEST_HAS_FILE_SYSTEM
684 #define GTEST_HAS_DEATH_TEST 1
685 #endif // GTEST_HAS_FILE_SYSTEM
692 #if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \
693 defined(__IBMCPP__) || defined(__HP_aCC)
694 #define GTEST_HAS_TYPED_TEST 1
695 #define GTEST_HAS_TYPED_TEST_P 1
699 #if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_CYGWIN) || \
700 defined(GTEST_OS_AIX) || defined(GTEST_OS_OS2)
701 #define GTEST_WIDE_STRING_USES_UTF16_ 1
703 #define GTEST_WIDE_STRING_USES_UTF16_ 0
707 #if defined(GTEST_OS_LINUX) || defined(GTEST_OS_GNU_KFREEBSD) || \
708 defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
709 defined(GTEST_OS_NETBSD) || defined(GTEST_OS_OPENBSD) || \
710 defined(GTEST_OS_GNU_HURD) || defined(GTEST_OS_MAC)
711 #define GTEST_CAN_STREAM_RESULTS_ 1
713 #define GTEST_CAN_STREAM_RESULTS_ 0
726 #ifdef __INTEL_COMPILER
727 #define GTEST_AMBIGUOUS_ELSE_BLOCKER_
729 #define GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
745 #ifdef __has_attribute
746 #define GTEST_HAVE_ATTRIBUTE_(x) __has_attribute(x)
748 #define GTEST_HAVE_ATTRIBUTE_(x) 0
757 #if defined(__has_cpp_attribute)
760 #define GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
762 #define GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(x) 0
770 #define GTEST_HAVE_FEATURE_(x) __has_feature(x)
772 #define GTEST_HAVE_FEATURE_(x) 0
783 #if GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(maybe_unused)
784 #define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]]
785 #elif GTEST_HAVE_ATTRIBUTE_(unused)
789 #define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED __attribute__((__unused__))
791 #define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED
795 #if GTEST_HAVE_ATTRIBUTE_(format) && defined(__MINGW_PRINTF_FORMAT)
799 #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
800 __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
801 #elif GTEST_HAVE_ATTRIBUTE_(format)
802 #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
803 __attribute__((format(printf, string_index, first_to_check)))
805 #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
813 #if GTEST_HAVE_ATTRIBUTE_(warn_unused_result)
814 #define GTEST_MUST_USE_RESULT_ __attribute__((warn_unused_result))
816 #define GTEST_MUST_USE_RESULT_
827 #define GTEST_INTENTIONAL_CONST_COND_PUSH_() \
828 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)
829 #define GTEST_INTENTIONAL_CONST_COND_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
834 #ifndef GTEST_HAS_SEH
837 #if defined(_MSC_VER) || defined(__BORLANDC__)
839 #define GTEST_HAS_SEH 1
842 #define GTEST_HAS_SEH 0
845 #endif // GTEST_HAS_SEH
847 #ifndef GTEST_IS_THREADSAFE
849 #if (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \
850 (defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && \
851 !defined(GTEST_OS_WINDOWS_RT)) || \
853 #define GTEST_IS_THREADSAFE 1
856 #endif // GTEST_IS_THREADSAFE
858 #ifdef GTEST_IS_THREADSAFE
860 #include <condition_variable>
862 #endif // GTEST_IS_THREADSAFE
870 #if defined(GTEST_LINKED_AS_SHARED_LIBRARY) && GTEST_LINKED_AS_SHARED_LIBRARY
871 #define GTEST_API_ __declspec(dllimport)
872 #elif defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY
873 #define GTEST_API_ __declspec(dllexport)
875 #elif GTEST_HAVE_ATTRIBUTE_(visibility)
876 #define GTEST_API_ __attribute__((visibility("default")))
885 #ifndef GTEST_DEFAULT_DEATH_TEST_STYLE
886 #define GTEST_DEFAULT_DEATH_TEST_STYLE "fast"
887 #endif // GTEST_DEFAULT_DEATH_TEST_STYLE
889 #if GTEST_HAVE_ATTRIBUTE_(noinline)
891 #define GTEST_NO_INLINE_ __attribute__((noinline))
893 #define GTEST_NO_INLINE_
896 #if GTEST_HAVE_ATTRIBUTE_(disable_tail_calls)
899 #define GTEST_NO_TAIL_CALL_ __attribute__((disable_tail_calls))
900 #elif defined(__GNUC__) && !defined(__NVCOMPILER)
901 #define GTEST_NO_TAIL_CALL_ \
902 __attribute__((optimize("no-optimize-sibling-calls")))
904 #define GTEST_NO_TAIL_CALL_
908 #if !defined(GTEST_HAS_CXXABI_H_)
909 #if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))
910 #define GTEST_HAS_CXXABI_H_ 1
912 #define GTEST_HAS_CXXABI_H_ 0
918 #if GTEST_HAVE_ATTRIBUTE_(no_sanitize_memory)
919 #define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ __attribute__((no_sanitize_memory))
921 #define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
925 #if GTEST_HAVE_ATTRIBUTE_(no_sanitize_address)
926 #define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
927 __attribute__((no_sanitize_address))
929 #define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
933 #if GTEST_HAVE_FEATURE_(hwaddress_sanitizer) && \
934 GTEST_HAVE_ATTRIBUTE_(no_sanitize)
935 #define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \
936 __attribute__((no_sanitize("hwaddress")))
938 #define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
942 #if GTEST_HAVE_ATTRIBUTE_(no_sanitize_thread)
943 #define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ __attribute((no_sanitize_thread))
945 #define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
955 using std::make_tuple;
957 using std::tuple_element;
958 using std::tuple_size;
975 #ifdef GTEST_USES_RE2
982 RE(absl::string_view regex) : regex_(regex) {}
983 RE(
const char* regex) : RE(absl::string_view(regex)) {}
984 RE(
const std::string& regex) : RE(absl::string_view(regex)) {}
985 RE(
const RE& other) : RE(other.pattern()) {}
987 const std::string& pattern()
const {
return regex_.pattern(); }
989 static bool FullMatch(absl::string_view str,
const RE& re) {
990 return RE2::FullMatch(str, re.regex_);
992 static bool PartialMatch(absl::string_view str,
const RE& re) {
993 return RE2::PartialMatch(str, re.regex_);
1000 #elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_SIMPLE_RE)
1010 RE(
const RE& other) { Init(other.pattern()); }
1013 RE(const ::std::string& regex) { Init(regex.c_str()); }
1015 RE(
const char* regex) { Init(regex); }
1019 const char* pattern()
const {
return pattern_.c_str(); }
1025 static bool FullMatch(const ::std::string& str,
const RE& re) {
1026 return FullMatch(str.c_str(), re);
1028 static bool PartialMatch(const ::std::string& str,
const RE& re) {
1029 return PartialMatch(str.c_str(), re);
1032 static bool FullMatch(
const char* str,
const RE& re);
1033 static bool PartialMatch(
const char* str,
const RE& re);
1036 void Init(
const char* regex);
1037 std::string pattern_;
1040 #ifdef GTEST_USES_POSIX_RE
1042 regex_t full_regex_;
1043 regex_t partial_regex_;
1045 #else // GTEST_USES_SIMPLE_RE
1047 std::string full_pattern_;
1052 #endif // ::testing::internal::RE implementation
1091 #if !defined(GTEST_LOG_)
1093 #define GTEST_LOG_(severity) \
1094 ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
1095 __FILE__, __LINE__) \
1101 #endif // !defined(GTEST_LOG_)
1103 #if !defined(GTEST_CHECK_)
1118 #define GTEST_CHECK_(condition) \
1119 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1120 if (::testing::internal::IsTrue(condition)) \
1123 GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
1124 #endif // !defined(GTEST_CHECK_)
1131 #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
1132 if (const int gtest_error = (posix_call)) \
1133 GTEST_LOG_(FATAL) << #posix_call << "failed with error " << gtest_error
1146 template <
typename T>
1150 template <
typename T>
1156 #define GTEST_REFERENCE_TO_CONST_(T) \
1157 typename ::testing::internal::ConstRef<T>::type
1179 template <
typename To>
1189 template <
class Derived,
class Base>
1192 "target type not derived from source type");
1194 GTEST_CHECK_(base ==
nullptr || dynamic_cast<Derived*>(base) !=
nullptr);
1196 return static_cast<Derived*
>(base);
1199 #if GTEST_HAS_STREAM_REDIRECTION
1212 #endif // GTEST_HAS_STREAM_REDIRECTION
1222 #ifdef GTEST_HAS_DEATH_TEST
1224 std::vector<std::string> GetInjectableArgvs();
1226 void SetInjectableArgvs(
const std::vector<std::string>* new_argvs);
1227 void SetInjectableArgvs(
const std::vector<std::string>& new_argvs);
1228 void ClearInjectableArgvs();
1230 #endif // GTEST_HAS_DEATH_TEST
1233 #ifdef GTEST_IS_THREADSAFE
1235 #ifdef GTEST_OS_WINDOWS
1245 typedef void* Handle;
1247 explicit AutoHandle(Handle handle);
1253 void Reset(Handle handle);
1258 bool IsCloseable()
const;
1262 AutoHandle(
const AutoHandle&) =
delete;
1263 AutoHandle& operator=(
const AutoHandle&) =
delete;
1267 #if GTEST_HAS_NOTIFICATION_
1284 Notification() : notified_(
false) {}
1285 Notification(
const Notification&) =
delete;
1286 Notification& operator=(
const Notification&) =
delete;
1291 std::lock_guard<std::mutex> lock(mu_);
1298 void WaitForNotification() {
1299 std::unique_lock<std::mutex> lock(mu_);
1300 cv_.wait(lock, [
this]() {
return notified_; });
1305 std::condition_variable cv_;
1309 #endif // GTEST_HAS_NOTIFICATION_
1314 #if GTEST_HAS_PTHREAD && !defined(GTEST_OS_WINDOWS_MINGW)
1321 class ThreadWithParamBase {
1323 virtual ~ThreadWithParamBase() =
default;
1324 virtual void Run() = 0;
1333 extern "C" inline void* ThreadFuncWithCLinkage(
void* thread) {
1334 static_cast<ThreadWithParamBase*
>(thread)->Run();
1350 template <
typename T>
1351 class ThreadWithParam :
public ThreadWithParamBase {
1353 typedef void UserThreadFunc(
T);
1355 ThreadWithParam(UserThreadFunc*
func,
T param, Notification* thread_can_start)
1358 thread_can_start_(thread_can_start),
1360 ThreadWithParamBase*
const base =
this;
1364 pthread_create(&thread_,
nullptr, &ThreadFuncWithCLinkage, base));
1366 ~ThreadWithParam()
override { Join(); }
1375 void Run()
override {
1376 if (thread_can_start_ !=
nullptr) thread_can_start_->WaitForNotification();
1381 UserThreadFunc*
const func_;
1385 Notification*
const thread_can_start_;
1390 ThreadWithParam(
const ThreadWithParam&) =
delete;
1391 ThreadWithParam& operator=(
const ThreadWithParam&) =
delete;
1393 #endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
1396 #if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
1400 #elif defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && \
1401 !defined(GTEST_OS_WINDOWS_RT)
1419 enum MutexType { kStatic = 0, kDynamic = 1 };
1423 enum StaticConstructorSelector { kStaticMutex = 0 };
1428 explicit Mutex(StaticConstructorSelector ) {}
1443 void ThreadSafeLazyInit();
1447 unsigned int owner_thread_id_;
1452 long critical_section_init_phase_;
1453 GTEST_CRITICAL_SECTION* critical_section_;
1455 Mutex(
const Mutex&) =
delete;
1456 Mutex& operator=(
const Mutex&) =
delete;
1459 #define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1460 extern ::testing::internal::Mutex mutex
1462 #define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
1463 ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)
1470 class GTestMutexLock {
1472 explicit GTestMutexLock(Mutex* mutex) : mutex_(mutex) { mutex_->Lock(); }
1477 Mutex*
const mutex_;
1487 class ThreadLocalValueHolderBase {
1489 virtual ~ThreadLocalValueHolderBase() {}
1494 class ThreadLocalBase {
1500 virtual ThreadLocalValueHolderBase* NewValueForCurrentThread()
const = 0;
1503 ThreadLocalBase() {}
1504 virtual ~ThreadLocalBase() {}
1507 ThreadLocalBase(
const ThreadLocalBase&) =
delete;
1508 ThreadLocalBase& operator=(
const ThreadLocalBase&) =
delete;
1518 static ThreadLocalValueHolderBase* GetValueOnCurrentThread(
1519 const ThreadLocalBase* thread_local_instance);
1522 static void OnThreadLocalDestroyed(
1523 const ThreadLocalBase* thread_local_instance);
1533 virtual ~Runnable() {}
1534 virtual void Run() = 0;
1537 ThreadWithParamBase(Runnable* runnable, Notification* thread_can_start);
1538 virtual ~ThreadWithParamBase();
1545 template <
typename T>
1546 class ThreadWithParam :
public ThreadWithParamBase {
1548 typedef void UserThreadFunc(
T);
1550 ThreadWithParam(UserThreadFunc* func,
T param, Notification* thread_can_start)
1551 : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {}
1552 virtual ~ThreadWithParam() {}
1555 class RunnableImpl :
public Runnable {
1557 RunnableImpl(UserThreadFunc* func,
T param) : func_(func), param_(param) {}
1558 virtual ~RunnableImpl() {}
1559 virtual void Run() { func_(param_); }
1562 UserThreadFunc*
const func_;
1565 RunnableImpl(
const RunnableImpl&) =
delete;
1566 RunnableImpl& operator=(
const RunnableImpl&) =
delete;
1569 ThreadWithParam(
const ThreadWithParam&) =
delete;
1570 ThreadWithParam& operator=(
const ThreadWithParam&) =
delete;
1600 template <
typename T>
1601 class ThreadLocal :
public ThreadLocalBase {
1603 ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}
1605 : default_factory_(new InstanceValueHolderFactory(value)) {}
1607 ~
ThreadLocal()
override { ThreadLocalRegistry::OnThreadLocalDestroyed(
this); }
1609 T*
pointer() {
return GetOrCreateValue(); }
1610 const T*
pointer()
const {
return GetOrCreateValue(); }
1611 const T&
get()
const {
return *
pointer(); }
1617 class ValueHolder :
public ThreadLocalValueHolderBase {
1619 ValueHolder() :
value_() {}
1620 explicit ValueHolder(
const T&
value) :
value_(value) {}
1626 ValueHolder(
const ValueHolder&) =
delete;
1627 ValueHolder& operator=(
const ValueHolder&) =
delete;
1630 T* GetOrCreateValue()
const {
1631 return static_cast<ValueHolder*
>(
1632 ThreadLocalRegistry::GetValueOnCurrentThread(
this))
1636 ThreadLocalValueHolderBase* NewValueForCurrentThread()
const override {
1637 return default_factory_->MakeNewHolder();
1640 class ValueHolderFactory {
1642 ValueHolderFactory() {}
1643 virtual ~ValueHolderFactory() {}
1644 virtual ValueHolder* MakeNewHolder()
const = 0;
1647 ValueHolderFactory(
const ValueHolderFactory&) =
delete;
1648 ValueHolderFactory& operator=(
const ValueHolderFactory&) =
delete;
1651 class DefaultValueHolderFactory :
public ValueHolderFactory {
1653 DefaultValueHolderFactory() {}
1654 ValueHolder* MakeNewHolder()
const override {
return new ValueHolder(); }
1657 DefaultValueHolderFactory(
const DefaultValueHolderFactory&) =
delete;
1658 DefaultValueHolderFactory& operator=(
const DefaultValueHolderFactory&) =
1662 class InstanceValueHolderFactory :
public ValueHolderFactory {
1664 explicit InstanceValueHolderFactory(
const T&
value) :
value_(value) {}
1665 ValueHolder* MakeNewHolder()
const override {
1666 return new ValueHolder(
value_);
1672 InstanceValueHolderFactory(
const InstanceValueHolderFactory&) =
delete;
1673 InstanceValueHolderFactory& operator=(
const InstanceValueHolderFactory&) =
1677 std::unique_ptr<ValueHolderFactory> default_factory_;
1683 #elif GTEST_HAS_PTHREAD
1691 owner_ = pthread_self();
1707 void AssertHeld()
const {
1708 GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
1709 <<
"The current thread is not holding the mutex @" <<
this;
1718 pthread_mutex_t mutex_;
1730 #define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1731 extern ::testing::internal::MutexBase mutex
1739 #define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
1740 ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0}
1744 class Mutex :
public MutexBase {
1762 class GTestMutexLock {
1764 explicit GTestMutexLock(MutexBase* mutex) : mutex_(mutex) { mutex_->Lock(); }
1769 MutexBase*
const mutex_;
1783 class GTEST_API_ ThreadLocalValueHolderBase {
1785 virtual ~ThreadLocalValueHolderBase() =
default;
1790 extern "C" inline void DeleteThreadLocalValue(
void* value_holder) {
1791 delete static_cast<ThreadLocalValueHolderBase*
>(value_holder);
1795 template <
typename T>
1799 : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
1800 explicit ThreadLocal(
const T&
value)
1801 : key_(CreateKey()),
1802 default_factory_(new InstanceValueHolderFactory(value)) {}
1806 DeleteThreadLocalValue(pthread_getspecific(key_));
1813 T* pointer() {
return GetOrCreateValue(); }
1814 const T* pointer()
const {
return GetOrCreateValue(); }
1815 const T&
get()
const {
return *pointer(); }
1820 class ValueHolder :
public ThreadLocalValueHolderBase {
1822 ValueHolder() :
value_() {}
1823 explicit ValueHolder(
const T&
value) :
value_(value) {}
1825 T* pointer() {
return &
value_; }
1829 ValueHolder(
const ValueHolder&) =
delete;
1830 ValueHolder& operator=(
const ValueHolder&) =
delete;
1833 static pthread_key_t CreateKey() {
1838 pthread_key_create(&key, &DeleteThreadLocalValue));
1842 T* GetOrCreateValue()
const {
1843 ThreadLocalValueHolderBase*
const holder =
1844 static_cast<ThreadLocalValueHolderBase*
>(pthread_getspecific(key_));
1845 if (holder !=
nullptr) {
1846 return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
1849 ValueHolder*
const new_holder = default_factory_->MakeNewHolder();
1850 ThreadLocalValueHolderBase*
const holder_base = new_holder;
1852 return new_holder->pointer();
1855 class ValueHolderFactory {
1857 ValueHolderFactory() =
default;
1858 virtual ~ValueHolderFactory() =
default;
1859 virtual ValueHolder* MakeNewHolder()
const = 0;
1862 ValueHolderFactory(
const ValueHolderFactory&) =
delete;
1863 ValueHolderFactory& operator=(
const ValueHolderFactory&) =
delete;
1866 class DefaultValueHolderFactory :
public ValueHolderFactory {
1868 DefaultValueHolderFactory() =
default;
1869 ValueHolder* MakeNewHolder()
const override {
return new ValueHolder(); }
1872 DefaultValueHolderFactory(
const DefaultValueHolderFactory&) =
delete;
1873 DefaultValueHolderFactory& operator=(
const DefaultValueHolderFactory&) =
1877 class InstanceValueHolderFactory :
public ValueHolderFactory {
1879 explicit InstanceValueHolderFactory(
const T&
value) :
value_(value) {}
1880 ValueHolder* MakeNewHolder()
const override {
1881 return new ValueHolder(
value_);
1887 InstanceValueHolderFactory(
const InstanceValueHolderFactory&) =
delete;
1888 InstanceValueHolderFactory& operator=(
const InstanceValueHolderFactory&) =
1893 const pthread_key_t key_;
1894 std::unique_ptr<ValueHolderFactory> default_factory_;
1896 ThreadLocal(
const ThreadLocal&) =
delete;
1897 ThreadLocal& operator=(
const ThreadLocal&) =
delete;
1900 #endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
1902 #else // GTEST_IS_THREADSAFE
1917 #define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1918 extern ::testing::internal::Mutex mutex
1920 #define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
1934 template <
typename T>
1948 #endif // GTEST_IS_THREADSAFE
1954 #ifdef GTEST_OS_WINDOWS
1955 #define GTEST_PATH_SEP_ "\\"
1956 #define GTEST_HAS_ALT_PATH_SEP_ 1
1958 #define GTEST_PATH_SEP_ "/"
1959 #define GTEST_HAS_ALT_PATH_SEP_ 0
1960 #endif // GTEST_OS_WINDOWS
1970 return isalpha(static_cast<unsigned char>(ch)) != 0;
1973 return isalnum(static_cast<unsigned char>(ch)) != 0;
1976 return isdigit(static_cast<unsigned char>(ch)) != 0;
1979 return islower(static_cast<unsigned char>(ch)) != 0;
1982 return isspace(static_cast<unsigned char>(ch)) != 0;
1985 return isupper(static_cast<unsigned char>(ch)) != 0;
1988 return isxdigit(static_cast<unsigned char>(ch)) != 0;
1990 #ifdef __cpp_lib_char8_t
1992 return isxdigit(static_cast<unsigned char>(ch)) != 0;
1996 const unsigned char low_byte =
static_cast<unsigned char>(
ch);
1997 return ch == low_byte && isxdigit(low_byte) != 0;
2000 const unsigned char low_byte =
static_cast<unsigned char>(
ch);
2001 return ch == low_byte && isxdigit(low_byte) != 0;
2004 const unsigned char low_byte =
static_cast<unsigned char>(
ch);
2005 return ch == low_byte && isxdigit(low_byte) != 0;
2009 return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
2012 return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
2016 std::string::iterator it = str.end();
2017 while (it != str.begin() &&
IsSpace(*--it)) it = str.erase(it);
2033 #ifdef GTEST_OS_WINDOWS
2035 typedef struct _stat StatStruct;
2037 #ifdef GTEST_OS_WINDOWS_MOBILE
2038 inline int FileNo(FILE* file) {
return reinterpret_cast<int>(_fileno(file)); }
2042 inline int FileNo(FILE* file) {
return _fileno(file); }
2043 #if GTEST_HAS_FILE_SYSTEM
2044 inline int Stat(
const char* path, StatStruct* buf) {
return _stat(path, buf); }
2045 inline int RmDir(
const char* dir) {
return _rmdir(dir); }
2046 inline bool IsDir(
const StatStruct& st) {
return (_S_IFDIR & st.st_mode) != 0; }
2048 #endif // GTEST_OS_WINDOWS_MOBILE
2050 #elif defined(GTEST_OS_ESP8266)
2051 typedef struct stat StatStruct;
2053 inline int FileNo(FILE* file) {
return fileno(file); }
2054 #if GTEST_HAS_FILE_SYSTEM
2055 inline int Stat(
const char* path, StatStruct* buf) {
2059 inline int RmDir(
const char* dir) {
return rmdir(dir); }
2060 inline bool IsDir(
const StatStruct& st) {
return S_ISDIR(st.st_mode); }
2065 typedef struct stat StatStruct;
2067 inline int FileNo(FILE* file) {
return fileno(file); }
2068 #if GTEST_HAS_FILE_SYSTEM
2069 inline int Stat(
const char* path, StatStruct* buf) {
return stat(path, buf); }
2070 #ifdef GTEST_OS_QURT
2072 inline int RmDir(
const char*) {
return 0; }
2074 inline int RmDir(
const char* dir) {
return rmdir(dir); }
2076 inline bool IsDir(
const StatStruct& st) {
return S_ISDIR(st.st_mode); }
2079 #endif // GTEST_OS_WINDOWS
2083 #ifdef GTEST_OS_WINDOWS
2086 inline int DoIsATTY(
int fd) {
return isatty(fd); }
2087 inline int StrCaseCmp(
const char* s1,
const char* s2) {
2088 return stricmp(s1, s2);
2090 #else // !__BORLANDC__
2091 #if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_ZOS) || \
2092 defined(GTEST_OS_IOS) || defined(GTEST_OS_WINDOWS_PHONE) || \
2093 defined(GTEST_OS_WINDOWS_RT) || defined(ESP_PLATFORM)
2094 inline int DoIsATTY(
int ) {
return 0; }
2096 inline int DoIsATTY(
int fd) {
return _isatty(fd); }
2097 #endif // GTEST_OS_WINDOWS_MOBILE
2098 inline int StrCaseCmp(
const char* s1,
const char* s2) {
2099 return _stricmp(s1, s2);
2101 #endif // __BORLANDC__
2107 return strcasecmp(s1, s2);
2110 #endif // GTEST_OS_WINDOWS
2116 int savedErrno = errno;
2130 #if GTEST_HAS_FILE_SYSTEM
2131 #if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \
2132 !defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES) && \
2133 !defined(GTEST_OS_ESP8266) && !defined(GTEST_OS_XTENSA) && \
2134 !defined(GTEST_OS_QURT)
2135 inline int ChDir(
const char* dir) {
return chdir(dir); }
2137 inline FILE*
FOpen(
const char* path,
const char* mode) {
2138 #if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW)
2139 struct wchar_codecvt :
public std::codecvt<wchar_t, char, std::mbstate_t> {};
2140 std::wstring_convert<wchar_codecvt> converter;
2141 std::wstring wide_path = converter.from_bytes(path);
2142 std::wstring wide_mode = converter.from_bytes(mode);
2143 return _wfopen(wide_path.c_str(), wide_mode.c_str());
2144 #else // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
2145 return fopen(path, mode);
2146 #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
2148 #if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT)
2149 inline FILE*
FReopen(
const char* path,
const char* mode, FILE* stream) {
2150 return freopen(path, mode, stream);
2152 inline FILE*
FDOpen(
int fd,
const char* mode) {
return fdopen(fd, mode); }
2153 #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2154 inline int FClose(FILE* fp) {
return fclose(fp); }
2155 #if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT)
2157 return static_cast<int>(read(fd, buf, count));
2160 return static_cast<int>(write(fd, buf, count));
2162 inline int Close(
int fd) {
return close(fd); }
2163 #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2164 #endif // GTEST_HAS_FILE_SYSTEM
2166 #if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT)
2167 inline const char*
StrError(
int errnum) {
return strerror(errnum); }
2168 #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2170 inline const char*
GetEnv(
const char* name) {
2171 #if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
2172 defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
2173 defined(GTEST_OS_QURT)
2175 static_cast<void>(name);
2177 #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
2180 const char*
const env = getenv(name);
2181 return (env !=
nullptr && env[0] !=
'\0') ? env :
nullptr;
2183 return getenv(name);
2189 #ifdef GTEST_OS_WINDOWS_MOBILE
2193 [[noreturn]]
void Abort();
2195 [[noreturn]]
inline void Abort() { abort(); }
2196 #endif // GTEST_OS_WINDOWS_MOBILE
2205 #if defined(_MSC_VER) && !defined(GTEST_OS_WINDOWS_MOBILE)
2207 #define GTEST_SNPRINTF_(buffer, size, format, ...) \
2208 _snprintf_s(buffer, size, size, format, __VA_ARGS__)
2209 #elif defined(_MSC_VER)
2211 #define GTEST_SNPRINTF_ _snprintf
2213 #define GTEST_SNPRINTF_ snprintf
2242 template <
size_t size>
2272 #if !defined(GTEST_FLAG)
2273 #define GTEST_FLAG_NAME_(name) gtest_##name
2274 #define GTEST_FLAG(name) FLAGS_gtest_##name
2275 #endif // !defined(GTEST_FLAG)
2278 #ifdef GTEST_INTERNAL_HAS_ABSL_FLAGS
2281 #define GTEST_DEFINE_bool_(name, default_val, doc) \
2282 ABSL_FLAG(bool, GTEST_FLAG_NAME_(name), default_val, doc)
2283 #define GTEST_DEFINE_int32_(name, default_val, doc) \
2284 ABSL_FLAG(int32_t, GTEST_FLAG_NAME_(name), default_val, doc)
2285 #define GTEST_DEFINE_string_(name, default_val, doc) \
2286 ABSL_FLAG(std::string, GTEST_FLAG_NAME_(name), default_val, doc)
2289 #define GTEST_DECLARE_bool_(name) \
2290 ABSL_DECLARE_FLAG(bool, GTEST_FLAG_NAME_(name))
2291 #define GTEST_DECLARE_int32_(name) \
2292 ABSL_DECLARE_FLAG(int32_t, GTEST_FLAG_NAME_(name))
2293 #define GTEST_DECLARE_string_(name) \
2294 ABSL_DECLARE_FLAG(std::string, GTEST_FLAG_NAME_(name))
2296 #define GTEST_FLAG_SAVER_ ::absl::FlagSaver
2298 #define GTEST_FLAG_GET(name) ::absl::GetFlag(GTEST_FLAG(name))
2299 #define GTEST_FLAG_SET(name, value) \
2300 (void)(::absl::SetFlag(>EST_FLAG(name), value))
2301 #define GTEST_USE_OWN_FLAGFILE_FLAG_ 0
2303 #undef GTEST_INTERNAL_HAS_ABSL_FLAGS
2304 #else // ndef GTEST_INTERNAL_HAS_ABSL_FLAGS
2307 #define GTEST_DEFINE_bool_(name, default_val, doc) \
2308 namespace testing { \
2309 GTEST_API_ bool GTEST_FLAG(name) = (default_val); \
2311 static_assert(true, "no-op to require trailing semicolon")
2312 #define GTEST_DEFINE_int32_(name, default_val, doc) \
2313 namespace testing { \
2314 GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val); \
2316 static_assert(true, "no-op to require trailing semicolon")
2317 #define GTEST_DEFINE_string_(name, default_val, doc) \
2318 namespace testing { \
2319 GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val); \
2321 static_assert(true, "no-op to require trailing semicolon")
2324 #define GTEST_DECLARE_bool_(name) \
2325 namespace testing { \
2326 GTEST_API_ extern bool GTEST_FLAG(name); \
2328 static_assert(true, "no-op to require trailing semicolon")
2329 #define GTEST_DECLARE_int32_(name) \
2330 namespace testing { \
2331 GTEST_API_ extern std::int32_t GTEST_FLAG(name); \
2333 static_assert(true, "no-op to require trailing semicolon")
2334 #define GTEST_DECLARE_string_(name) \
2335 namespace testing { \
2336 GTEST_API_ extern ::std::string GTEST_FLAG(name); \
2338 static_assert(true, "no-op to require trailing semicolon")
2340 #define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
2342 #define GTEST_FLAG_GET(name) ::testing::GTEST_FLAG(name)
2343 #define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value)
2344 #define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
2346 #endif // GTEST_INTERNAL_HAS_ABSL_FLAGS
2349 #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
2350 #define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
2351 #define GTEST_LOCK_EXCLUDED_(locks)
2352 #endif // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
2370 #if !defined(GTEST_INTERNAL_DEPRECATED)
2380 #if defined(_MSC_VER)
2381 #define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message))
2382 #elif defined(__GNUC__)
2383 #define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message)))
2385 #define GTEST_INTERNAL_DEPRECATED(message)
2388 #endif // !defined(GTEST_INTERNAL_DEPRECATED)
2390 #ifdef GTEST_HAS_ABSL
2393 #define GTEST_INTERNAL_HAS_ANY 1
2394 #include "absl/types/any.h"
2396 namespace internal {
2397 using Any = ::absl::any;
2401 #if defined(__cpp_lib_any) || (GTEST_INTERNAL_HAS_INCLUDE(<any>) && \
2402 GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
2403 (!defined(_MSC_VER) || GTEST_HAS_RTTI))
2406 #define GTEST_INTERNAL_HAS_ANY 1
2409 namespace internal {
2410 using Any = ::std::any;
2415 #endif // __cpp_lib_any
2416 #endif // GTEST_HAS_ABSL
2418 #ifndef GTEST_INTERNAL_HAS_ANY
2419 #define GTEST_INTERNAL_HAS_ANY 0
2422 #ifdef GTEST_HAS_ABSL
2425 #define GTEST_INTERNAL_HAS_OPTIONAL 1
2426 #include "absl/types/optional.h"
2428 namespace internal {
2429 template <
typename T>
2430 using Optional = ::absl::optional<T>;
2431 inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; }
2435 #if defined(__cpp_lib_optional) || (GTEST_INTERNAL_HAS_INCLUDE(<optional>) && \
2436 GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
2439 #define GTEST_INTERNAL_HAS_OPTIONAL 1
2442 namespace internal {
2443 template <
typename T>
2444 using Optional = ::std::optional<T>;
2445 inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
2450 #endif // __cpp_lib_optional
2451 #endif // GTEST_HAS_ABSL
2453 #ifndef GTEST_INTERNAL_HAS_OPTIONAL
2454 #define GTEST_INTERNAL_HAS_OPTIONAL 0
2457 #if defined(__cpp_lib_span) || (GTEST_INTERNAL_HAS_INCLUDE(<span>) && \
2458 GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L)
2459 #define GTEST_INTERNAL_HAS_STD_SPAN 1
2460 #endif // __cpp_lib_span
2462 #ifndef GTEST_INTERNAL_HAS_STD_SPAN
2463 #define GTEST_INTERNAL_HAS_STD_SPAN 0
2466 #ifdef GTEST_HAS_ABSL
2469 #define GTEST_INTERNAL_HAS_STRING_VIEW 1
2470 #include "absl/strings/string_view.h"
2472 namespace internal {
2473 using StringView = ::absl::string_view;
2477 #if defined(__cpp_lib_string_view) || \
2478 (GTEST_INTERNAL_HAS_INCLUDE(<string_view>) && \
2479 GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
2482 #define GTEST_INTERNAL_HAS_STRING_VIEW 1
2483 #include <string_view>
2485 namespace internal {
2486 using StringView = ::std::string_view;
2491 #endif // __cpp_lib_string_view
2492 #endif // GTEST_HAS_ABSL
2494 #ifndef GTEST_INTERNAL_HAS_STRING_VIEW
2495 #define GTEST_INTERNAL_HAS_STRING_VIEW 0
2498 #ifdef GTEST_HAS_ABSL
2501 #define GTEST_INTERNAL_HAS_VARIANT 1
2502 #include "absl/types/variant.h"
2504 namespace internal {
2505 template <
typename...
T>
2506 using Variant = ::absl::variant<
T...>;
2510 #if defined(__cpp_lib_variant) || (GTEST_INTERNAL_HAS_INCLUDE(<variant>) && \
2511 GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
2514 #define GTEST_INTERNAL_HAS_VARIANT 1
2517 namespace internal {
2518 template <
typename...
T>
2519 using Variant = ::std::variant<
T...>;
2523 #endif // __cpp_lib_variant
2524 #endif // GTEST_HAS_ABSL
2526 #ifndef GTEST_INTERNAL_HAS_VARIANT
2527 #define GTEST_INTERNAL_HAS_VARIANT 0
2530 #if (defined(__cpp_constexpr) && !defined(__cpp_inline_variables)) || \
2531 (defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
2532 GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L)
2533 #define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
2536 #if (defined(__cpp_lib_three_way_comparison) || \
2537 (GTEST_INTERNAL_HAS_INCLUDE(<compare>) && \
2538 GTEST_INTERNAL_CPLUSPLUS_LANG >= 201907L))
2539 #define GTEST_INTERNAL_HAS_COMPARE_LIB 1
2541 #define GTEST_INTERNAL_HAS_COMPARE_LIB 0
2544 #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
FILE * FReopen(const char *path, const char *mode, FILE *stream)
GTEST_API_ bool IsTrue(bool condition)
GTEST_API_ int32_t Int32FromGTestEnv(const char *flag, int32_t default_val)
GTEST_API_ std::string GetCapturedStdout()
GTEST_API_ std::string GetCapturedStderr()
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
const T * pointer() const
const char * StringFromGTestEnv(const char *flag, const char *default_val)
constexpr BiggestInt kMaxBiggestInt
GTEST_API_ size_t GetThreadCount()
int Stat(const char *path, StatStruct *buf)
int ChDir(const char *dir)
const char * GetEnv(const char *name)
GTEST_API_ void CaptureStdout()
#define GTEST_DISABLE_MSC_DEPRECATED_POP_()
GTEST_API_ std::vector< std::string > GetArgvs()
GTEST_API_ std::string ReadEntireFile(FILE *file)
GTEST_API_ bool ParseInt32(const Message &src_text, const char *str, int32_t *value)
GTEST_API_::std::string FormatFileLocation(const char *file, int line)
int Write(int fd, const void *buf, unsigned int count)
::std::ostream & GetStream()
const GTestLogSeverity severity_
int RmDir(const char *dir)
#define GTEST_CHECK_(condition)
GTEST_API_ size_t GetFileSize(FILE *file)
Secret(const Secret &)=delete
int Read(int fd, void *buf, unsigned int count)
ThreadLocal(const T &value)
GTEST_DISABLE_MSC_WARNINGS_POP_() inline const char *SkipComma(const char *str)
int StrCaseCmp(const char *s1, const char *s2)
bool IsDir(const StatStruct &st)
#define GTEST_CHECK_POSIX_SUCCESS_(posix_call)
GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_API_ GTEST_API_::std::string FormatCompilerIndependentFileLocation(const char *file, int line)
bool BoolFromGTestEnv(const char *flag, bool default_val)
FILE * FOpen(const char *path, const char *mode)
GTEST_API_ void CaptureStderr()
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251) class GTEST_API_ TypedTestSuitePState
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
const T func(int n, T *x)
FILE * FDOpen(int fd, const char *mode)
const char * StrError(int errnum)
Derived * CheckedDowncastToActualType(Base *base)
std::string OutputFlagAlsoCheckEnvVar()
std::string StripTrailingSpaces(std::string str)