mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
ThirdParty: Update included gtest
This commit is contained in:
+268
-173
@@ -40,8 +40,8 @@
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
|
||||
// Environment-describing macros
|
||||
// -----------------------------
|
||||
@@ -190,23 +190,32 @@
|
||||
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
|
||||
// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
|
||||
// variable don't have to be used.
|
||||
// GTEST_DISALLOW_ASSIGN_ - disables operator=.
|
||||
// GTEST_DISALLOW_ASSIGN_ - disables copy operator=.
|
||||
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
|
||||
// GTEST_DISALLOW_MOVE_ASSIGN_ - disables move operator=.
|
||||
// GTEST_DISALLOW_MOVE_AND_ASSIGN_ - disables move ctor and operator=.
|
||||
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
|
||||
// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
|
||||
// suppressed (constant conditional).
|
||||
// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
|
||||
// is suppressed.
|
||||
// GTEST_INTERNAL_HAS_ANY - for enabling UniversalPrinter<std::any> or
|
||||
// UniversalPrinter<absl::any> specializations.
|
||||
// GTEST_INTERNAL_HAS_OPTIONAL - for enabling UniversalPrinter<std::optional>
|
||||
// or
|
||||
// UniversalPrinter<absl::optional>
|
||||
// specializations.
|
||||
// GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or
|
||||
// Matcher<absl::string_view>
|
||||
// specializations.
|
||||
// GTEST_INTERNAL_HAS_VARIANT - for enabling UniversalPrinter<std::variant> or
|
||||
// UniversalPrinter<absl::variant>
|
||||
// specializations.
|
||||
//
|
||||
// Synchronization:
|
||||
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
|
||||
// - synchronization primitives.
|
||||
//
|
||||
// Template meta programming:
|
||||
// IteratorTraits - partial implementation of std::iterator_traits, which
|
||||
// is not available in libCstd when compiled with Sun C++.
|
||||
//
|
||||
//
|
||||
// Regular expressions:
|
||||
// RE - a simple regular expression class using the POSIX
|
||||
// Extended Regular Expression syntax on UNIX-like platforms
|
||||
@@ -228,8 +237,7 @@
|
||||
//
|
||||
// Integer types:
|
||||
// TypeWithSize - maps an integer to a int type.
|
||||
// Int32, UInt32, Int64, UInt64, TimeInMillis
|
||||
// - integers of known sizes.
|
||||
// TimeInMillis - integers of known sizes.
|
||||
// BiggestInt - the biggest signed integer type.
|
||||
//
|
||||
// Command-line utilities:
|
||||
@@ -240,7 +248,7 @@
|
||||
// Environment variable utilities:
|
||||
// GetEnv() - gets the value of an environment variable.
|
||||
// BoolFromGTestEnv() - parses a bool environment variable.
|
||||
// Int32FromGTestEnv() - parses an Int32 environment variable.
|
||||
// Int32FromGTestEnv() - parses an int32_t environment variable.
|
||||
// StringFromGTestEnv() - parses a string environment variable.
|
||||
//
|
||||
// Deprecation warnings:
|
||||
@@ -253,7 +261,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <memory>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
@@ -266,16 +277,15 @@
|
||||
# include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm> // NOLINT
|
||||
#include <iostream> // NOLINT
|
||||
#include <sstream> // NOLINT
|
||||
#include <string> // NOLINT
|
||||
#include <iostream> // NOLINT
|
||||
#include <locale>
|
||||
#include <memory>
|
||||
#include <string> // NOLINT
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector> // NOLINT
|
||||
|
||||
#include "gtest/internal/gtest-port-arch.h"
|
||||
#include "gtest/internal/custom/gtest-port.h"
|
||||
#include "gtest/internal/gtest-port-arch.h"
|
||||
|
||||
#if !defined(GTEST_DEV_EMAIL_)
|
||||
# define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
|
||||
@@ -349,6 +359,10 @@ typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
|
||||
typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#endif
|
||||
#elif GTEST_OS_XTENSA
|
||||
#include <unistd.h>
|
||||
// Xtensa toolchains define strcasecmp in the string.h header instead of
|
||||
// strings.h. string.h is already included.
|
||||
#else
|
||||
// This assumes that non-Windows OSes provide unistd.h. For OSes where this
|
||||
// is not the case, we need to include headers that provide the functions
|
||||
@@ -362,13 +376,14 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
# include <android/api-level.h> // NOLINT
|
||||
#endif
|
||||
|
||||
// Defines this to true iff Google Test can use POSIX regular expressions.
|
||||
// Defines this to true if and only if Google Test can use POSIX regular
|
||||
// expressions.
|
||||
#ifndef GTEST_HAS_POSIX_RE
|
||||
# if GTEST_OS_LINUX_ANDROID
|
||||
// On Android, <regex.h> is only available starting with Gingerbread.
|
||||
# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
|
||||
# else
|
||||
# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
|
||||
#define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS && !GTEST_OS_XTENSA)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -403,7 +418,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// The user didn't tell us whether exceptions are enabled, so we need
|
||||
// to figure it out.
|
||||
# if defined(_MSC_VER) && defined(_CPPUNWIND)
|
||||
// MSVC defines _CPPUNWIND to 1 iff exceptions are enabled.
|
||||
// MSVC defines _CPPUNWIND to 1 if and only if exceptions are enabled.
|
||||
# define GTEST_HAS_EXCEPTIONS 1
|
||||
# elif defined(__BORLANDC__)
|
||||
// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS
|
||||
@@ -414,16 +429,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
# endif // _HAS_EXCEPTIONS
|
||||
# define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
|
||||
# elif defined(__clang__)
|
||||
// clang defines __EXCEPTIONS iff exceptions are enabled before clang 220714,
|
||||
// but iff cleanups are enabled after that. In Obj-C++ files, there can be
|
||||
// cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions
|
||||
// are disabled. clang has __has_feature(cxx_exceptions) which checks for C++
|
||||
// exceptions starting at clang r206352, but which checked for cleanups prior to
|
||||
// that. To reliably check for C++ exception availability with clang, check for
|
||||
// clang defines __EXCEPTIONS if and only if exceptions are enabled before clang
|
||||
// 220714, but if and only if cleanups are enabled after that. In Obj-C++ files,
|
||||
// there can be cleanups for ObjC exceptions which also need cleanups, even if
|
||||
// C++ exceptions are disabled. clang has __has_feature(cxx_exceptions) which
|
||||
// checks for C++ exceptions starting at clang r206352, but which checked for
|
||||
// cleanups prior to that. To reliably check for C++ exception availability with
|
||||
// clang, check for
|
||||
// __EXCEPTIONS && __has_feature(cxx_exceptions).
|
||||
# define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
|
||||
# elif defined(__GNUC__) && __EXCEPTIONS
|
||||
// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
|
||||
// gcc defines __EXCEPTIONS to 1 if and only if exceptions are enabled.
|
||||
# define GTEST_HAS_EXCEPTIONS 1
|
||||
# elif defined(__SUNPRO_CC)
|
||||
// Sun Pro CC supports exceptions. However, there is no compile-time way of
|
||||
@@ -431,7 +447,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// they are enabled unless the user tells us otherwise.
|
||||
# define GTEST_HAS_EXCEPTIONS 1
|
||||
# elif defined(__IBMCPP__) && __EXCEPTIONS
|
||||
// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
|
||||
// xlC defines __EXCEPTIONS to 1 if and only if exceptions are enabled.
|
||||
# define GTEST_HAS_EXCEPTIONS 1
|
||||
# elif defined(__HP_aCC)
|
||||
// Exception handling is in effect by default in HP aCC compiler. It has to
|
||||
@@ -444,15 +460,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
# endif // defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
#if !defined(GTEST_HAS_STD_STRING)
|
||||
// Even though we don't use this macro any longer, we keep it in case
|
||||
// some clients still depend on it.
|
||||
# define GTEST_HAS_STD_STRING 1
|
||||
#elif !GTEST_HAS_STD_STRING
|
||||
// The user told us that ::std::string isn't available.
|
||||
# error "::std::string isn't available."
|
||||
#endif // !defined(GTEST_HAS_STD_STRING)
|
||||
|
||||
#ifndef GTEST_HAS_STD_WSTRING
|
||||
// The user didn't tell us whether ::std::wstring is available, so we need
|
||||
// to figure it out.
|
||||
@@ -461,7 +468,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// no support for it at least as recent as Froyo (2.2).
|
||||
#define GTEST_HAS_STD_WSTRING \
|
||||
(!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
|
||||
GTEST_OS_HAIKU))
|
||||
GTEST_OS_HAIKU || GTEST_OS_ESP32 || GTEST_OS_ESP8266 || GTEST_OS_XTENSA))
|
||||
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
@@ -472,13 +479,14 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
|
||||
# ifdef _MSC_VER
|
||||
|
||||
# ifdef _CPPRTTI // MSVC defines this macro iff RTTI is enabled.
|
||||
#ifdef _CPPRTTI // MSVC defines this macro if and only if RTTI is enabled.
|
||||
# define GTEST_HAS_RTTI 1
|
||||
# else
|
||||
# define GTEST_HAS_RTTI 0
|
||||
# endif
|
||||
|
||||
// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
|
||||
// Starting with version 4.3.2, gcc defines __GXX_RTTI if and only if RTTI is
|
||||
// enabled.
|
||||
# elif defined(__GNUC__)
|
||||
|
||||
# ifdef __GXX_RTTI
|
||||
@@ -584,7 +592,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#ifndef GTEST_HAS_STREAM_REDIRECTION
|
||||
// By default, we assume that stream redirection is supported on all
|
||||
// platforms except known mobile ones.
|
||||
# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
|
||||
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
|
||||
GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA
|
||||
# define GTEST_HAS_STREAM_REDIRECTION 0
|
||||
# else
|
||||
# define GTEST_HAS_STREAM_REDIRECTION 1
|
||||
@@ -678,16 +687,27 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#endif
|
||||
|
||||
|
||||
// A macro to disallow operator=
|
||||
// A macro to disallow copy operator=
|
||||
// This should be used in the private: declarations for a class.
|
||||
#define GTEST_DISALLOW_ASSIGN_(type) \
|
||||
void operator=(type const &) = delete
|
||||
type& operator=(type const &) = delete
|
||||
|
||||
// A macro to disallow copy constructor and operator=
|
||||
// This should be used in the private: declarations for a class.
|
||||
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \
|
||||
type(type const &) = delete; \
|
||||
GTEST_DISALLOW_ASSIGN_(type)
|
||||
type(type const&) = delete; \
|
||||
type& operator=(type const&) = delete
|
||||
|
||||
// A macro to disallow move operator=
|
||||
// This should be used in the private: declarations for a class.
|
||||
#define GTEST_DISALLOW_MOVE_ASSIGN_(type) \
|
||||
type& operator=(type &&) noexcept = delete
|
||||
|
||||
// A macro to disallow move constructor and operator=
|
||||
// This should be used in the private: declarations for a class.
|
||||
#define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \
|
||||
type(type&&) noexcept = delete; \
|
||||
type& operator=(type&&) noexcept = delete
|
||||
|
||||
// Tell the compiler to warn about unused return values for functions declared
|
||||
// with this macro. The macro should be used on function declarations
|
||||
@@ -858,30 +878,6 @@ class Secret;
|
||||
// expression is false, compiler will issue an error containing this identifier.
|
||||
#define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)
|
||||
|
||||
// StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
|
||||
//
|
||||
// This template is declared, but intentionally undefined.
|
||||
template <typename T1, typename T2>
|
||||
struct StaticAssertTypeEqHelper;
|
||||
|
||||
template <typename T>
|
||||
struct StaticAssertTypeEqHelper<T, T> {
|
||||
enum { value = true };
|
||||
};
|
||||
|
||||
// Same as std::is_same<>.
|
||||
template <typename T, typename U>
|
||||
struct IsSame {
|
||||
enum { value = false };
|
||||
};
|
||||
template <typename T>
|
||||
struct IsSame<T, T> {
|
||||
enum { value = true };
|
||||
};
|
||||
|
||||
// Evaluates to the number of elements in 'array'.
|
||||
#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
|
||||
|
||||
// A helper for suppressing warnings on constant condition. It just
|
||||
// returns 'condition'.
|
||||
GTEST_API_ bool IsTrue(bool condition);
|
||||
@@ -909,9 +905,9 @@ class GTEST_API_ RE {
|
||||
// Returns the string representation of the regex.
|
||||
const char* pattern() const { return pattern_; }
|
||||
|
||||
// FullMatch(str, re) returns true iff regular expression re matches
|
||||
// the entire str.
|
||||
// PartialMatch(str, re) returns true iff regular expression re
|
||||
// FullMatch(str, re) returns true if and only if regular expression re
|
||||
// matches the entire str.
|
||||
// PartialMatch(str, re) returns true if and only if regular expression re
|
||||
// matches a substring of str (including str itself).
|
||||
static bool FullMatch(const ::std::string& str, const RE& re) {
|
||||
return FullMatch(str.c_str(), re);
|
||||
@@ -938,8 +934,6 @@ class GTEST_API_ RE {
|
||||
const char* full_pattern_; // For FullMatch();
|
||||
|
||||
# endif
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(RE);
|
||||
};
|
||||
|
||||
#endif // GTEST_USES_PCRE
|
||||
@@ -1029,19 +1023,6 @@ inline void FlushInfoLog() { fflush(nullptr); }
|
||||
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
|
||||
<< gtest_error
|
||||
|
||||
// Adds reference to a type if it is not a reference type,
|
||||
// otherwise leaves it unchanged. This is the same as
|
||||
// tr1::add_reference, which is not widely available yet.
|
||||
template <typename T>
|
||||
struct AddReference { typedef T& type; }; // NOLINT
|
||||
template <typename T>
|
||||
struct AddReference<T&> { typedef T& type; }; // NOLINT
|
||||
|
||||
// A handy wrapper around AddReference that works when the argument T
|
||||
// depends on template parameters.
|
||||
#define GTEST_ADD_REFERENCE_(T) \
|
||||
typename ::testing::internal::AddReference<T>::type
|
||||
|
||||
// Transforms "T" into "const T&" according to standard reference collapsing
|
||||
// rules (this is only needed as a backport for C++98 compilers that do not
|
||||
// support reference collapsing). Specifically, it transforms:
|
||||
@@ -1266,7 +1247,8 @@ class GTEST_API_ AutoHandle {
|
||||
void Reset(Handle handle);
|
||||
|
||||
private:
|
||||
// Returns true iff the handle is a valid handle object that can be closed.
|
||||
// Returns true if and only if the handle is a valid handle object that can be
|
||||
// closed.
|
||||
bool IsCloseable() const;
|
||||
|
||||
Handle handle_;
|
||||
@@ -1368,7 +1350,8 @@ class ThreadWithParam : public ThreadWithParamBase {
|
||||
// When non-NULL, used to block execution until the controller thread
|
||||
// notifies.
|
||||
Notification* const thread_can_start_;
|
||||
bool finished_; // true iff we know that the thread function has finished.
|
||||
bool finished_; // true if and only if we know that the thread function has
|
||||
// finished.
|
||||
pthread_t thread_; // The native thread object.
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
|
||||
@@ -1633,7 +1616,7 @@ class ThreadLocal : public ThreadLocalBase {
|
||||
class DefaultValueHolderFactory : public ValueHolderFactory {
|
||||
public:
|
||||
DefaultValueHolderFactory() {}
|
||||
virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
|
||||
ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
|
||||
@@ -1642,7 +1625,7 @@ class ThreadLocal : public ThreadLocalBase {
|
||||
class InstanceValueHolderFactory : public ValueHolderFactory {
|
||||
public:
|
||||
explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
|
||||
virtual ValueHolder* MakeNewHolder() const {
|
||||
ValueHolder* MakeNewHolder() const override {
|
||||
return new ValueHolder(value_);
|
||||
}
|
||||
|
||||
@@ -1842,7 +1825,7 @@ class GTEST_API_ ThreadLocal {
|
||||
class DefaultValueHolderFactory : public ValueHolderFactory {
|
||||
public:
|
||||
DefaultValueHolderFactory() {}
|
||||
virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
|
||||
ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
|
||||
@@ -1851,7 +1834,7 @@ class GTEST_API_ ThreadLocal {
|
||||
class InstanceValueHolderFactory : public ValueHolderFactory {
|
||||
public:
|
||||
explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
|
||||
virtual ValueHolder* MakeNewHolder() const {
|
||||
ValueHolder* MakeNewHolder() const override {
|
||||
return new ValueHolder(value_);
|
||||
}
|
||||
|
||||
@@ -1921,47 +1904,12 @@ class GTEST_API_ ThreadLocal {
|
||||
// we cannot detect it.
|
||||
GTEST_API_ size_t GetThreadCount();
|
||||
|
||||
template <bool bool_value>
|
||||
struct bool_constant {
|
||||
typedef bool_constant<bool_value> type;
|
||||
static const bool value = bool_value;
|
||||
};
|
||||
template <bool bool_value> const bool bool_constant<bool_value>::value;
|
||||
|
||||
typedef bool_constant<false> false_type;
|
||||
typedef bool_constant<true> true_type;
|
||||
|
||||
template <typename T, typename U>
|
||||
struct is_same : public false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_same<T, T> : public true_type {};
|
||||
|
||||
template <typename Iterator>
|
||||
struct IteratorTraits {
|
||||
typedef typename Iterator::value_type value_type;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct IteratorTraits<T*> {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IteratorTraits<const T*> {
|
||||
typedef T value_type;
|
||||
};
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
# define GTEST_PATH_SEP_ "\\"
|
||||
# define GTEST_HAS_ALT_PATH_SEP_ 1
|
||||
// The biggest signed integer type the compiler supports.
|
||||
typedef __int64 BiggestInt;
|
||||
#else
|
||||
# define GTEST_PATH_SEP_ "/"
|
||||
# define GTEST_HAS_ALT_PATH_SEP_ 0
|
||||
typedef long long BiggestInt; // NOLINT
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
// Utilities for char.
|
||||
@@ -1992,6 +1940,19 @@ inline bool IsUpper(char ch) {
|
||||
inline bool IsXDigit(char ch) {
|
||||
return isxdigit(static_cast<unsigned char>(ch)) != 0;
|
||||
}
|
||||
#ifdef __cpp_char8_t
|
||||
inline bool IsXDigit(char8_t ch) {
|
||||
return isxdigit(static_cast<unsigned char>(ch)) != 0;
|
||||
}
|
||||
#endif
|
||||
inline bool IsXDigit(char16_t ch) {
|
||||
const unsigned char low_byte = static_cast<unsigned char>(ch);
|
||||
return ch == low_byte && isxdigit(low_byte) != 0;
|
||||
}
|
||||
inline bool IsXDigit(char32_t ch) {
|
||||
const unsigned char low_byte = static_cast<unsigned char>(ch);
|
||||
return ch == low_byte && isxdigit(low_byte) != 0;
|
||||
}
|
||||
inline bool IsXDigit(wchar_t ch) {
|
||||
const unsigned char low_byte = static_cast<unsigned char>(ch);
|
||||
return ch == low_byte && isxdigit(low_byte) != 0;
|
||||
@@ -2026,16 +1987,16 @@ namespace posix {
|
||||
typedef struct _stat StatStruct;
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
inline int IsATTY(int fd) { return isatty(fd); }
|
||||
inline int DoIsATTY(int fd) { return isatty(fd); }
|
||||
inline int StrCaseCmp(const char* s1, const char* s2) {
|
||||
return stricmp(s1, s2);
|
||||
}
|
||||
inline char* StrDup(const char* src) { return strdup(src); }
|
||||
# else // !__BORLANDC__
|
||||
# if GTEST_OS_WINDOWS_MOBILE
|
||||
inline int IsATTY(int /* fd */) { return 0; }
|
||||
inline int DoIsATTY(int /* fd */) { return 0; }
|
||||
# else
|
||||
inline int IsATTY(int fd) { return _isatty(fd); }
|
||||
inline int DoIsATTY(int fd) { return _isatty(fd); }
|
||||
# endif // GTEST_OS_WINDOWS_MOBILE
|
||||
inline int StrCaseCmp(const char* s1, const char* s2) {
|
||||
return _stricmp(s1, s2);
|
||||
@@ -2056,12 +2017,28 @@ inline bool IsDir(const StatStruct& st) {
|
||||
}
|
||||
# endif // GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
#elif GTEST_OS_ESP8266
|
||||
typedef struct stat StatStruct;
|
||||
|
||||
inline int FileNo(FILE* file) { return fileno(file); }
|
||||
inline int DoIsATTY(int fd) { return isatty(fd); }
|
||||
inline int Stat(const char* path, StatStruct* buf) {
|
||||
// stat function not implemented on ESP8266
|
||||
return 0;
|
||||
}
|
||||
inline int StrCaseCmp(const char* s1, const char* s2) {
|
||||
return strcasecmp(s1, s2);
|
||||
}
|
||||
inline char* StrDup(const char* src) { return strdup(src); }
|
||||
inline int RmDir(const char* dir) { return rmdir(dir); }
|
||||
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
|
||||
|
||||
#else
|
||||
|
||||
typedef struct stat StatStruct;
|
||||
|
||||
inline int FileNo(FILE* file) { return fileno(file); }
|
||||
inline int IsATTY(int fd) { return isatty(fd); }
|
||||
inline int DoIsATTY(int fd) { return isatty(fd); }
|
||||
inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
|
||||
inline int StrCaseCmp(const char* s1, const char* s2) {
|
||||
return strcasecmp(s1, s2);
|
||||
@@ -2072,23 +2049,39 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
|
||||
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
inline int IsATTY(int fd) {
|
||||
// DoIsATTY might change errno (for example ENOTTY in case you redirect stdout
|
||||
// to a file on Linux), which is unexpected, so save the previous value, and
|
||||
// restore it after the call.
|
||||
int savedErrno = errno;
|
||||
int isAttyValue = DoIsATTY(fd);
|
||||
errno = savedErrno;
|
||||
|
||||
return isAttyValue;
|
||||
}
|
||||
|
||||
// Functions deprecated by MSVC 8.0.
|
||||
|
||||
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
|
||||
|
||||
inline const char* StrNCpy(char* dest, const char* src, size_t n) {
|
||||
return strncpy(dest, src, n);
|
||||
}
|
||||
|
||||
// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
|
||||
// StrError() aren't needed on Windows CE at this time and thus not
|
||||
// defined there.
|
||||
|
||||
#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
|
||||
#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \
|
||||
!GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA
|
||||
inline int ChDir(const char* dir) { return chdir(dir); }
|
||||
#endif
|
||||
inline FILE* FOpen(const char* path, const char* mode) {
|
||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
||||
struct wchar_codecvt : public std::codecvt<wchar_t, char, std::mbstate_t> {};
|
||||
std::wstring_convert<wchar_codecvt> converter;
|
||||
std::wstring wide_path = converter.from_bytes(path);
|
||||
std::wstring wide_mode = converter.from_bytes(mode);
|
||||
return _wfopen(wide_path.c_str(), wide_mode.c_str());
|
||||
#else // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
||||
return fopen(path, mode);
|
||||
#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
||||
}
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
|
||||
@@ -2108,8 +2101,9 @@ inline int Close(int fd) { return close(fd); }
|
||||
inline const char* StrError(int errnum) { return strerror(errnum); }
|
||||
#endif
|
||||
inline const char* GetEnv(const char* name) {
|
||||
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
|
||||
// We are on Windows CE, which has no environment variables.
|
||||
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
|
||||
GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA
|
||||
// We are on an embedded platform, which has no environment variables.
|
||||
static_cast<void>(name); // To prevent 'unused argument' warning.
|
||||
return nullptr;
|
||||
#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
|
||||
@@ -2151,15 +2145,13 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_()
|
||||
# define GTEST_SNPRINTF_ snprintf
|
||||
#endif
|
||||
|
||||
// The maximum number a BiggestInt can represent. This definition
|
||||
// works no matter BiggestInt is represented in one's complement or
|
||||
// two's complement.
|
||||
// The biggest signed integer type the compiler supports.
|
||||
//
|
||||
// We cannot rely on numeric_limits in STL, as __int64 and long long
|
||||
// are not part of standard C++ and numeric_limits doesn't need to be
|
||||
// defined for them.
|
||||
const BiggestInt kMaxBiggestInt =
|
||||
~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
|
||||
// long long is guaranteed to be at least 64-bits in C++11.
|
||||
using BiggestInt = long long; // NOLINT
|
||||
|
||||
// The maximum number a BiggestInt can represent.
|
||||
constexpr BiggestInt kMaxBiggestInt = (std::numeric_limits<BiggestInt>::max)();
|
||||
|
||||
// This template class serves as a compile-time function from size to
|
||||
// type. It maps a size in bytes to a primitive type with that
|
||||
@@ -2184,40 +2176,27 @@ class TypeWithSize {
|
||||
public:
|
||||
// This prevents the user from using TypeWithSize<N> with incorrect
|
||||
// values of N.
|
||||
typedef void UInt;
|
||||
using UInt = void;
|
||||
};
|
||||
|
||||
// The specialization for size 4.
|
||||
template <>
|
||||
class TypeWithSize<4> {
|
||||
public:
|
||||
// unsigned int has size 4 in both gcc and MSVC.
|
||||
//
|
||||
// As base/basictypes.h doesn't compile on Windows, we cannot use
|
||||
// uint32, uint64, and etc here.
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
using Int = std::int32_t;
|
||||
using UInt = std::uint32_t;
|
||||
};
|
||||
|
||||
// The specialization for size 8.
|
||||
template <>
|
||||
class TypeWithSize<8> {
|
||||
public:
|
||||
#if GTEST_OS_WINDOWS
|
||||
typedef __int64 Int;
|
||||
typedef unsigned __int64 UInt;
|
||||
#else
|
||||
typedef long long Int; // NOLINT
|
||||
typedef unsigned long long UInt; // NOLINT
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
using Int = std::int64_t;
|
||||
using UInt = std::uint64_t;
|
||||
};
|
||||
|
||||
// Integer types of known sizes.
|
||||
typedef TypeWithSize<4>::Int Int32;
|
||||
typedef TypeWithSize<4>::UInt UInt32;
|
||||
typedef TypeWithSize<8>::Int Int64;
|
||||
typedef TypeWithSize<8>::UInt UInt64;
|
||||
typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
|
||||
// Utilities for command line flags and environment variables.
|
||||
|
||||
@@ -2236,7 +2215,7 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
// Macros for declaring flags.
|
||||
# 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)
|
||||
GTEST_API_ extern std::int32_t GTEST_FLAG(name)
|
||||
# define GTEST_DECLARE_string_(name) \
|
||||
GTEST_API_ extern ::std::string GTEST_FLAG(name)
|
||||
|
||||
@@ -2244,7 +2223,7 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
# 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)
|
||||
GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val)
|
||||
# define GTEST_DEFINE_string_(name, default_val, doc) \
|
||||
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
|
||||
|
||||
@@ -2259,12 +2238,13 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
// Parses 'str' for a 32-bit signed integer. If successful, writes the result
|
||||
// to *value and returns true; otherwise leaves *value unchanged and returns
|
||||
// false.
|
||||
bool ParseInt32(const Message& src_text, const char* str, Int32* value);
|
||||
GTEST_API_ bool ParseInt32(const Message& src_text, const char* str,
|
||||
int32_t* value);
|
||||
|
||||
// Parses a bool/Int32/string from the environment variable
|
||||
// Parses a bool/int32_t/string from the environment variable
|
||||
// corresponding to the given Google Test flag.
|
||||
bool BoolFromGTestEnv(const char* flag, bool default_val);
|
||||
GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
|
||||
GTEST_API_ int32_t Int32FromGTestEnv(const char* flag, int32_t default_val);
|
||||
std::string OutputFlagAlsoCheckEnvVar();
|
||||
const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
||||
|
||||
@@ -2291,4 +2271,119 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
||||
|
||||
#endif // !defined(GTEST_INTERNAL_DEPRECATED)
|
||||
|
||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
#if GTEST_HAS_ABSL
|
||||
// Always use absl::any for UniversalPrinter<> specializations if googletest
|
||||
// is built with absl support.
|
||||
#define GTEST_INTERNAL_HAS_ANY 1
|
||||
#include "absl/types/any.h"
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
using Any = ::absl::any;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#ifdef __has_include
|
||||
#if __has_include(<any>) && __cplusplus >= 201703L
|
||||
// Otherwise for C++17 and higher use std::any for UniversalPrinter<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_ANY 1
|
||||
#include <any>
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
using Any = ::std::any;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::any is not
|
||||
// supported.
|
||||
#endif // __has_include(<any>) && __cplusplus >= 201703L
|
||||
#endif // __has_include
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#if GTEST_HAS_ABSL
|
||||
// Always use absl::optional for UniversalPrinter<> specializations if
|
||||
// googletest is built with absl support.
|
||||
#define GTEST_INTERNAL_HAS_OPTIONAL 1
|
||||
#include "absl/types/optional.h"
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
template <typename T>
|
||||
using Optional = ::absl::optional<T>;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#ifdef __has_include
|
||||
#if __has_include(<optional>) && __cplusplus >= 201703L
|
||||
// Otherwise for C++17 and higher use std::optional for UniversalPrinter<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_OPTIONAL 1
|
||||
#include <optional>
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
template <typename T>
|
||||
using Optional = ::std::optional<T>;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::optional is not
|
||||
// supported.
|
||||
#endif // __has_include(<optional>) && __cplusplus >= 201703L
|
||||
#endif // __has_include
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#if GTEST_HAS_ABSL
|
||||
// Always use absl::string_view for Matcher<> specializations if googletest
|
||||
// is built with absl support.
|
||||
# define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||
#include "absl/strings/string_view.h"
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
using StringView = ::absl::string_view;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
# ifdef __has_include
|
||||
# if __has_include(<string_view>) && __cplusplus >= 201703L
|
||||
// Otherwise for C++17 and higher use std::string_view for Matcher<>
|
||||
// specializations.
|
||||
# define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||
#include <string_view>
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
using StringView = ::std::string_view;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::string_view is not
|
||||
// supported.
|
||||
# endif // __has_include(<string_view>) && __cplusplus >= 201703L
|
||||
# endif // __has_include
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#if GTEST_HAS_ABSL
|
||||
// Always use absl::variant for UniversalPrinter<> specializations if googletest
|
||||
// is built with absl support.
|
||||
#define GTEST_INTERNAL_HAS_VARIANT 1
|
||||
#include "absl/types/variant.h"
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
template <typename... T>
|
||||
using Variant = ::absl::variant<T...>;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#ifdef __has_include
|
||||
#if __has_include(<variant>) && __cplusplus >= 201703L
|
||||
// Otherwise for C++17 and higher use std::variant for UniversalPrinter<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_VARIANT 1
|
||||
#include <variant>
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
template <typename... T>
|
||||
using Variant = ::std::variant<T...>;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::variant is not supported.
|
||||
#endif // __has_include(<variant>) && __cplusplus >= 201703L
|
||||
#endif // __has_include
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
|
||||
Reference in New Issue
Block a user