Commit b0ed638d authored by Gabriela Melchior's avatar Gabriela Melchior Committed by Commit Bot

Adding death tests to span bounds checks.

These tests should ensure that bounds are being checked for span
functions and that these guarantees don't decay.

R=palmer@chromium.org
BUG=817982

Change-Id: Ief96bcc56a78187c615cbb15e906320290eafc59
Reviewed-on: https://chromium-review.googlesource.com/c/1317894Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Gabriela Melchior <gabimelchior@google.com>
Cr-Commit-Position: refs/heads/master@{#606017}
parent 436a929a
......@@ -1183,4 +1183,18 @@ TEST(SpanTest, EnsureConstexprGoodness) {
EXPECT_EQ(kArray[size], item);
}
TEST(SpanTest, OutOfBoundsDeath) {
constexpr span<int, 0> kEmptySpan;
ASSERT_DEATH_IF_SUPPORTED(kEmptySpan[0], "");
ASSERT_DEATH_IF_SUPPORTED(kEmptySpan(0), "");
ASSERT_DEATH_IF_SUPPORTED(kEmptySpan.first(1), "");
ASSERT_DEATH_IF_SUPPORTED(kEmptySpan.last(1), "");
ASSERT_DEATH_IF_SUPPORTED(kEmptySpan.subspan(1), "");
}
} // namespace base
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment