mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
deps: update googletest to 36ba75f0ad5383a9759f17f3f72fd4661c72cb6d
PR-URL: https://github.com/nodejs/node/pull/65654 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
aeed6132a7
commit
373cd332d8
8 files changed
+130
-57
No files matched your search
+2
-2
@@ -552,7 +552,7 @@ auto ConvertGenerator(Gen&& gen, Func&& f) {
|
||||
|
||||
#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \
|
||||
static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
|
||||
gtest_##prefix##test_suite_name##_EvalGenerator_() { \
|
||||
gtest_##prefix##test_suite_name##_EvalGenerator_() { \
|
||||
return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \
|
||||
} \
|
||||
static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
|
||||
@@ -562,7 +562,7 @@ auto ConvertGenerator(Gen&& gen, Func&& f) {
|
||||
__VA_ARGS__, \
|
||||
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
|
||||
DUMMY_PARAM_))); \
|
||||
auto t = std::make_tuple(__VA_ARGS__); \
|
||||
const auto t = std::make_tuple(__VA_ARGS__); \
|
||||
static_assert(std::tuple_size<decltype(t)>::value <= 2, \
|
||||
"Too Many Args!"); \
|
||||
} \
|
||||
|
||||
+13
-16
@@ -522,17 +522,14 @@ inline void PrintTo(bool x, ::std::ostream* os) {
|
||||
GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
|
||||
|
||||
GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
|
||||
inline void PrintTo(char16_t c, ::std::ostream* os) {
|
||||
// TODO(b/418738869): Incorrect for values not representing valid codepoints.
|
||||
// Also see https://github.com/google/googletest/issues/4762.
|
||||
PrintTo(static_cast<char32_t>(c), os);
|
||||
}
|
||||
|
||||
// Overloads for the UTF-8 and UTF-16 code unit types. A code unit that
|
||||
// encodes a code point all by itself is printed with the U+XXXX notation;
|
||||
// one that does not (any non-ASCII char8_t, and the UTF-16 surrogates) is
|
||||
// printed as a code unit instead, the way wchar_t is.
|
||||
GTEST_API_ void PrintTo(char16_t c, ::std::ostream* os);
|
||||
#ifdef __cpp_lib_char8_t
|
||||
inline void PrintTo(char8_t c, ::std::ostream* os) {
|
||||
// TODO(b/418738869): Incorrect for values not representing valid codepoints.
|
||||
// Also see https://github.com/google/googletest/issues/4762.
|
||||
PrintTo(static_cast<char32_t>(c), os);
|
||||
}
|
||||
GTEST_API_ void PrintTo(char8_t c, ::std::ostream* os);
|
||||
#endif
|
||||
|
||||
// gcc/clang __{u,}int128_t
|
||||
@@ -674,12 +671,12 @@ inline void PrintTo(char32_t* s, ::std::ostream* os) {
|
||||
PrintTo(ImplicitCast_<const char32_t*>(s), os);
|
||||
}
|
||||
|
||||
// MSVC can be configured to define wchar_t as a typedef of unsigned
|
||||
// short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
|
||||
// type. When wchar_t is a typedef, defining an overload for const
|
||||
// wchar_t* would cause unsigned short* be printed as a wide string,
|
||||
// possibly causing invalid memory accesses.
|
||||
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
// Only add an overload for printing wchar_t* if:
|
||||
// 1. Wide string support is enabled.
|
||||
// 2. wchar_t is a distinct native type. (If it's a typedef, the overload could
|
||||
// cause a pointer to the underlying type to be mistakenly treated as a
|
||||
// string.)
|
||||
#if GTEST_HAS_STD_WSTRING && GTEST_HAS_NATIVE_WCHAR
|
||||
// Overloads for wide C strings
|
||||
GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
|
||||
inline void PrintTo(wchar_t* s, ::std::ostream* os) {
|
||||
|
||||
+13
-9
@@ -71,7 +71,7 @@
|
||||
#include "gtest/gtest-typed-test.h" // IWYU pragma: export
|
||||
#include "gtest/gtest_pred_impl.h" // IWYU pragma: export
|
||||
#include "gtest/gtest_prod.h" // IWYU pragma: export
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-internal.h" // IWYU pragma: export
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
||||
@@ -1514,6 +1514,8 @@ GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1, const char* s2);
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
|
||||
// Helper function for *_STREQ on wide strings.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
@@ -1528,6 +1530,8 @@ GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const wchar_t* s1, const wchar_t* s2);
|
||||
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// IsSubstring() and IsNotSubstring() are intended to be used as the
|
||||
@@ -1542,18 +1546,10 @@ GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const char* needle,
|
||||
const char* haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const wchar_t* needle,
|
||||
const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const char* needle,
|
||||
const char* haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const wchar_t* needle,
|
||||
const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const ::std::string& needle,
|
||||
@@ -1564,6 +1560,14 @@ GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const ::std::string& haystack);
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const wchar_t* needle,
|
||||
const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const wchar_t* needle,
|
||||
const wchar_t* haystack);
|
||||
GTEST_API_ AssertionResult IsSubstring(const char* needle_expr,
|
||||
const char* haystack_expr,
|
||||
const ::std::wstring& needle,
|
||||
|
||||
+4
-3
@@ -39,7 +39,7 @@
|
||||
#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
#include "gtest/internal/gtest-port.h" // IWYU pragma: export
|
||||
|
||||
#ifdef GTEST_OS_LINUX
|
||||
#include <stdlib.h>
|
||||
@@ -1516,8 +1516,9 @@ class [[nodiscard]] NeverThrown {
|
||||
parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__), \
|
||||
::testing::internal::SuiteApiResolver< \
|
||||
parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__), \
|
||||
new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
|
||||
test_suite_name, test_name)>); \
|
||||
::std::make_unique<::testing::internal::TestFactoryImpl< \
|
||||
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)>>() \
|
||||
.release()); \
|
||||
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
+40
-3
@@ -500,6 +500,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
// MSVC either defines wchar_t as a typedef of unsigned short, or as a native
|
||||
// type (in which case, it defines _NATIVE_WCHAR_T_DEFINED). When wchar_t is a
|
||||
// typedef, defining an overload for const wchar_t* would cause unsigned short*
|
||||
// be printed as a wide string, possibly causing invalid memory accesses, so we
|
||||
// omit wchar_t overloads in that case.
|
||||
#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
#define GTEST_HAS_NATIVE_WCHAR 0
|
||||
#else
|
||||
#define GTEST_HAS_NATIVE_WCHAR 1
|
||||
#endif
|
||||
|
||||
// 1. Calculate default GTEST_HAS_STD_WSTRING values based on STL capabilities.
|
||||
#if defined(_MSVC_STL_VERSION)
|
||||
// Microsoft's STL implementation always supports ::std::wstring.
|
||||
@@ -2185,7 +2196,13 @@ GTEST_DISABLE_DEPRECATED_PUSH_()
|
||||
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES) && \
|
||||
!defined(GTEST_OS_ESP8266) && !defined(GTEST_OS_XTENSA) && \
|
||||
!defined(GTEST_OS_QURT)
|
||||
inline int ChDir(const char* dir) { return chdir(dir); }
|
||||
inline int ChDir(const char* dir) {
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
return _chdir(dir);
|
||||
#else
|
||||
return chdir(dir);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
inline FILE* FOpen(const char* path, const char* mode) {
|
||||
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW)
|
||||
@@ -2202,17 +2219,37 @@ inline FILE* FOpen(const char* path, const char* mode) {
|
||||
inline FILE* FReopen(const char* path, const char* mode, FILE* stream) {
|
||||
return freopen(path, mode, stream);
|
||||
}
|
||||
inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
|
||||
inline FILE* FDOpen(int fd, const char* mode) {
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
return _fdopen(fd, mode);
|
||||
#else
|
||||
return fdopen(fd, mode);
|
||||
#endif
|
||||
}
|
||||
#endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
|
||||
inline int FClose(FILE* fp) { return fclose(fp); }
|
||||
#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT)
|
||||
inline int Read(int fd, void* buf, unsigned int count) {
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
return static_cast<int>(_read(fd, buf, count));
|
||||
#else
|
||||
return static_cast<int>(read(fd, buf, count));
|
||||
#endif
|
||||
}
|
||||
inline int Write(int fd, const void* buf, unsigned int count) {
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
return static_cast<int>(_write(fd, buf, count));
|
||||
#else
|
||||
return static_cast<int>(write(fd, buf, count));
|
||||
#endif
|
||||
}
|
||||
inline int Close(int fd) {
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
return _close(fd);
|
||||
#else
|
||||
return close(fd);
|
||||
#endif
|
||||
}
|
||||
inline int Close(int fd) { return close(fd); }
|
||||
#endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
|
||||
#endif // GTEST_HAS_FILE_SYSTEM
|
||||
|
||||
|
||||
Vendored
+19
-4
@@ -1085,7 +1085,14 @@ bool EndsWithPathSeparator(const std::string& path) {
|
||||
class CapturedStream {
|
||||
public:
|
||||
// The ctor redirects the stream to a temporary file.
|
||||
explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
|
||||
explicit CapturedStream(int fd)
|
||||
: fd_(fd),
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
uncaptured_fd_(_dup(fd))
|
||||
#else
|
||||
uncaptured_fd_(dup(fd))
|
||||
#endif
|
||||
{
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
char temp_dir_path[MAX_PATH + 1] = {'\0'}; // NOLINT
|
||||
char temp_file_path[MAX_PATH + 1] = {'\0'}; // NOLINT
|
||||
@@ -1097,7 +1104,7 @@ class CapturedStream {
|
||||
GTEST_CHECK_(success != 0)
|
||||
<< "Failed to create temporary file in " << temp_dir_path
|
||||
<< " with error " << ::GetLastError();
|
||||
const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
|
||||
const int captured_fd = _creat(temp_file_path, _S_IREAD | _S_IWRITE);
|
||||
GTEST_CHECK_(captured_fd != -1)
|
||||
<< "Failed to open temporary file " << temp_file_path << " with error "
|
||||
<< ::GetLastError();
|
||||
@@ -1167,8 +1174,12 @@ class CapturedStream {
|
||||
filename_ = std::move(name_template);
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
fflush(nullptr);
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
_dup2(captured_fd, fd_);
|
||||
#else
|
||||
dup2(captured_fd, fd_);
|
||||
close(captured_fd);
|
||||
#endif
|
||||
posix::Close(captured_fd);
|
||||
}
|
||||
|
||||
~CapturedStream() { remove(filename_.c_str()); }
|
||||
@@ -1177,8 +1188,12 @@ class CapturedStream {
|
||||
if (uncaptured_fd_ != -1) {
|
||||
// Restores the original stream.
|
||||
fflush(nullptr);
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
_dup2(uncaptured_fd_, fd_);
|
||||
#else
|
||||
dup2(uncaptured_fd_, fd_);
|
||||
close(uncaptured_fd_);
|
||||
#endif
|
||||
posix::Close(uncaptured_fd_);
|
||||
uncaptured_fd_ = -1;
|
||||
}
|
||||
|
||||
|
||||
+24
-9
@@ -286,6 +286,28 @@ void PrintTo(char32_t c, ::std::ostream* os) {
|
||||
<< static_cast<uint32_t>(c);
|
||||
}
|
||||
|
||||
// char8_t and char16_t hold code units, not code points, so the U+XXXX
|
||||
// notation only applies to the values that encode a code point on their own.
|
||||
// The rest -- non-ASCII char8_t, which are always part of a multi-unit UTF-8
|
||||
// sequence, and the UTF-16 surrogates -- are printed as code units.
|
||||
void PrintTo(char16_t c, ::std::ostream* os) {
|
||||
if (c >= 0xD800 && c <= 0xDFFF) {
|
||||
PrintCharAndCodeTo(c, os);
|
||||
} else {
|
||||
PrintTo(static_cast<char32_t>(c), os);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cpp_lib_char8_t
|
||||
void PrintTo(char8_t c, ::std::ostream* os) {
|
||||
if (c >= 0x80) {
|
||||
PrintCharAndCodeTo(c, os);
|
||||
} else {
|
||||
PrintTo(static_cast<char32_t>(c), os);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// gcc/clang __{u,}int128_t
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
void PrintTo(__uint128_t v, ::std::ostream* os) {
|
||||
@@ -468,16 +490,9 @@ void PrintTo(const char16_t* s, ostream* os) { PrintCStringTo(s, os); }
|
||||
|
||||
void PrintTo(const char32_t* s, ostream* os) { PrintCStringTo(s, os); }
|
||||
|
||||
// MSVC compiler can be configured to define whar_t as a typedef
|
||||
// of unsigned short. Defining an overload for const wchar_t* in that case
|
||||
// would cause pointers to unsigned shorts be printed as wide strings,
|
||||
// possibly accessing more memory than intended and causing invalid
|
||||
// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when
|
||||
// wchar_t is implemented as a native type.
|
||||
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
// Prints the given wide C string to the ostream.
|
||||
#if GTEST_HAS_STD_WSTRING && GTEST_HAS_NATIVE_WCHAR
|
||||
void PrintTo(const wchar_t* s, ostream* os) { PrintCStringTo(s, os); }
|
||||
#endif // wchar_t is native
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
Vendored
+15
-11
@@ -1876,11 +1876,13 @@ bool IsSubstringPred(const char* needle, const char* haystack) {
|
||||
return strstr(haystack, needle) != nullptr;
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {
|
||||
if (needle == nullptr || haystack == nullptr) return needle == haystack;
|
||||
|
||||
return wcsstr(haystack, needle) != nullptr;
|
||||
}
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
// StringType here can be either ::std::string or ::std::wstring.
|
||||
template <typename StringType>
|
||||
@@ -1922,23 +1924,12 @@ AssertionResult IsSubstring(const char* needle_expr, const char* haystack_expr,
|
||||
return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
|
||||
}
|
||||
|
||||
AssertionResult IsSubstring(const char* needle_expr, const char* haystack_expr,
|
||||
const wchar_t* needle, const wchar_t* haystack) {
|
||||
return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
|
||||
}
|
||||
|
||||
AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr, const char* needle,
|
||||
const char* haystack) {
|
||||
return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
|
||||
}
|
||||
|
||||
AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr, const wchar_t* needle,
|
||||
const wchar_t* haystack) {
|
||||
return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
|
||||
}
|
||||
|
||||
AssertionResult IsSubstring(const char* needle_expr, const char* haystack_expr,
|
||||
const ::std::string& needle,
|
||||
const ::std::string& haystack) {
|
||||
@@ -1953,6 +1944,17 @@ AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
AssertionResult IsSubstring(const char* needle_expr, const char* haystack_expr,
|
||||
const wchar_t* needle, const wchar_t* haystack) {
|
||||
return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
|
||||
}
|
||||
|
||||
AssertionResult IsNotSubstring(const char* needle_expr,
|
||||
const char* haystack_expr, const wchar_t* needle,
|
||||
const wchar_t* haystack) {
|
||||
return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
|
||||
}
|
||||
|
||||
AssertionResult IsSubstring(const char* needle_expr, const char* haystack_expr,
|
||||
const ::std::wstring& needle,
|
||||
const ::std::wstring& haystack) {
|
||||
@@ -2182,6 +2184,7 @@ bool String::WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs) {
|
||||
return wcscmp(lhs, rhs) == 0;
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
// Helper function for *_STREQ on wide strings.
|
||||
AssertionResult CmpHelperSTREQ(const char* lhs_expression,
|
||||
const char* rhs_expression, const wchar_t* lhs,
|
||||
@@ -2206,6 +2209,7 @@ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
<< "Expected: (" << s1_expression << ") != (" << s2_expression
|
||||
<< "), actual: " << PrintToString(s1) << " vs " << PrintToString(s2);
|
||||
}
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
// Compares two C strings, ignoring case. Returns true if and only if they have
|
||||
// the same content.
|
||||
|
||||
Reference in new issue
Block a user