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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
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
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-
explicitAssertionResult(
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+
explicitAssertionResult(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+
explicitAssertionResult(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+
namespaceinternal {
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+
structAssertionResultExpectation {
241+
testing::AssertionResult assertion_result;
242+
bool expected_result;
243+
244+
explicitoperatorbool() const {
245+
boolconverted(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
staticvoidPrint(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
staticvoidPrint(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
962962
};
963963

964+
structUniversalPrinterVisitor {
965+
template <typename T>
966+
voidoperator()(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
staticvoidPrint(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-
structVisitor {
976-
template <typename U>
977-
voidoperator()(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+
staticvoidPrint(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
#defineGTEST_EXPECT_TRUE(condition) \
18191819
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
18201820
GTEST_NONFATAL_FAILURE_)
1821-
#defineGTEST_EXPECT_FALSE(condition) \
1822-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1821+
#defineGTEST_EXPECT_FALSE(condition) \
1822+
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
18231823
GTEST_NONFATAL_FAILURE_)
18241824
#defineGTEST_ASSERT_TRUE(condition) \
18251825
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
1826-
#defineGTEST_ASSERT_FALSE(condition) \
1827-
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1828-
GTEST_FATAL_FAILURE_)
1826+
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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
#defineGTEST_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-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
366+
// Pragmas to disable function deprecation warnings.
367+
#if defined(__clang__)
368+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
370369
_Pragma("clang diagnostic push") \
371370
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
372371
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
373-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
372+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
373+
#elif defined(__GNUC__)
374+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() \
375+
_Pragma("GCC diagnostic push") \
376+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
377+
#defineGTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
378+
#elif defined(_MSC_VER)
379+
#defineGTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
380+
#defineGTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
374381
#else
375-
#defineGTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
376-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
377-
#defineGTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
382+
#defineGTEST_DISABLE_DEPRECATED_PUSH_()
383+
#defineGTEST_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
#defineGTEST_DEFINE_bool_(name, default_val, doc) \
2311+
GTEST_DECLARE_bool_(name); \
23052312
namespacetesting { \
23062313
GTEST_API_boolGTEST_FLAG(name) = (default_val); \
23072314
} \
23082315
static_assert(true, "no-op to require trailing semicolon")
23092316
#defineGTEST_DEFINE_int32_(name, default_val, doc) \
2317+
GTEST_DECLARE_int32_(name); \
23102318
namespacetesting { \
23112319
GTEST_API_ std::int32_tGTEST_FLAG(name) = (default_val); \
23122320
} \
23132321
static_assert(true, "no-op to require trailing semicolon")
23142322
#defineGTEST_DEFINE_string_(name, default_val, doc) \
2323+
GTEST_DECLARE_string_(name); \
23152324
namespacetesting { \
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
#defineGTEST_DECLARE_bool_(name) \
23222335
namespacetesting { \
23232336
GTEST_API_externboolGTEST_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
constint 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-
constauto len = static_cast<size_t>(message.length());
1109+
constsize_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
constint 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
returnos_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 <classT, 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-
returnstatic_cast<Result>(0);
2751+
returnResult();
27522752
#else
27532753
returnHandleSehExceptionsInMethodIfSupported(object, method, location);
27542754
#endif// GTEST_HAS_EXCEPTIONS
@@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
42394239
for (;;) {
42404240
constchar* 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-
conststd::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)