diff options
Diffstat (limited to 'absl/types/span_test.cc')
-rw-r--r-- | absl/types/span_test.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/absl/types/span_test.cc b/absl/types/span_test.cc index 6ac234d365ad..2584339bd309 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" @@ -233,7 +234,7 @@ TEST(IntSpan, ElementAccess) { EXPECT_EQ(s.front(), s[0]); EXPECT_EQ(s.back(), s[9]); -#ifndef NDEBUG +#if !defined(NDEBUG) || ABSL_OPTION_HARDENED EXPECT_DEATH_IF_SUPPORTED(s[-1], ""); EXPECT_DEATH_IF_SUPPORTED(s[10], ""); #endif @@ -273,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) { |