Skip to content

Commit 261d78d

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 3133097 commit 261d78d

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
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,18 @@ class GTEST_API_ [[nodiscard]] AssertionResult {
158158
// The second parameter prevents this overload from being considered if
159159
// the argument is implicitly convertible to AssertionResult. In that case
160160
// we want AssertionResult's copy constructor to be used.
161-
template <typename T>
162-
explicit AssertionResult(
163-
const T& success,
164-
std::enable_if_t<!std::is_convertible_v<T, AssertionResult>>*
165-
/*enabler*/
166-
= nullptr)
167-
: success_(success) {}
161+
template <typename T,
162+
std::enable_if_t<!std::is_convertible_v<T, AssertionResult> &&
163+
!std::is_trivially_constructible_v<bool, T>,
164+
int> = 0>
165+
explicit AssertionResult(T&& success) : success_(std::forward<T>(success)) {}
166+
167+
// Similar to the mutable overload, but for cases where mutability is
168+
// unnecessary or problematic (e.g., bitfields).
169+
template <typename T,
170+
std::enable_if_t<!std::is_convertible_v<const T&, AssertionResult>,
171+
int> = 0>
172+
explicit AssertionResult(const T& success) : success_(success) {}
168173

169174
#if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
170175
GTEST_DISABLE_MSC_WARNINGS_POP_()
@@ -226,6 +231,24 @@ class GTEST_API_ [[nodiscard]] AssertionResult {
226231
std::unique_ptr< ::std::string> message_;
227232
};
228233

234+
namespace internal {
235+
236+
// A pair containing the result that an assertion is evaluating, and the
237+
// expected result (true, false).
238+
//
239+
// Contains a conversion operator that indicates whether the two match.
240+
struct AssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicit operator bool() const {
245+
bool converted(assertion_result);
246+
return converted == expected_result;
247+
}
248+
};
249+
250+
} // namespace internal
251+
229252
// Makes a successful assertion result.
230253
GTEST_API_ AssertionResult AssertionSuccess();
231254

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
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ int UnitTestImpl::test_to_run_count() const {
12091209
// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
12101210
std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
12111211
return os_stack_trace_getter()->CurrentStackTrace(
1212-
static_cast<int>(GTEST_FLAG_GET(stack_trace_depth)), skip_count + 1
1212+
GTEST_FLAG_GET(stack_trace_depth), skip_count + 1
12131213
// Skips the user-specified number of frames plus this function
12141214
// itself.
12151215
); // NOLINT
@@ -2700,7 +2700,7 @@ Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
27002700
}
27012701

27022702
// Runs the given method and catches and reports C++ and/or SEH-style
2703-
// exceptions, if they are supported; returns the 0-value for type
2703+
// exceptions, if they are supported; returns the default-value for type
27042704
// Result in case of an SEH exception.
27052705
template <class T, typename Result>
27062706
Result HandleExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
@@ -2748,7 +2748,7 @@ Result HandleExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
27482748
TestPartResult::kFatalFailure,
27492749
FormatCxxExceptionMessage(nullptr, location));
27502750
}
2751-
return static_cast<Result>(0);
2751+
return Result();
27522752
#else
27532753
return HandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif // GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
const char* const next_segment = strstr(segment, "]]>");
42414241
if (next_segment != nullptr) {
4242-
stream->write(segment,
4243-
static_cast<std::streamsize>(next_segment - segment));
4242+
stream->write(segment, next_segment - segment);
42444243
*stream << "]]>]]&gt;<![CDATA[";
42454244
segment = next_segment + strlen("]]>");
42464245
} else {
@@ -5172,9 +5171,12 @@ class ScopedPrematureExitFile {
51725171
// create the file with a single "0" character in it. I/O
51735172
// errors are ignored as there's nothing better we can do and we
51745173
// don't want to fail the test because of this.
5175-
FILE* pfile = posix::FOpen(premature_exit_filepath_.c_str(), "w");
5176-
fwrite("0", 1, 1, pfile);
5177-
fclose(pfile);
5174+
if (FILE* pfile = posix::FOpen(premature_exit_filepath_.c_str(), "w")) {
5175+
fwrite("0", 1, 1, pfile);
5176+
fclose(pfile);
5177+
} else {
5178+
premature_exit_filepath_.clear();
5179+
}
51785180
}
51795181
}
51805182

@@ -5192,7 +5194,7 @@ class ScopedPrematureExitFile {
51925194
}
51935195

51945196
private:
5195-
const std::string premature_exit_filepath_;
5197+
std::string premature_exit_filepath_;
51965198

51975199
ScopedPrematureExitFile(const ScopedPrematureExitFile&) = delete;
51985200
ScopedPrematureExitFile& operator=(const ScopedPrematureExitFile&) = delete;

0 commit comments

Comments
 (0)