1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[ilist_node] Add a getReverseIterator() method and a unittest for it.

This is the reverse_iterator analogue of getIterator().

llvm-svn: 285780
This commit is contained in:
Michael Gottesman 2016-11-02 00:59:58 +00:00
parent 0bff92205e
commit faf00da81c
2 changed files with 23 additions and 0 deletions

View File

@ -80,6 +80,12 @@ private:
public:
self_iterator getIterator() { return self_iterator(*this); }
const_self_iterator getIterator() const { return const_self_iterator(*this); }
reverse_self_iterator getReverseIterator() {
return reverse_self_iterator(*this);
}
const_reverse_self_iterator getReverseIterator() const {
return const_reverse_self_iterator(*this);
}
// Under-approximation, but always available for assertions.
using node_base_type::isKnownSentinel;

View File

@ -178,6 +178,23 @@ TEST(SimpleIListTest, erase) {
EXPECT_EQ(2u, L.size());
}
TEST(SimpleIListTest, reverse_iterator) {
simple_ilist<Node> L;
Node A, B, C;
L.push_back(A);
L.push_back(B);
L.push_back(C);
auto ReverseIter = L.rbegin();
EXPECT_EQ(C.getReverseIterator(), ReverseIter);
++ReverseIter;
EXPECT_EQ(B.getReverseIterator(), ReverseIter);
++ReverseIter;
EXPECT_EQ(A.getReverseIterator(), ReverseIter);
++ReverseIter;
EXPECT_EQ(L.rend(), ReverseIter);
}
TEST(SimpleIListTest, eraseAndDispose) {
simple_ilist<Node> L;
Node A, C;