From 7bed95a856f1e0146e838e7575677159f42f3bf7 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 29 Sep 2020 12:17:26 -0400 Subject: [PATCH] [libc++] Add a regression test for erasing from a vector After rebasing my trivially-relocatable branch, this behavior was broken... but no libc++ unit test caught it! Add a regression test specifically for erasing out of a vector. Differential Revision: https://reviews.llvm.org/D88421 --- .../sequences/vector/vector.modifiers/erase_iter.pass.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp index fb9b4bf..1d58d31 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp @@ -36,6 +36,21 @@ bool Throws::sThrows = false; int main(int, char**) { { + int a1[] = {1, 2, 3, 4, 5}; + std::vector l1(a1, a1+5); + l1.erase(l1.begin()); + assert(is_contiguous_container_asan_correct(l1)); + assert(l1 == std::vector(a1+1, a1+5)); + } + { + int a1[] = {1, 2, 3, 4, 5}; + int e1[] = {1, 3, 4, 5}; + std::vector l1(a1, a1+5); + l1.erase(l1.begin() + 1); + assert(is_contiguous_container_asan_correct(l1)); + assert(l1 == std::vector(e1, e1+4)); + } + { int a1[] = {1, 2, 3}; std::vector l1(a1, a1+3); std::vector::const_iterator i = l1.begin(); -- 2.7.4