X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FADT%2FMapVectorTest.cpp;h=92f0dc41910b2ff8c6924c3fb7f03f68d20bc12e;hb=c12ce2b66186404177a3a9f854df0272beb52d81;hp=dd84e7ebd13fbdad5fff66b07c062597b4f2b16b;hpb=4b0a7f39463552ca2aec3d235f831264572f9916;p=oota-llvm.git diff --git a/unittests/ADT/MapVectorTest.cpp b/unittests/ADT/MapVectorTest.cpp index dd84e7ebd13..92f0dc41910 100644 --- a/unittests/ADT/MapVectorTest.cpp +++ b/unittests/ADT/MapVectorTest.cpp @@ -68,3 +68,24 @@ TEST(MapVectorTest, erase) { ASSERT_EQ(MV[3], 4); ASSERT_EQ(MV[5], 6); } + +TEST(MapVectorTest, remove_if) { + MapVector MV; + + MV.insert(std::make_pair(1, 11)); + MV.insert(std::make_pair(2, 12)); + MV.insert(std::make_pair(3, 13)); + MV.insert(std::make_pair(4, 14)); + MV.insert(std::make_pair(5, 15)); + MV.insert(std::make_pair(6, 16)); + ASSERT_EQ(MV.size(), 6u); + + MV.remove_if([](const std::pair &Val) { return Val.second % 2; }); + ASSERT_EQ(MV.size(), 3u); + ASSERT_EQ(MV.find(1), MV.end()); + ASSERT_EQ(MV.find(3), MV.end()); + ASSERT_EQ(MV.find(5), MV.end()); + ASSERT_EQ(MV[2], 12); + ASSERT_EQ(MV[4], 14); + ASSERT_EQ(MV[6], 16); +}