diff options
author | Michael Gottesman <mgottesman@apple.com> | 2014-10-27 17:20:53 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2014-10-27 17:20:53 +0000 |
commit | d71825c3cbdb173274c2e3afcef2c66552400648 (patch) | |
tree | 981555ff6654d73164e38e4998f934b77c47bd40 /llvm/unittests/ADT/MapVectorTest.cpp | |
parent | e068ac77a223588faf7d80b36e516a656d9b52f6 (diff) | |
download | llvm-d71825c3cbdb173274c2e3afcef2c66552400648.zip llvm-d71825c3cbdb173274c2e3afcef2c66552400648.tar.gz llvm-d71825c3cbdb173274c2e3afcef2c66552400648.tar.bz2 |
Add MapVector::rbegin(), MapVector::rend() to completment MapVector::begin(), MapVector::end().
These just delegate to the underlying vector type in the MapVector.
Also just add in some sanity unittests.
llvm-svn: 220687
Diffstat (limited to 'llvm/unittests/ADT/MapVectorTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/MapVectorTest.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/MapVectorTest.cpp b/llvm/unittests/ADT/MapVectorTest.cpp index 46cd36a..8919799 100644 --- a/llvm/unittests/ADT/MapVectorTest.cpp +++ b/llvm/unittests/ADT/MapVectorTest.cpp @@ -9,6 +9,7 @@ #include "gtest/gtest.h" #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/iterator_range.h" #include <utility> using namespace llvm; @@ -97,3 +98,27 @@ TEST(MapVectorTest, remove_if) { ASSERT_EQ(MV[4], 14); ASSERT_EQ(MV[6], 16); } + +TEST(MapVectorTest, iteration_test) { + MapVector<int, int> 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); + + int count = 1; + for (auto P : make_range(MV.begin(), MV.end())) { + ASSERT_EQ(P.first, count); + count++; + } + + count = 6; + for (auto P : make_range(MV.rbegin(), MV.rend())) { + ASSERT_EQ(P.first, count); + count--; + } +} |