Skip to content

Commit 36b639b

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update googletest to e9092b1
PR-URL: #58565 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 104d173 commit 36b639b

File tree

6 files changed

+97
-207
lines changed

6 files changed

+97
-207
lines changed

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

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,19 @@
104104
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
105105
#define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
106106

107+
#include <any>
107108
#include <functional>
108109
#include <memory>
110+
#include <optional>
109111
#include <ostream> // NOLINT
110112
#include <sstream>
111113
#include <string>
114+
#include <string_view>
112115
#include <tuple>
113116
#include <type_traits>
114117
#include <typeinfo>
115118
#include <utility>
119+
#include <variant>
116120
#include <vector>
117121

118122
#ifdef GTEST_HAS_ABSL
@@ -245,8 +249,8 @@ struct StreamPrinter {
245249
// ADL (possibly involving implicit conversions).
246250
// (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name
247251
// lookup properly when we do it in the template parameter list.)
248-
static auto PrintValue(const T& value,
249-
::std::ostream* os) -> decltype((void)(*os << value)) {
252+
static auto PrintValue(const T& value, ::std::ostream* os)
253+
-> decltype((void)(*os << value)) {
250254
// Call streaming operator found by ADL, possibly with implicit conversions
251255
// of the arguments.
252256
*os << value;
@@ -521,11 +525,15 @@ GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
521525

522526
GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
523527
inline void PrintTo(char16_t c, ::std::ostream* os) {
524-
PrintTo(ImplicitCast_<char32_t>(c), os);
528+
// TODO(b/418738869): Incorrect for values not representing valid codepoints.
529+
// Also see https://github.com/google/googletest/issues/4762.
530+
PrintTo(static_cast<char32_t>(c), os);
525531
}
526532
#ifdef __cpp_lib_char8_t
527533
inline void PrintTo(char8_t c, ::std::ostream* os) {
528-
PrintTo(ImplicitCast_<char32_t>(c), os);
534+
// TODO(b/418738869): Incorrect for values not representing valid codepoints.
535+
// Also see https://github.com/google/googletest/issues/4762.
536+
PrintTo(static_cast<char32_t>(c), os);
529537
}
530538
#endif
531539

@@ -695,44 +703,63 @@ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
695703
}
696704
}
697705

698-
// Overloads for ::std::string.
699-
GTEST_API_ void PrintStringTo(const ::std::string& s, ::std::ostream* os);
706+
// Overloads for ::std::string and ::std::string_view
707+
GTEST_API_ void PrintStringTo(::std::string_view s, ::std::ostream* os);
700708
inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
701709
PrintStringTo(s, os);
702710
}
711+
inline void PrintTo(::std::string_view s, ::std::ostream* os) {
712+
PrintStringTo(s, os);
713+
}
703714

704-
// Overloads for ::std::u8string
715+
// Overloads for ::std::u8string and ::std::u8string_view
705716
#ifdef __cpp_lib_char8_t
706-
GTEST_API_ void PrintU8StringTo(const ::std::u8string& s, ::std::ostream* os);
717+
GTEST_API_ void PrintU8StringTo(::std::u8string_view s, ::std::ostream* os);
707718
inline void PrintTo(const ::std::u8string& s, ::std::ostream* os) {
708719
PrintU8StringTo(s, os);
709720
}
721+
inline void PrintTo(::std::u8string_view s, ::std::ostream* os) {
722+
PrintU8StringTo(s, os);
723+
}
710724
#endif
711725

712-
// Overloads for ::std::u16string
713-
GTEST_API_ void PrintU16StringTo(const ::std::u16string& s, ::std::ostream* os);
726+
// Overloads for ::std::u16string and ::std::u16string_view
727+
GTEST_API_ void PrintU16StringTo(::std::u16string_view s, ::std::ostream* os);
714728
inline void PrintTo(const ::std::u16string& s, ::std::ostream* os) {
715729
PrintU16StringTo(s, os);
716730
}
731+
inline void PrintTo(::std::u16string_view s, ::std::ostream* os) {
732+
PrintU16StringTo(s, os);
733+
}
717734

718-
// Overloads for ::std::u32string
719-
GTEST_API_ void PrintU32StringTo(const ::std::u32string& s, ::std::ostream* os);
735+
// Overloads for ::std::u32string and ::std::u32string_view
736+
GTEST_API_ void PrintU32StringTo(::std::u32string_view s, ::std::ostream* os);
720737
inline void PrintTo(const ::std::u32string& s, ::std::ostream* os) {
721738
PrintU32StringTo(s, os);
722739
}
740+
inline void PrintTo(::std::u32string_view s, ::std::ostream* os) {
741+
PrintU32StringTo(s, os);
742+
}
723743

724-
// Overloads for ::std::wstring.
744+
// Overloads for ::std::wstring and ::std::wstring_view
725745
#if GTEST_HAS_STD_WSTRING
726-
GTEST_API_ void PrintWideStringTo(const ::std::wstring& s, ::std::ostream* os);
746+
GTEST_API_ void PrintWideStringTo(::std::wstring_view s, ::std::ostream* os);
727747
inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
728748
PrintWideStringTo(s, os);
729749
}
750+
inline void PrintTo(::std::wstring_view s, ::std::ostream* os) {
751+
PrintWideStringTo(s, os);
752+
}
730753
#endif // GTEST_HAS_STD_WSTRING
731754

732755
#if GTEST_INTERNAL_HAS_STRING_VIEW
733-
// Overload for internal::StringView.
756+
// Overload for internal::StringView. Needed for build configurations where
757+
// internal::StringView is an alias for absl::string_view, but absl::string_view
758+
// is a distinct type from std::string_view.
759+
template <int&... ExplicitArgumentBarrier, typename T = internal::StringView,
760+
std::enable_if_t<!std::is_same_v<T, ::std::string_view>, int> = 0>
734761
inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
735-
PrintTo(::std::string(sp), os);
762+
PrintStringTo(sp, os);
736763
}
737764
#endif // GTEST_INTERNAL_HAS_STRING_VIEW
738765

@@ -890,14 +917,11 @@ class UniversalPrinter {
890917
template <typename T>
891918
class UniversalPrinter<const T> : public UniversalPrinter<T> {};
892919

893-
#if GTEST_INTERNAL_HAS_ANY
894-
895-
// Printer for std::any / absl::any
896-
920+
// Printer for std::any
897921
template <>
898-
class UniversalPrinter<Any> {
922+
class UniversalPrinter<std::any> {
899923
public:
900-
static void Print(const Any& value, ::std::ostream* os) {
924+
static void Print(const std::any& value, ::std::ostream* os) {
901925
if (value.has_value()) {
902926
*os << "value of type " << GetTypeName(value);
903927
} else {
@@ -906,7 +930,7 @@ class UniversalPrinter<Any> {
906930
}
907931

908932
private:
909-
static std::string GetTypeName(const Any& value) {
933+
static std::string GetTypeName(const std::any& value) {
910934
#if GTEST_HAS_RTTI
911935
return internal::GetTypeName(value.type());
912936
#else
@@ -916,16 +940,11 @@ class UniversalPrinter<Any> {
916940
}
917941
};
918942

919-
#endif // GTEST_INTERNAL_HAS_ANY
920-
921-
#if GTEST_INTERNAL_HAS_OPTIONAL
922-
923-
// Printer for std::optional / absl::optional
924-
943+
// Printer for std::optional
925944
template <typename T>
926-
class UniversalPrinter<Optional<T>> {
945+
class UniversalPrinter<std::optional<T>> {
927946
public:
928-
static void Print(const Optional<T>& value, ::std::ostream* os) {
947+
static void Print(const std::optional<T>& value, ::std::ostream* os) {
929948
*os << '(';
930949
if (!value) {
931950
*os << "nullopt";
@@ -937,29 +956,18 @@ class UniversalPrinter<Optional<T>> {
937956
};
938957

939958
template <>
940-
class UniversalPrinter<decltype(Nullopt())> {
959+
class UniversalPrinter<std::nullopt_t> {
941960
public:
942-
static void Print(decltype(Nullopt()), ::std::ostream* os) {
943-
*os << "(nullopt)";
944-
}
961+
static void Print(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
945962
};
946963

947-
#endif // GTEST_INTERNAL_HAS_OPTIONAL
948-
949-
#if GTEST_INTERNAL_HAS_VARIANT
950-
951-
// Printer for std::variant / absl::variant
952-
964+
// Printer for std::variant
953965
template <typename... T>
954-
class UniversalPrinter<Variant<T...>> {
966+
class UniversalPrinter<std::variant<T...>> {
955967
public:
956-
static void Print(const Variant<T...>& value, ::std::ostream* os) {
968+
static void Print(const std::variant<T...>& value, ::std::ostream* os) {
957969
*os << '(';
958-
#ifdef GTEST_HAS_ABSL
959-
absl::visit(Visitor{os, value.index()}, value);
960-
#else
961970
std::visit(Visitor{os, value.index()}, value);
962-
#endif // GTEST_HAS_ABSL
963971
*os << ')';
964972
}
965973

@@ -976,8 +984,6 @@ class UniversalPrinter<Variant<T...>> {
976984
};
977985
};
978986

979-
#endif // GTEST_INTERNAL_HAS_VARIANT
980-
981987
// UniversalPrintArray(begin, len, os) prints an array of 'len'
982988
// elements, starting at address 'begin'.
983989
template <typename T>

deps/googletest/include/gtest/gtest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ class WithParamInterface {
16931693

16941694
// The current parameter value. Is also available in the test fixture's
16951695
// constructor.
1696-
static const ParamType& GetParam() {
1696+
[[nodiscard]] static const ParamType& GetParam() {
16971697
GTEST_CHECK_(parameter_ != nullptr)
16981698
<< "GetParam() can only be called inside a value-parameterized test "
16991699
<< "-- did you intend to write TEST_P instead of TEST_F?";

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

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,17 @@ class FloatingPoint {
290290
// around may change its bits, although the new value is guaranteed
291291
// to be also a NAN. Therefore, don't expect this constructor to
292292
// preserve the bits in x when x is a NAN.
293-
explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
293+
explicit FloatingPoint(RawType x) { memcpy(&bits_, &x, sizeof(x)); }
294294

295295
// Static methods
296296

297297
// Reinterprets a bit pattern as a floating-point number.
298298
//
299299
// This function is needed to test the AlmostEquals() method.
300-
static RawType ReinterpretBits(const Bits bits) {
301-
FloatingPoint fp(0);
302-
fp.u_.bits_ = bits;
303-
return fp.u_.value_;
300+
static RawType ReinterpretBits(Bits bits) {
301+
RawType fp;
302+
memcpy(&fp, &bits, sizeof(fp));
303+
return fp;
304304
}
305305

306306
// Returns the floating-point number that represent positive infinity.
@@ -309,16 +309,16 @@ class FloatingPoint {
309309
// Non-static methods
310310

311311
// Returns the bits that represents this number.
312-
const Bits& bits() const { return u_.bits_; }
312+
const Bits& bits() const { return bits_; }
313313

314314
// Returns the exponent bits of this number.
315-
Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
315+
Bits exponent_bits() const { return kExponentBitMask & bits_; }
316316

317317
// Returns the fraction bits of this number.
318-
Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
318+
Bits fraction_bits() const { return kFractionBitMask & bits_; }
319319

320320
// Returns the sign bit of this number.
321-
Bits sign_bit() const { return kSignBitMask & u_.bits_; }
321+
Bits sign_bit() const { return kSignBitMask & bits_; }
322322

323323
// Returns true if and only if this is NAN (not a number).
324324
bool is_nan() const {
@@ -332,23 +332,16 @@ class FloatingPoint {
332332
//
333333
// - returns false if either number is (or both are) NAN.
334334
// - treats really large numbers as almost equal to infinity.
335-
// - thinks +0.0 and -0.0 are 0 DLP's apart.
335+
// - thinks +0.0 and -0.0 are 0 ULP's apart.
336336
bool AlmostEquals(const FloatingPoint& rhs) const {
337337
// The IEEE standard says that any comparison operation involving
338338
// a NAN must return false.
339339
if (is_nan() || rhs.is_nan()) return false;
340340

341-
return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) <=
342-
kMaxUlps;
341+
return DistanceBetweenSignAndMagnitudeNumbers(bits_, rhs.bits_) <= kMaxUlps;
343342
}
344343

345344
private:
346-
// The data type used to store the actual floating-point number.
347-
union FloatingPointUnion {
348-
RawType value_; // The raw floating-point number.
349-
Bits bits_; // The bits that represent the number.
350-
};
351-
352345
// Converts an integer from the sign-and-magnitude representation to
353346
// the biased representation. More precisely, let N be 2 to the
354347
// power of (kBitCount - 1), an integer x is represented by the
@@ -364,7 +357,7 @@ class FloatingPoint {
364357
//
365358
// Read https://en.wikipedia.org/wiki/Signed_number_representations
366359
// for more details on signed number representations.
367-
static Bits SignAndMagnitudeToBiased(const Bits& sam) {
360+
static Bits SignAndMagnitudeToBiased(Bits sam) {
368361
if (kSignBitMask & sam) {
369362
// sam represents a negative number.
370363
return ~sam + 1;
@@ -376,14 +369,13 @@ class FloatingPoint {
376369

377370
// Given two numbers in the sign-and-magnitude representation,
378371
// returns the distance between them as an unsigned number.
379-
static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits& sam1,
380-
const Bits& sam2) {
372+
static Bits DistanceBetweenSignAndMagnitudeNumbers(Bits sam1, Bits sam2) {
381373
const Bits biased1 = SignAndMagnitudeToBiased(sam1);
382374
const Bits biased2 = SignAndMagnitudeToBiased(sam2);
383375
return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
384376
}
385377

386-
FloatingPointUnion u_;
378+
Bits bits_; // The bits that represent the number.
387379
};
388380

389381
// Typedefs the instances of the FloatingPoint template class that we

0 commit comments

Comments
 (0)