about summary refs log tree commit diff
path: root/absl/strings/string_view_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/strings/string_view_test.cc')
-rw-r--r--absl/strings/string_view_test.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/absl/strings/string_view_test.cc b/absl/strings/string_view_test.cc
index 3077d240d17b..a26f6c3ae119 100644
--- a/absl/strings/string_view_test.cc
+++ b/absl/strings/string_view_test.cc
@@ -1068,6 +1068,17 @@ TEST(HugeStringView, TwoPointTwoGB) {
 TEST(NonNegativeLenTest, NonNegativeLen) {
   EXPECT_DEATH_IF_SUPPORTED(absl::string_view("xyz", -1), "len <= kMaxSize");
 }
+
+TEST(LenExceedsMaxSizeTest, LenExceedsMaxSize) {
+  auto max_size = absl::string_view().max_size();
+
+  // This should construct ok (although the view itself is obviously invalid).
+  absl::string_view ok_view("", max_size);
+
+  // Adding one to the max should trigger an assertion.
+  EXPECT_DEATH_IF_SUPPORTED(absl::string_view("", max_size + 1),
+                            "len <= kMaxSize");
+}
 #endif  // !defined(NDEBUG) && !defined(ABSL_HAVE_STD_STRING_VIEW)
 
 class StringViewStreamTest : public ::testing::Test {