mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
deps: update googletest to d89aac5f0dd4021198d903d39de16f896726de21
PR-URL: https://github.com/nodejs/node/pull/65153 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
01f201888e
commit
2f2dca5d79
8 files changed
+62
-58
No files matched your search
+33
-17
@@ -45,6 +45,7 @@
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include "gtest/gtest-printers.h"
|
||||
@@ -543,9 +544,8 @@ Matcher<std::string> : public internal::MatcherBase<std::string> {
|
||||
Matcher(const char* s); // NOLINT
|
||||
};
|
||||
|
||||
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
// The following two specializations allow the user to write str
|
||||
// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view
|
||||
// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string_view
|
||||
// matcher is expected.
|
||||
template <>
|
||||
class GTEST_API_ [[nodiscard]] Matcher<const internal::StringView&>
|
||||
@@ -569,7 +569,7 @@ class GTEST_API_ [[nodiscard]] Matcher<const internal::StringView&>
|
||||
// Allows the user to write "foo" instead of Eq("foo") sometimes.
|
||||
Matcher(const char* s); // NOLINT
|
||||
|
||||
// Allows the user to pass absl::string_views or std::string_views directly.
|
||||
// Allows the user to pass std::string_views directly.
|
||||
Matcher(internal::StringView s); // NOLINT
|
||||
};
|
||||
|
||||
@@ -596,10 +596,9 @@ class GTEST_API_ [[nodiscard]] Matcher<internal::StringView>
|
||||
// Allows the user to write "foo" instead of Eq("foo") sometimes.
|
||||
Matcher(const char* s); // NOLINT
|
||||
|
||||
// Allows the user to pass absl::string_views or std::string_views directly.
|
||||
// Allows the user to pass std::string_views directly.
|
||||
Matcher(internal::StringView s); // NOLINT
|
||||
};
|
||||
#endif // GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
|
||||
// Prints a matcher in a human-readable format.
|
||||
template <typename T>
|
||||
@@ -812,9 +811,26 @@ class [[nodiscard]] ImplicitCastEqMatcher {
|
||||
StoredRhs stored_rhs_;
|
||||
};
|
||||
|
||||
template <typename T,
|
||||
typename = std::enable_if_t<std::is_constructible_v<std::string, T>>>
|
||||
using StringLike = T;
|
||||
// Dummy function (never defined) whose return type evaluates to std::string if
|
||||
// the given type is a string-like type that can be converted to std::string,
|
||||
// either directly or through an intermediate std::string_view.
|
||||
template <class T>
|
||||
extern std::enable_if_t<std::is_constructible_v<std::string, T>, std::string>
|
||||
ResolveAsString(const void* /* preferred */);
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
// Same as above, but for std::wstring. In cases where both conversions are
|
||||
// possible, this overload takes lower priority.
|
||||
template <class T>
|
||||
extern std::enable_if_t<std::is_constructible_v<std::wstring, T>, std::wstring>
|
||||
ResolveAsString(... /* fallback */);
|
||||
#endif
|
||||
|
||||
// Evaluates to the std::basic_string type that the given string-like type can
|
||||
// be converted to. Prefers std::string over std::wstring if both are possible.
|
||||
// Fails in a SFINAE-friendly way if no conversion was viable.
|
||||
template <typename T>
|
||||
using StringType = decltype(ResolveAsString<T>(nullptr));
|
||||
|
||||
// Implements polymorphic matchers MatchesRegex(regex) and
|
||||
// ContainsRegex(regex), which can be used as a Matcher<T> as long as
|
||||
@@ -824,12 +840,10 @@ class [[nodiscard]] MatchesRegexMatcher {
|
||||
MatchesRegexMatcher(const RE* regex, bool full_match)
|
||||
: regex_(regex), full_match_(full_match) {}
|
||||
|
||||
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
bool MatchAndExplain(const internal::StringView& s,
|
||||
MatchResultListener* listener) const {
|
||||
return MatchAndExplain(std::string(s), listener);
|
||||
}
|
||||
#endif // GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
|
||||
// Accepts pointer types, particularly:
|
||||
// const char*
|
||||
@@ -844,7 +858,7 @@ class [[nodiscard]] MatchesRegexMatcher {
|
||||
// Matches anything that can convert to std::string.
|
||||
//
|
||||
// This is a template, not just a plain function with const std::string&,
|
||||
// because absl::string_view has some interfering non-explicit constructors.
|
||||
// because std::string_view has some interfering non-explicit constructors.
|
||||
template <class MatcheeStringType>
|
||||
bool MatchAndExplain(const MatcheeStringType& s,
|
||||
MatchResultListener* /* listener */) const {
|
||||
@@ -877,9 +891,10 @@ inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
|
||||
return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
|
||||
}
|
||||
template <typename T = std::string>
|
||||
PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
|
||||
const internal::StringLike<T>& regex) {
|
||||
return MatchesRegex(new internal::RE(std::string(regex)));
|
||||
std::enable_if_t<std::is_constructible_v<internal::RE, internal::StringType<T>>,
|
||||
PolymorphicMatcher<internal::MatchesRegexMatcher>>
|
||||
MatchesRegex(const T& regex) {
|
||||
return MatchesRegex(new internal::RE(internal::StringType<T>(regex)));
|
||||
}
|
||||
|
||||
// Matches a string that contains regular expression 'regex'.
|
||||
@@ -889,9 +904,10 @@ inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
|
||||
return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
|
||||
}
|
||||
template <typename T = std::string>
|
||||
PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
|
||||
const internal::StringLike<T>& regex) {
|
||||
return ContainsRegex(new internal::RE(std::string(regex)));
|
||||
std::enable_if_t<std::is_constructible_v<internal::RE, internal::StringType<T>>,
|
||||
PolymorphicMatcher<internal::MatchesRegexMatcher>>
|
||||
ContainsRegex(const T& regex) {
|
||||
return ContainsRegex(new internal::RE(internal::StringType<T>(regex)));
|
||||
}
|
||||
|
||||
// Creates a polymorphic matcher that matches anything equal to x.
|
||||
|
||||
+4
-8
@@ -291,11 +291,9 @@ struct ConvertibleToIntegerPrinter {
|
||||
};
|
||||
|
||||
struct ConvertibleToStringViewPrinter {
|
||||
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
static void PrintValue(internal::StringView value, ::std::ostream* os) {
|
||||
internal::UniversalPrint(value, os);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
@@ -703,12 +701,12 @@ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
|
||||
}
|
||||
}
|
||||
|
||||
// Overloads for ::std::string and ::std::string_view
|
||||
GTEST_API_ void PrintStringTo(::std::string_view s, ::std::ostream* os);
|
||||
// Overloads for ::std::string and std::string_view
|
||||
GTEST_API_ void PrintStringTo(std::string_view s, ::std::ostream* os);
|
||||
inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
|
||||
PrintStringTo(s, os);
|
||||
}
|
||||
inline void PrintTo(::std::string_view s, ::std::ostream* os) {
|
||||
inline void PrintTo(std::string_view s, ::std::ostream* os) {
|
||||
PrintStringTo(s, os);
|
||||
}
|
||||
|
||||
@@ -752,16 +750,14 @@ inline void PrintTo(::std::wstring_view s, ::std::ostream* os) {
|
||||
}
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
// Overload for internal::StringView. Needed for build configurations where
|
||||
// internal::StringView is an alias for absl::string_view, but absl::string_view
|
||||
// is a distinct type from std::string_view.
|
||||
template <int&... ExplicitArgumentBarrier, typename T = internal::StringView,
|
||||
std::enable_if_t<!std::is_same_v<T, ::std::string_view>, int> = 0>
|
||||
std::enable_if_t<!std::is_same_v<T, std::string_view>, int> = 0>
|
||||
inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
|
||||
PrintStringTo(sp, os);
|
||||
}
|
||||
#endif // GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
|
||||
inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "gtest/gtest-matchers.h"
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
@@ -63,6 +64,10 @@ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
::testing::internal::RE regex) {
|
||||
return ContainsRegex(regex.pattern());
|
||||
}
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
std::string_view regex) {
|
||||
return ContainsRegex(regex);
|
||||
}
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
|
||||
return ContainsRegex(regex);
|
||||
}
|
||||
|
||||
+7
-7
@@ -1451,13 +1451,13 @@ class [[nodiscard]] NeverThrown {
|
||||
// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
|
||||
// either a boolean expression or an AssertionResult. text is a textual
|
||||
// representation of expression as it was passed into the EXPECT_TRUE.
|
||||
#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AssertionResultExpectation gtest_are_ = { \
|
||||
::testing::AssertionResult(expression), expected}) \
|
||||
; \
|
||||
else \
|
||||
fail(::testing::internal::GetBoolAssertionFailureMessage( \
|
||||
#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (const ::testing::internal::AssertionResultExpectation gtest_are_ = { \
|
||||
::testing::AssertionResult(expression), expected}) \
|
||||
; \
|
||||
else /* NOLINT */ \
|
||||
fail(::testing::internal::GetBoolAssertionFailureMessage( \
|
||||
gtest_are_.assertion_result, text, #actual, #expected))
|
||||
|
||||
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
|
||||
|
||||
+10
-21
@@ -293,9 +293,10 @@
|
||||
#include <limits>
|
||||
#include <locale>
|
||||
#include <memory>
|
||||
// #include <mutex> // Guarded by GTEST_IS_THREADSAFE below
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
// #include <mutex> // Guarded by GTEST_IS_THREADSAFE below
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
@@ -949,21 +950,21 @@ GTEST_API_ bool IsTrue(bool condition);
|
||||
#ifdef GTEST_USES_RE2
|
||||
|
||||
// This is almost `using RE = ::RE2`, except it is copy-constructible, and it
|
||||
// needs to disambiguate the `std::string`, `absl::string_view`, and `const
|
||||
// needs to disambiguate the `std::string`, `std::string_view`, and `const
|
||||
// char*` constructors.
|
||||
class GTEST_API_ [[nodiscard]] RE {
|
||||
public:
|
||||
RE(absl::string_view regex) : regex_(regex) {} // NOLINT
|
||||
RE(const char* regex) : RE(absl::string_view(regex)) {} // NOLINT
|
||||
RE(const std::string& regex) : RE(absl::string_view(regex)) {} // NOLINT
|
||||
RE(std::string_view regex) : regex_(regex) {} // NOLINT
|
||||
RE(const char* regex) : RE(std::string_view(regex)) {} // NOLINT
|
||||
RE(const std::string& regex) : RE(std::string_view(regex)) {} // NOLINT
|
||||
RE(const RE& other) : RE(other.pattern()) {}
|
||||
|
||||
const std::string& pattern() const { return regex_.pattern(); }
|
||||
|
||||
static bool FullMatch(absl::string_view str, const RE& re) {
|
||||
static bool FullMatch(std::string_view str, const RE& re) {
|
||||
return RE2::FullMatch(str, re.regex_);
|
||||
}
|
||||
static bool PartialMatch(absl::string_view str, const RE& re) {
|
||||
static bool PartialMatch(std::string_view str, const RE& re) {
|
||||
return RE2::PartialMatch(str, re.regex_);
|
||||
}
|
||||
|
||||
@@ -2396,7 +2397,6 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
// Always use absl::string_view for Matcher<> specializations if googletest
|
||||
// is built with absl support.
|
||||
#define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||
#include "absl/strings/string_view.h"
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
@@ -2404,26 +2404,15 @@ using StringView = ::absl::string_view;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#if defined(__cpp_lib_string_view) || \
|
||||
(GTEST_INTERNAL_HAS_INCLUDE(<string_view>) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
|
||||
// Otherwise for C++17 and higher use std::string_view for Matcher<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||
#include <string_view>
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
using StringView = ::std::string_view;
|
||||
using StringView = std::string_view;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::string_view is not
|
||||
// supported.
|
||||
#endif // __cpp_lib_string_view
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#ifndef GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
#define GTEST_INTERNAL_HAS_STRING_VIEW 0
|
||||
#endif
|
||||
#define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||
|
||||
#if defined(__cpp_lib_three_way_comparison)
|
||||
#define GTEST_INTERNAL_HAS_COMPARE_LIB 1
|
||||
|
||||
-2
@@ -59,7 +59,6 @@ Matcher<std::string>::Matcher(const std::string& s) { *this = Eq(s); }
|
||||
// s.
|
||||
Matcher<std::string>::Matcher(const char* s) { *this = Eq(std::string(s)); }
|
||||
|
||||
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
// Constructs a matcher that matches a const StringView& whose value is
|
||||
// equal to s.
|
||||
Matcher<const internal::StringView&>::Matcher(const std::string& s) {
|
||||
@@ -93,6 +92,5 @@ Matcher<internal::StringView>::Matcher(const char* s) {
|
||||
Matcher<internal::StringView>::Matcher(internal::StringView s) {
|
||||
*this = Eq(std::string(s));
|
||||
}
|
||||
#endif // GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
|
||||
} // namespace testing
|
||||
+2
-2
@@ -515,13 +515,13 @@ bool IsValidUTF8(const char* str, size_t length) {
|
||||
void ConditionalPrintAsText(const char* str, size_t length, ostream* os) {
|
||||
if (!ContainsUnprintableControlCodes(str, length) &&
|
||||
IsValidUTF8(str, length)) {
|
||||
*os << "\n As Text: \"" << ::std::string_view(str, length) << "\"";
|
||||
*os << "\n As Text: \"" << std::string_view(str, length) << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void PrintStringTo(::std::string_view s, ostream* os) {
|
||||
void PrintStringTo(std::string_view s, ostream* os) {
|
||||
if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {
|
||||
if (GTEST_FLAG_GET(print_utf8)) {
|
||||
ConditionalPrintAsText(s.data(), s.size(), os);
|
||||
|
||||
Vendored
+1
-1
@@ -6930,7 +6930,7 @@ void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
|
||||
std::vector<char*> positional_args;
|
||||
std::vector<absl::UnrecognizedFlag> unrecognized_flags;
|
||||
absl::ParseAbseilFlagsOnly(*argc, argv, positional_args, unrecognized_flags);
|
||||
absl::flat_hash_set<absl::string_view> unrecognized;
|
||||
absl::flat_hash_set<std::string_view> unrecognized;
|
||||
for (const auto& flag : unrecognized_flags) {
|
||||
unrecognized.insert(flag.flag_name);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user