[libcxx-commits] [PATCH] D88421: Add a regression test for erasing from a vector

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 28 08:07:13 PDT 2020


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, EricWF.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.
Quuxplusone requested review of this revision.

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.

I'll do some more investigation of the actual root cause of the trivially-relocatable bug that this is a regression test for, since I have to fix it anyway. Still, I was shocked that libc++'s test suite didn't catch a simple misbehavior. (The specific misbehavior in my case was that after erasing l1.begin() you'd get {2,2,3,4} instead of {2,3,4,5} — it's shifting down only one element instead of all of them. But I haven't yet looked at my code to see //why// that is.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88421

Files:
  libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp


Index: libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
+++ libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
@@ -35,6 +35,12 @@
 
 int main(int, char**)
 {
+    {
+    int a1[] = {1, 2, 3, 4, 5};
+    std::vector<int> l1(a1, a1+5);
+    l1.erase(l1.begin());
+    assert(l1 == std::vector<int>(a1+1, a1+5));
+    }
     {
     int a1[] = {1, 2, 3};
     std::vector<int> l1(a1, a1+3);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88421.294710.patch
Type: text/x-patch
Size: 602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200928/bdd53df4/attachment.bin>


More information about the libcxx-commits mailing list