diff options
Diffstat (limited to 'third_party/abseil-cpp/absl/types/span_test.cc')
-rw-r--r-- | third_party/abseil-cpp/absl/types/span_test.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/third_party/abseil-cpp/absl/types/span_test.cc b/third_party/abseil-cpp/absl/types/span_test.cc index 22467a0a76..13264aae14 100644 --- a/third_party/abseil-cpp/absl/types/span_test.cc +++ b/third_party/abseil-cpp/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) { @@ -648,6 +661,8 @@ TEST(IntSpan, ExposesContainerTypesAndConsts) { CheckType<absl::Span<int>::const_reverse_iterator>(slice.crend()); testing::StaticAssertTypeEq<int, absl::Span<int>::value_type>(); testing::StaticAssertTypeEq<int, absl::Span<const int>::value_type>(); + testing::StaticAssertTypeEq<int, absl::Span<int>::element_type>(); + testing::StaticAssertTypeEq<const int, absl::Span<const int>::element_type>(); testing::StaticAssertTypeEq<int*, absl::Span<int>::pointer>(); testing::StaticAssertTypeEq<const int*, absl::Span<const int>::pointer>(); testing::StaticAssertTypeEq<int&, absl::Span<int>::reference>(); |