GeezerVison is showing github.com — deps: update googletest to d89aac5f0dd4021198d903d39de16f896726de21 · nodejs/node@96b4af1
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: deps/googletest/include/gtest/gtest-matchers.h +33-17Lines changed: 33 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 45 | 45 | #include <memory> | 46 | 46 | #include <ostream> | 47 | 47 | #include <string> | | 48 | +#include <string_view> | 48 | 49 | #include <type_traits> | 49 | 50 |
| 50 | 51 | #include "gtest/gtest-printers.h" | @@ -543,9 +544,8 @@ Matcher<std::string> : public internal::MatcherBase<std::string> { | 543 | 544 | Matcher(const char* s); // NOLINT | 544 | 545 | }; | 545 | 546 |
| 546 | | -#if GTEST_INTERNAL_HAS_STRING_VIEW | 547 | 547 | // The following two specializations allow the user to write str | 548 | | -// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view | | 548 | +// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string_view | 549 | 549 | // matcher is expected. | 550 | 550 | template <> | 551 | 551 | class GTEST_API_ [[nodiscard]] Matcher<const internal::StringView&> | @@ -569,7 +569,7 @@ class GTEST_API_ [[nodiscard]] Matcher<const internal::StringView&> | 569 | 569 | // Allows the user to write "foo" instead of Eq("foo") sometimes. | 570 | 570 | Matcher(const char* s); // NOLINT | 571 | 571 |
| 572 | | - // Allows the user to pass absl::string_views or std::string_views directly. | | 572 | + // Allows the user to pass std::string_views directly. | 573 | 573 | Matcher(internal::StringView s); // NOLINT | 574 | 574 | }; | 575 | 575 |
| @@ -596,10 +596,9 @@ class GTEST_API_ [[nodiscard]] Matcher<internal::StringView> | 596 | 596 | // Allows the user to write "foo" instead of Eq("foo") sometimes. | 597 | 597 | Matcher(const char* s); // NOLINT | 598 | 598 |
| 599 | | - // Allows the user to pass absl::string_views or std::string_views directly. | | 599 | + // Allows the user to pass std::string_views directly. | 600 | 600 | Matcher(internal::StringView s); // NOLINT | 601 | 601 | }; | 602 | | -#endif // GTEST_INTERNAL_HAS_STRING_VIEW | 603 | 602 |
| 604 | 603 | // Prints a matcher in a human-readable format. | 605 | 604 | template <typename T> | @@ -812,9 +811,26 @@ class [[nodiscard]] ImplicitCastEqMatcher { | 812 | 811 | StoredRhs stored_rhs_; | 813 | 812 | }; | 814 | 813 |
| 815 | | -template <typename T, | 816 | | - typename = std::enable_if_t<std::is_constructible_v<std::string, T>>> | 817 | | -using StringLike = T; | | 814 | +// Dummy function (never defined) whose return type evaluates to std::string if | | 815 | +// the given type is a string-like type that can be converted to std::string, | | 816 | +// either directly or through an intermediate std::string_view. | | 817 | +template <class T> | | 818 | +extern std::enable_if_t<std::is_constructible_v<std::string, T>, std::string> | | 819 | +ResolveAsString(const void* /* preferred */); | | 820 | + | | 821 | +#if GTEST_HAS_STD_WSTRING | | 822 | +// Same as above, but for std::wstring. In cases where both conversions are | | 823 | +// possible, this overload takes lower priority. | | 824 | +template <class T> | | 825 | +extern std::enable_if_t<std::is_constructible_v<std::wstring, T>, std::wstring> | | 826 | +ResolveAsString(... /* fallback */); | | 827 | +#endif | | 828 | + | | 829 | +// Evaluates to the std::basic_string type that the given string-like type can | | 830 | +// be converted to. Prefers std::string over std::wstring if both are possible. | | 831 | +// Fails in a SFINAE-friendly way if no conversion was viable. | | 832 | +template <typename T> | | 833 | +using StringType = decltype(ResolveAsString<T>(nullptr)); | 818 | 834 |
| 819 | 835 | // Implements polymorphic matchers MatchesRegex(regex) and | 820 | 836 | // ContainsRegex(regex), which can be used as a Matcher<T> as long as | @@ -824,12 +840,10 @@ class [[nodiscard]] MatchesRegexMatcher { | 824 | 840 | MatchesRegexMatcher(const RE* regex, bool full_match) | 825 | 841 | : regex_(regex), full_match_(full_match) {} | 826 | 842 |
| 827 | | -#if GTEST_INTERNAL_HAS_STRING_VIEW | 828 | 843 | bool MatchAndExplain(const internal::StringView& s, | 829 | 844 | MatchResultListener* listener) const { | 830 | 845 | return MatchAndExplain(std::string(s), listener); | 831 | 846 | } | 832 | | -#endif // GTEST_INTERNAL_HAS_STRING_VIEW | 833 | 847 |
| 834 | 848 | // Accepts pointer types, particularly: | 835 | 849 | // const char* | @@ -844,7 +858,7 @@ class [[nodiscard]] MatchesRegexMatcher { | 844 | 858 | // Matches anything that can convert to std::string. | 845 | 859 | // | 846 | 860 | // This is a template, not just a plain function with const std::string&, | 847 | | - // because absl::string_view has some interfering non-explicit constructors. | | 861 | + // because std::string_view has some interfering non-explicit constructors. | 848 | 862 | template <class MatcheeStringType> | 849 | 863 | bool MatchAndExplain(const MatcheeStringType& s, | 850 | 864 | MatchResultListener* /* listener */) const { | @@ -877,9 +891,10 @@ inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex( | 877 | 891 | return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true)); | 878 | 892 | } | 879 | 893 | template <typename T = std::string> | 880 | | -PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex( | 881 | | - const internal::StringLike<T>& regex) { | 882 | | - return MatchesRegex(new internal::RE(std::string(regex))); | | 894 | +std::enable_if_t<std::is_constructible_v<internal::RE, internal::StringType<T>>, | | 895 | + PolymorphicMatcher<internal::MatchesRegexMatcher>> | | 896 | +MatchesRegex(const T& regex) { | | 897 | + return MatchesRegex(new internal::RE(internal::StringType<T>(regex))); | 883 | 898 | } | 884 | 899 |
| 885 | 900 | // Matches a string that contains regular expression 'regex'. | @@ -889,9 +904,10 @@ inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex( | 889 | 904 | return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false)); | 890 | 905 | } | 891 | 906 | template <typename T = std::string> | 892 | | -PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex( | 893 | | - const internal::StringLike<T>& regex) { | 894 | | - return ContainsRegex(new internal::RE(std::string(regex))); | | 907 | +std::enable_if_t<std::is_constructible_v<internal::RE, internal::StringType<T>>, | | 908 | + PolymorphicMatcher<internal::MatchesRegexMatcher>> | | 909 | +ContainsRegex(const T& regex) { | | 910 | + return ContainsRegex(new internal::RE(internal::StringType<T>(regex))); | 895 | 911 | } | 896 | 912 |
| 897 | 913 | // Creates a polymorphic matcher that matches anything equal to x. | |
Collapse file Copy file name to clipboardExpand all lines: deps/googletest/include/gtest/gtest-printers.h +4-8Lines changed: 4 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -291,11 +291,9 @@ struct ConvertibleToIntegerPrinter { | 291 | 291 | }; | 292 | 292 |
| 293 | 293 | struct ConvertibleToStringViewPrinter { | 294 | | -#if GTEST_INTERNAL_HAS_STRING_VIEW | 295 | 294 | static void PrintValue(internal::StringView value, ::std::ostream* os) { | 296 | 295 | internal::UniversalPrint(value, os); | 297 | 296 | } | 298 | | -#endif | 299 | 297 | }; | 300 | 298 |
| 301 | 299 | #ifdef GTEST_HAS_ABSL | @@ -703,12 +701,12 @@ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) { | 703 | 701 | } | 704 | 702 | } | 705 | 703 |
| 706 | | -// Overloads for ::std::string and ::std::string_view | 707 | | -GTEST_API_ void PrintStringTo(::std::string_view s, ::std::ostream* os); | | 704 | +// Overloads for ::std::string and std::string_view | | 705 | +GTEST_API_ void PrintStringTo(std::string_view s, ::std::ostream* os); | 708 | 706 | inline void PrintTo(const ::std::string& s, ::std::ostream* os) { | 709 | 707 | PrintStringTo(s, os); | 710 | 708 | } | 711 | | -inline void PrintTo(::std::string_view s, ::std::ostream* os) { | | 709 | +inline void PrintTo(std::string_view s, ::std::ostream* os) { | 712 | 710 | PrintStringTo(s, os); | 713 | 711 | } | 714 | 712 |
| @@ -752,16 +750,14 @@ inline void PrintTo(::std::wstring_view s, ::std::ostream* os) { | 752 | 750 | } | 753 | 751 | #endif // GTEST_HAS_STD_WSTRING | 754 | 752 |
| 755 | | -#if GTEST_INTERNAL_HAS_STRING_VIEW | 756 | 753 | // Overload for internal::StringView. Needed for build configurations where | 757 | 754 | // internal::StringView is an alias for absl::string_view, but absl::string_view | 758 | 755 | // is a distinct type from std::string_view. | 759 | 756 | template <int&... ExplicitArgumentBarrier, typename T = internal::StringView, | 760 | | - std::enable_if_t<!std::is_same_v<T, ::std::string_view>, int> = 0> | | 757 | + std::enable_if_t<!std::is_same_v<T, std::string_view>, int> = 0> | 761 | 758 | inline void PrintTo(internal::StringView sp, ::std::ostream* os) { | 762 | 759 | PrintStringTo(sp, os); | 763 | 760 | } | 764 | | -#endif // GTEST_INTERNAL_HAS_STRING_VIEW | 765 | 761 |
| 766 | 762 | inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } | 767 | 763 |
| |
Collapse file Copy file name to clipboardExpand all lines: deps/googletest/include/gtest/internal/gtest-death-test-internal.h +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 43 | 43 |
| 44 | 44 | #include <memory> | 45 | 45 | #include <string> | | 46 | +#include <string_view> | 46 | 47 |
| 47 | 48 | #include "gtest/gtest-matchers.h" | 48 | 49 | #include "gtest/internal/gtest-internal.h" | @@ -63,6 +64,10 @@ inline Matcher<const ::std::string&> MakeDeathTestMatcher( | 63 | 64 | ::testing::internal::RE regex) { | 64 | 65 | return ContainsRegex(regex.pattern()); | 65 | 66 | } | | 67 | +inline Matcher<const ::std::string&> MakeDeathTestMatcher( | | 68 | + std::string_view regex) { | | 69 | + return ContainsRegex(regex); | | 70 | +} | 66 | 71 | inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) { | 67 | 72 | return ContainsRegex(regex); | 68 | 73 | } | |
Collapse file Copy file name to clipboardExpand all lines: deps/googletest/include/gtest/internal/gtest-internal.h +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1451,13 +1451,13 @@ class [[nodiscard]] NeverThrown { | 1451 | 1451 | // Implements Boolean test assertions such as EXPECT_TRUE. expression can be | 1452 | 1452 | // either a boolean expression or an AssertionResult. text is a textual | 1453 | 1453 | // representation of expression as it was passed into the EXPECT_TRUE. | 1454 | | -#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ | 1455 | | - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | 1456 | | - if (::testing::internal::AssertionResultExpectation gtest_are_ = { \ | 1457 | | - ::testing::AssertionResult(expression), expected}) \ | 1458 | | - ; \ | 1459 | | - else \ | 1460 | | - fail(::testing::internal::GetBoolAssertionFailureMessage( \ | | 1454 | +#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ | | 1455 | + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | | 1456 | + if (const ::testing::internal::AssertionResultExpectation gtest_are_ = { \ | | 1457 | + ::testing::AssertionResult(expression), expected}) \ | | 1458 | + ; \ | | 1459 | + else /* NOLINT */ \ | | 1460 | + fail(::testing::internal::GetBoolAssertionFailureMessage( \ | 1461 | 1461 | gtest_are_.assertion_result, text, #actual, #expected)) | 1462 | 1462 |
| 1463 | 1463 | #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ | |
Collapse file Copy file name to clipboardExpand all lines: deps/googletest/include/gtest/internal/gtest-port.h +10-21Lines changed: 10 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 293 | 293 | #include <limits> | 294 | 294 | #include <locale> | 295 | 295 | #include <memory> | | 296 | +// #include <mutex> // Guarded by GTEST_IS_THREADSAFE below | 296 | 297 | #include <ostream> | 297 | 298 | #include <string> | 298 | | -// #include <mutex> // Guarded by GTEST_IS_THREADSAFE below | | 299 | +#include <string_view> | 299 | 300 | #include <tuple> | 300 | 301 | #include <type_traits> | 301 | 302 | #include <vector> | @@ -949,21 +950,21 @@ GTEST_API_ bool IsTrue(bool condition); | 949 | 950 | #ifdef GTEST_USES_RE2 | 950 | 951 |
| 951 | 952 | // This is almost `using RE = ::RE2`, except it is copy-constructible, and it | 952 | | -// needs to disambiguate the `std::string`, `absl::string_view`, and `const | | 953 | +// needs to disambiguate the `std::string`, `std::string_view`, and `const | 953 | 954 | // char*` constructors. | 954 | 955 | class GTEST_API_ [[nodiscard]] RE { | 955 | 956 | public: | 956 | | - RE(absl::string_view regex) : regex_(regex) {} // NOLINT | 957 | | - RE(const char* regex) : RE(absl::string_view(regex)) {} // NOLINT | 958 | | - RE(const std::string& regex) : RE(absl::string_view(regex)) {} // NOLINT | | 957 | + RE(std::string_view regex) : regex_(regex) {} // NOLINT | | 958 | + RE(const char* regex) : RE(std::string_view(regex)) {} // NOLINT | | 959 | + RE(const std::string& regex) : RE(std::string_view(regex)) {} // NOLINT | 959 | 960 | RE(const RE& other) : RE(other.pattern()) {} | 960 | 961 |
| 961 | 962 | const std::string& pattern() const { return regex_.pattern(); } | 962 | 963 |
| 963 | | - static bool FullMatch(absl::string_view str, const RE& re) { | | 964 | + static bool FullMatch(std::string_view str, const RE& re) { | 964 | 965 | return RE2::FullMatch(str, re.regex_); | 965 | 966 | } | 966 | | - static bool PartialMatch(absl::string_view str, const RE& re) { | | 967 | + static bool PartialMatch(std::string_view str, const RE& re) { | 967 | 968 | return RE2::PartialMatch(str, re.regex_); | 968 | 969 | } | 969 | 970 |
| @@ -2396,34 +2397,22 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val); | 2396 | 2397 | #ifdef GTEST_HAS_ABSL | 2397 | 2398 | // Always use absl::string_view for Matcher<> specializations if googletest | 2398 | 2399 | // is built with absl support. | 2399 | | -#define GTEST_INTERNAL_HAS_STRING_VIEW 1 | 2400 | 2400 | #include "absl/strings/string_view.h" | 2401 | 2401 | namespace testing { | 2402 | 2402 | namespace internal { | 2403 | 2403 | using StringView = ::absl::string_view; | 2404 | 2404 | } // namespace internal | 2405 | 2405 | } // namespace testing | 2406 | 2406 | #else | 2407 | | -#if defined(__cpp_lib_string_view) || \ | 2408 | | - (GTEST_INTERNAL_HAS_INCLUDE(<string_view>) && \ | 2409 | | - GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L) | 2410 | 2407 | // Otherwise for C++17 and higher use std::string_view for Matcher<> | 2411 | 2408 | // specializations. | 2412 | | -#define GTEST_INTERNAL_HAS_STRING_VIEW 1 | 2413 | | -#include <string_view> | 2414 | 2409 | namespace testing { | 2415 | 2410 | namespace internal { | 2416 | | -using StringView = ::std::string_view; | | 2411 | +using StringView = std::string_view; | 2417 | 2412 | } // namespace internal | 2418 | 2413 | } // namespace testing | 2419 | | -// The case where absl is configured NOT to alias std::string_view is not | 2420 | | -// supported. | 2421 | | -#endif // __cpp_lib_string_view | 2422 | 2414 | #endif // GTEST_HAS_ABSL | 2423 | | - | 2424 | | -#ifndef GTEST_INTERNAL_HAS_STRING_VIEW | 2425 | | -#define GTEST_INTERNAL_HAS_STRING_VIEW 0 | 2426 | | -#endif | | 2415 | +#define GTEST_INTERNAL_HAS_STRING_VIEW 1 | 2427 | 2416 |
| 2428 | 2417 | #if defined(__cpp_lib_three_way_comparison) | 2429 | 2418 | #define GTEST_INTERNAL_HAS_COMPARE_LIB 1 | |
Collapse file Copy file name to clipboardExpand all lines: deps/googletest/src/gtest-matchers.cc -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,7 +59,6 @@ Matcher<std::string>::Matcher(const std::string& s) { *this = Eq(s); } | 59 | 59 | // s. | 60 | 60 | Matcher<std::string>::Matcher(const char* s) { *this = Eq(std::string(s)); } | 61 | 61 |
| 62 | | -#if GTEST_INTERNAL_HAS_STRING_VIEW | 63 | 62 | // Constructs a matcher that matches a const StringView& whose value is | 64 | 63 | // equal to s. | 65 | 64 | Matcher<const internal::StringView&>::Matcher(const std::string& s) { | @@ -93,6 +92,5 @@ Matcher<internal::StringView>::Matcher(const char* s) { | 93 | 92 | Matcher<internal::StringView>::Matcher(internal::StringView s) { | 94 | 93 | *this = Eq(std::string(s)); | 95 | 94 | } | 96 | | -#endif // GTEST_INTERNAL_HAS_STRING_VIEW | 97 | 95 |
| 98 | 96 | } // namespace testing |
Collapse file Copy file name to clipboardExpand all lines: deps/googletest/src/gtest-printers.cc +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -515,13 +515,13 @@ bool IsValidUTF8(const char* str, size_t length) { | 515 | 515 | void ConditionalPrintAsText(const char* str, size_t length, ostream* os) { | 516 | 516 | if (!ContainsUnprintableControlCodes(str, length) && | 517 | 517 | IsValidUTF8(str, length)) { | 518 | | - *os << "\n As Text: \"" << ::std::string_view(str, length) << "\""; | | 518 | + *os << "\n As Text: \"" << std::string_view(str, length) << "\""; | 519 | 519 | } | 520 | 520 | } | 521 | 521 |
| 522 | 522 | } // anonymous namespace | 523 | 523 |
| 524 | | -void PrintStringTo(::std::string_view s, ostream* os) { | | 524 | +void PrintStringTo(std::string_view s, ostream* os) { | 525 | 525 | if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) { | 526 | 526 | if (GTEST_FLAG_GET(print_utf8)) { | 527 | 527 | ConditionalPrintAsText(s.data(), s.size(), os); | |
Collapse file Copy file name to clipboardExpand all lines: deps/googletest/src/gtest.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -6930,7 +6930,7 @@ void ParseGoogleTestFlagsOnly(int* argc, char** argv) { | 6930 | 6930 | std::vector<char*> positional_args; | 6931 | 6931 | std::vector<absl::UnrecognizedFlag> unrecognized_flags; | 6932 | 6932 | absl::ParseAbseilFlagsOnly(*argc, argv, positional_args, unrecognized_flags); | 6933 | | - absl::flat_hash_set<absl::string_view> unrecognized; | | 6933 | + absl::flat_hash_set<std::string_view> unrecognized; | 6934 | 6934 | for (const auto& flag : unrecognized_flags) { | 6935 | 6935 | unrecognized.insert(flag.flag_name); | 6936 | 6936 | } | |
|