Commit 38c97285 authored by Gabriela Melchior's avatar Gabriela Melchior Committed by Commit Bot

Adding death tests to string piece bounds checks.

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

R=mpdenton@chromium.org
BUG=817982

Change-Id: I24f365e3b1461082fd5abc725d3f905662faeb71
Reviewed-on: https://chromium-review.googlesource.com/c/1301460
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603351}
parent 55290db2
......@@ -723,6 +723,33 @@ TEST(StringPieceTest, ConstexprCtor) {
}
}
TEST(StringPieceTest, OutOfBoundsDeath) {
{
constexpr StringPiece piece;
ASSERT_DEATH_IF_SUPPORTED(piece[0], "");
}
{
constexpr StringPiece piece;
ASSERT_DEATH_IF_SUPPORTED(piece.front(), "");
}
{
constexpr StringPiece piece;
ASSERT_DEATH_IF_SUPPORTED(piece.back(), "");
}
{
StringPiece piece;
ASSERT_DEATH_IF_SUPPORTED(piece.remove_suffix(1), "");
}
{
StringPiece piece;
ASSERT_DEATH_IF_SUPPORTED(piece.remove_prefix(1), "");
}
}
TEST(StringPieceTest, ConstexprData) {
{
constexpr StringPiece piece;
......
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