deps: update googletest to 1b6f64d659944658a4c685b7bd9f04c1c3b8a39b · nodejs/node@5c423aa · GitHub
Skip to content

Commit 5c423aa

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update googletest to 1b6f64d659944658a4c685b7bd9f04c1c3b8a39b
PR-URL: #64940 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 40561e6 commit 5c423aa

8 files changed

Lines changed: 107 additions & 57 deletions

File tree

deps/googletest/include/gtest/gtest-assertion-result.h

Lines changed: 30 additions & 7 deletions

deps/googletest/include/gtest/gtest-printers.h

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -945,13 +945,13 @@ template <typename T>
945945
class [[nodiscard]] UniversalPrinter<std::optional<T>> {
946946
public:
947947
static void Print(const std::optional<T>& value, ::std::ostream* os) {
948-
*os << '(';
949948
if (!value) {
950-
*os << "nullopt";
949+
UniversalPrint(std::nullopt, os);
951950
} else {
951+
*os << '(';
952952
UniversalPrint(*value, os);
953+
*os << ')';
953954
}
954-
*os << ')';
955955
}
956956
};
957957

@@ -961,27 +961,38 @@ class [[nodiscard]] UniversalPrinter<std::nullopt_t> {
961961
static void Print(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
struct UniversalPrinterVisitor {
965+
template <typename T>
966+
void operator()(const T& arg) const {
967+
*os << "'" << GetTypeName<T>() << "(index = " << index << ")' with value ";
968+
UniversalPrint(arg, os);
969+
}
970+
::std::ostream* os;
971+
std::size_t index;
972+
};
973+
964974
// Printer for std::variant
965975
template <typename... T>
966976
class [[nodiscard]] UniversalPrinter<std::variant<T...>> {
967977
public:
968978
static void Print(const std::variant<T...>& value, ::std::ostream* os) {
969-
*os << '(';
970-
std::visit(Visitor{os, value.index()}, value);
971-
*os << ')';
979+
if (value.valueless_by_exception()) {
980+
*os << "(valueless)";
981+
} else {
982+
*os << '(';
983+
std::visit(UniversalPrinterVisitor{os, value.index()}, value);
984+
*os << ')';
985+
}
972986
}
987+
};
973988

974-
private:
975-
struct Visitor {
976-
template <typename U>
977-
void operator()(const U& u) const {
978-
*os << "'" << GetTypeName<U>() << "(index = " << index
979-
<< ")' with value ";
980-
UniversalPrint(u, os);
981-
}
982-
::std::ostream* os;
983-
std::size_t index;
984-
};
989+
// Printer for std::monostate
990+
template <>
991+
class [[nodiscard]] UniversalPrinter<std::monostate> {
992+
public:
993+
static void Print(std::monostate, ::std::ostream* os) {
994+
*os << "(monostate)";
995+
}
985996
};
986997

987998
// UniversalPrintArray(begin, len, os) prints an array of 'len'

deps/googletest/include/gtest/gtest.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,14 +1818,13 @@ class [[nodiscard]] TestWithParam : public Test,
18181818
#define GTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#define GTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#define GTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#define GTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#define GTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#define GTEST_ASSERT_FALSE(condition) \
1827+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, GTEST_FATAL_FAILURE_)
18291828

18301829
// Define these macros to 1 to omit the definition of the corresponding
18311830
// EXPECT or ASSERT, which clashes with some users' own code.

deps/googletest/include/gtest/internal/gtest-internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,12 +1453,12 @@ class [[nodiscard]] NeverThrown {
14531453
// representation of expression as it was passed into the EXPECT_TRUE.
14541454
#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
14551455
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1456-
if (const ::testing::AssertionResult gtest_ar_ = \
1457-
::testing::AssertionResult(expression)) \
1456+
if (::testing::internal::AssertionResultExpectation gtest_are_ = { \
1457+
::testing::AssertionResult(expression), expected}) \
14581458
; \
14591459
else \
14601460
fail(::testing::internal::GetBoolAssertionFailureMessage( \
1461-
gtest_ar_, text, #actual, #expected))
1461+
gtest_are_.assertion_result, text, #actual, #expected))
14621462

14631463
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
14641464
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \

deps/googletest/include/gtest/internal/gtest-port.h

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,24 @@
363363
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
364364
#endif
365365

366-
// Clang on Windows does not understand MSVC's pragma warning.
367-
// We need clang-specific way to disable function deprecation warning.
368-
#ifdef __clang__
369-
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#define GTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#define GTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#define GTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#define GTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#define GTEST_DISABLE_DEPRECATED_PUSH_()
383+
#define GTEST_DISABLE_DEPRECATED_POP_()
378384
#endif
379385

380386
// Brings in definitions for functions used in the testing::internal::posix
@@ -2119,7 +2125,7 @@ inline int IsATTY(int fd) {
21192125

21202126
// Functions deprecated by MSVC 8.0.
21212127

2122-
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
2128+
GTEST_DISABLE_DEPRECATED_PUSH_()
21232129

21242130
// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
21252131
// StrError() aren't needed on Windows CE at this time and thus not
@@ -2181,7 +2187,7 @@ inline const char* GetEnv(const char* name) {
21812187
#endif
21822188
}
21832189

2184-
GTEST_DISABLE_MSC_DEPRECATED_POP_()
2190+
GTEST_DISABLE_DEPRECATED_POP_()
21852191

21862192
#ifdef GTEST_OS_WINDOWS_MOBILE
21872193
// Windows CE has no C library. The abort() function is used in
@@ -2302,22 +2308,29 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
23022308

23032309
// Macros for defining flags.
23042310
#define GTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespace testing { \
23062313
GTEST_API_ bool GTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#define GTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespace testing { \
23112319
GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#define GTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespace testing { \
23162325
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val); \
23172326
} \
23182327
static_assert(true, "no-op to require trailing semicolon")
23192328

23202329
// Macros for declaring flags.
2330+
//
2331+
// We also need to declare the flag in the public namespace to avoid triggering
2332+
// -Wmissing-variable-declarations warnings, as reported here:
2333+
// https://github.com/google/googletest/issues/4897
23212334
#define GTEST_DECLARE_bool_(name) \
23222335
namespace testing { \
23232336
GTEST_API_ extern bool GTEST_FLAG(name); \

deps/googletest/src/gtest-internal-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ class GTEST_API_ UnitTestImpl {
587587
// total_test_suite_count() - 1. If i is not in that range, returns NULL.
588588
const TestSuite* GetTestSuite(int i) const {
589589
const int index = GetElementOr(test_suite_indices_, i, -1);
590-
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(i)];
590+
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(index)];
591591
}
592592

593593
// Legacy API is deprecated but still available
@@ -1106,7 +1106,7 @@ class StreamingListener : public EmptyTestEventListener {
11061106
GTEST_CHECK_(sockfd_ != -1)
11071107
<< "Send() can be called only when there is a connection.";
11081108

1109-
const auto len = static_cast<size_t>(message.length());
1109+
const size_t len = message.length();
11101110
if (write(sockfd_, message.c_str(), len) != static_cast<ssize_t>(len)) {
11111111
GTEST_LOG_(WARNING) << "stream_result_to: failed to stream to "
11121112
<< host_name_ << ":" << port_num_;

deps/googletest/src/gtest-port.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ GTestLog::~GTestLog() {
10691069

10701070
// Disable Microsoft deprecation warnings for POSIX functions called from
10711071
// this class (creat, dup, dup2, and close)
1072-
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
1072+
GTEST_DISABLE_DEPRECATED_PUSH_()
10731073

10741074
namespace {
10751075

@@ -1095,10 +1095,12 @@ class CapturedStream {
10951095
0, // Generate unique file name.
10961096
temp_file_path);
10971097
GTEST_CHECK_(success != 0)
1098-
<< "Unable to create a temporary file in " << temp_dir_path;
1098+
<< "Failed to create temporary file in " << temp_dir_path
1099+
<< " with error " << ::GetLastError();
10991100
const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
11001101
GTEST_CHECK_(captured_fd != -1)
1101-
<< "Unable to open temporary file " << temp_file_path;
1102+
<< "Failed to open temporary file " << temp_file_path << " with error "
1103+
<< ::GetLastError();
11021104
filename_ = temp_file_path;
11031105
#else
11041106
// There's no guarantee that a test has write access to the current
@@ -1200,7 +1202,7 @@ class CapturedStream {
12001202
CapturedStream& operator=(const CapturedStream&) = delete;
12011203
};
12021204

1203-
GTEST_DISABLE_MSC_DEPRECATED_POP_()
1205+
GTEST_DISABLE_DEPRECATED_POP_()
12041206

12051207
static CapturedStream* g_captured_stderr = nullptr;
12061208
static CapturedStream* g_captured_stdout = nullptr;

deps/googletest/src/gtest.cc

Lines changed: 11 additions & 9 deletions

0 commit comments

Comments
 (0)