summaryrefslogtreecommitdiff
path: root/absl/types/span_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/types/span_test.cc')
-rw-r--r--absl/types/span_test.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/absl/types/span_test.cc b/absl/types/span_test.cc
index 22467a0a..2584339b 100644
--- a/absl/types/span_test.cc
+++ b/absl/types/span_test.cc
@@ -27,6 +27,7 @@
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/exception_testing.h"
+#include "absl/base/options.h"
#include "absl/container/fixed_array.h"
#include "absl/container/inlined_vector.h"
#include "absl/hash/hash_testing.h"
@@ -232,6 +233,11 @@ TEST(IntSpan, ElementAccess) {
EXPECT_EQ(s.front(), s[0]);
EXPECT_EQ(s.back(), s[9]);
+
+#if !defined(NDEBUG) || ABSL_OPTION_HARDENED
+ EXPECT_DEATH_IF_SUPPORTED(s[-1], "");
+ EXPECT_DEATH_IF_SUPPORTED(s[10], "");
+#endif
}
TEST(IntSpan, AtThrows) {
@@ -268,6 +274,13 @@ TEST(IntSpan, RemovePrefixAndSuffix) {
EXPECT_EQ(s.size(), 0);
EXPECT_EQ(v, MakeRamp(20, 1));
+
+#if !defined(NDEBUG) || ABSL_OPTION_HARDENED
+ absl::Span<int> prefix_death(v);
+ EXPECT_DEATH_IF_SUPPORTED(prefix_death.remove_prefix(21), "");
+ absl::Span<int> suffix_death(v);
+ EXPECT_DEATH_IF_SUPPORTED(suffix_death.remove_suffix(21), "");
+#endif
}
TEST(IntSpan, Subspan) {