about summary refs log tree commit diff
path: root/absl/strings/string_view_test.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-08-06T14·13-0700
committerCJ Johnson <johnsoncj@google.com>2019-08-06T18·16-0400
commit67222ffc4c83d918ce8395aa61769eeb77df4c4d (patch)
tree6dba7ec72ecc36105c848fc5da5c044a33643e13 /absl/strings/string_view_test.cc
parentc5c4db4f5191fe5e76cbf68dcc71fb28702f7d2b (diff)
Export of internal Abseil changes
--
5315e7b98905922e779798f3168d98343438c134 by Derek Mauro <dmauro@google.com>:

Fix absl::string_view::copy to throw std::out_of_range when pos > size().

Fixes https://github.com/abseil/abseil-cpp/issues/362

PiperOrigin-RevId: 261907364
GitOrigin-RevId: 5315e7b98905922e779798f3168d98343438c134
Change-Id: Ia8ab971c54f287411f6ea4b99f9c666c989c33fd
Diffstat (limited to 'absl/strings/string_view_test.cc')
-rw-r--r--absl/strings/string_view_test.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/absl/strings/string_view_test.cc b/absl/strings/string_view_test.cc
index 2380e1a377a3..22d43536be55 100644
--- a/absl/strings/string_view_test.cc
+++ b/absl/strings/string_view_test.cc
@@ -369,6 +369,11 @@ TEST(StringViewTest, STL1) {
   EXPECT_EQ(buf[1], c[1]);
   EXPECT_EQ(buf[2], c[2]);
   EXPECT_EQ(buf[3], a[3]);
+#ifdef ABSL_HAVE_EXCEPTIONS
+  EXPECT_THROW(a.copy(buf, 1, 27), std::out_of_range);
+#else
+  EXPECT_DEATH(a.copy(buf, 1, 27), "absl::string_view::copy");
+#endif
 }
 
 // Separated from STL1() because some compilers produce an overly