summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/STLExtrasTest.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2016-12-26 23:30:44 +0000
committerChandler Carruth <chandlerc@gmail.com>2016-12-26 23:30:44 +0000
commitcc44ab63b6051732dee9504ea2977120646d96bf (patch)
tree41937316ac9cc9a25b69cd11a3b1779c863e7c42 /llvm/unittests/ADT/STLExtrasTest.cpp
parentc9cf7fc7a4aac89c388ba9d9b1ab2bf24cd1ece6 (diff)
downloadbcm5719-llvm-cc44ab63b6051732dee9504ea2977120646d96bf.tar.gz
bcm5719-llvm-cc44ab63b6051732dee9504ea2977120646d96bf.zip
[ADT] Add an llvm::erase_if utility to make the standard erase+remove_if
pattern easier to write. Differential Revision: https://reviews.llvm.org/D28120 llvm-svn: 290555
Diffstat (limited to 'llvm/unittests/ADT/STLExtrasTest.cpp')
-rw-r--r--llvm/unittests/ADT/STLExtrasTest.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/STLExtrasTest.cpp b/llvm/unittests/ADT/STLExtrasTest.cpp
index 28e0ebb53f6..f17d24f36b2 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -297,4 +297,15 @@ TEST(STLExtrasTest, PartitionAdaptor) {
EXPECT_EQ(7, V[7]);
}
+TEST(STLExtrasTest, EraseIf) {
+ std::vector<int> V = {1, 2, 3, 4, 5, 6, 7, 8};
+
+ erase_if(V, [](int i) { return i % 2 == 0; });
+ EXPECT_EQ(4u, V.size());
+ EXPECT_EQ(1, V[0]);
+ EXPECT_EQ(3, V[1]);
+ EXPECT_EQ(5, V[2]);
+ EXPECT_EQ(7, V[3]);
+}
+
}
OpenPOWER on IntegriCloud