diff options
Diffstat (limited to 'Firestore/third_party/abseil-cpp/absl/strings')
3 files changed, 33 insertions, 6 deletions
diff --git a/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt b/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt index dcd4974..83cb934 100644 --- a/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt +++ b/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt @@ -35,6 +35,7 @@ list(APPEND STRINGS_INTERNAL_HEADERS "internal/memutil.h" "internal/ostringstream.h" "internal/resize_uninitialized.h" + "internal/stl_type_traits.h" "internal/str_join_internal.h" "internal/str_split_internal.h" "internal/utf8.h" @@ -49,6 +50,7 @@ list(APPEND STRINGS_SRC "internal/memutil.cc" "internal/memutil.h" "internal/utf8.cc" + "internal/ostringstream.cc" "match.cc" "numbers.cc" "str_cat.cc" @@ -205,12 +207,15 @@ absl_test( # test ostringstream_test set(OSTRINGSTREAM_TEST_SRC "internal/ostringstream_test.cc") +set(OSTRINGSTREAM_TEST_PUBLIC_LIBRARIES absl::strings) absl_test( TARGET ostringstream_test SOURCES ${OSTRINGSTREAM_TEST_SRC} + PUBLIC_LIBRARIES + ${OSTRINGSTREAM_TEST_PUBLIC_LIBRARIES} ) diff --git a/Firestore/third_party/abseil-cpp/absl/strings/string_view.h b/Firestore/third_party/abseil-cpp/absl/strings/string_view.h index c3acd72..ddc8934 100644 --- a/Firestore/third_party/abseil-cpp/absl/strings/string_view.h +++ b/Firestore/third_party/abseil-cpp/absl/strings/string_view.h @@ -419,7 +419,7 @@ class string_view { size_type rfind(string_view s, size_type pos = npos) const noexcept; - // Overload of `string_view::rfind()` for finding the given character `c` + // Overload of `string_view::rfind()` for finding the last given character `c` // within the `string_view`. size_type rfind(char c, size_type pos = npos) const noexcept; diff --git a/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc b/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc index 13fc214..3077d24 100644 --- a/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc +++ b/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc @@ -684,8 +684,11 @@ TEST(StringViewTest, TruncSubstr) { } TEST(StringViewTest, UTF8) { - EXPECT_EQ(strlen("á"), absl::string_view("á á").find_first_of(" ")); - EXPECT_EQ(strlen("á"), absl::string_view("á á").find_first_of(" \t")); + std::string utf8 = "\u00E1"; + std::string utf8_twice = utf8 + " " + utf8; + int utf8_len = strlen(utf8.data()); + EXPECT_EQ(utf8_len, absl::string_view(utf8_twice).find_first_of(" ")); + EXPECT_EQ(utf8_len, absl::string_view(utf8_twice).find_first_of(" \t")); } TEST(StringViewTest, FindConformance) { @@ -796,11 +799,25 @@ TEST(StringViewTest, FrontBackSingleChar) { EXPECT_EQ(&c, &csp.back()); } +// `std::string_view::string_view(const char*)` calls +// `std::char_traits<char>::length(const char*)` to get the std::string length. In +// libc++, it doesn't allow `nullptr` in the constexpr context, with the error +// "read of dereferenced null pointer is not allowed in a constant expression". +// At run time, the behavior of `std::char_traits::length()` on `nullptr` is +// undefined by the standard and usually results in crash with libc++. This +// conforms to the standard, but `absl::string_view` implements a different +// behavior for historical reasons. We work around tests that construct +// `string_view` from `nullptr` when using libc++. +#if !defined(ABSL_HAVE_STD_STRING_VIEW) || !defined(_LIBCPP_VERSION) +#define ABSL_HAVE_STRING_VIEW_FROM_NULLPTR 1 +#endif // !defined(ABSL_HAVE_STD_STRING_VIEW) || !defined(_LIBCPP_VERSION) + TEST(StringViewTest, NULLInput) { absl::string_view s; EXPECT_EQ(s.data(), nullptr); EXPECT_EQ(s.size(), 0); +#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR s = absl::string_view(nullptr); EXPECT_EQ(s.data(), nullptr); EXPECT_EQ(s.size(), 0); @@ -808,6 +825,7 @@ TEST(StringViewTest, NULLInput) { // .ToString() on a absl::string_view with nullptr should produce the empty // std::string. EXPECT_EQ("", std::string(s)); +#endif // ABSL_HAVE_STRING_VIEW_FROM_NULLPTR } TEST(StringViewTest, Comparisons2) { @@ -879,7 +897,9 @@ TEST(StringViewTest, NullSafeStringView) { TEST(StringViewTest, ConstexprCompiles) { constexpr absl::string_view sp; +#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR constexpr absl::string_view cstr(nullptr); +#endif constexpr absl::string_view cstr_len("cstr", 4); #if defined(ABSL_HAVE_STD_STRING_VIEW) @@ -923,10 +943,12 @@ TEST(StringViewTest, ConstexprCompiles) { constexpr absl::string_view::iterator const_end_empty = sp.end(); EXPECT_EQ(const_begin_empty, const_end_empty); +#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR constexpr absl::string_view::iterator const_begin_nullptr = cstr.begin(); constexpr absl::string_view::iterator const_end_nullptr = cstr.end(); EXPECT_EQ(const_begin_nullptr, const_end_nullptr); -#endif +#endif // ABSL_HAVE_STRING_VIEW_FROM_NULLPTR +#endif // !defined(__clang__) || ... constexpr absl::string_view::iterator const_begin = cstr_len.begin(); constexpr absl::string_view::iterator const_end = cstr_len.end(); @@ -1042,11 +1064,11 @@ TEST(HugeStringView, TwoPointTwoGB) { } #endif // THREAD_SANITIZER -#ifndef NDEBUG +#if !defined(NDEBUG) && !defined(ABSL_HAVE_STD_STRING_VIEW) TEST(NonNegativeLenTest, NonNegativeLen) { EXPECT_DEATH_IF_SUPPORTED(absl::string_view("xyz", -1), "len <= kMaxSize"); } -#endif // NDEBUG +#endif // !defined(NDEBUG) && !defined(ABSL_HAVE_STD_STRING_VIEW) class StringViewStreamTest : public ::testing::Test { public: |