summaryrefslogtreecommitdiff
path: root/Tests/AK/TestVector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/AK/TestVector.cpp')
-rw-r--r--Tests/AK/TestVector.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/Tests/AK/TestVector.cpp b/Tests/AK/TestVector.cpp
index 2289c24639..4cfa6da98d 100644
--- a/Tests/AK/TestVector.cpp
+++ b/Tests/AK/TestVector.cpp
@@ -533,3 +533,29 @@ TEST_CASE(reference_deletion_should_not_affect_object)
}
EXPECT_EQ(times_deleted, 1u);
}
+
+TEST_CASE(rbegin)
+{
+ Vector<int> v { 1, 2, 3, 4, 5, 6, 7, 8, 0 };
+
+ auto const expected = v.begin() + 4;
+ auto const expected_in_reverse = v.rbegin() + 4;
+ EXPECT_EQ(*expected, *expected_in_reverse);
+}
+
+TEST_CASE(rend)
+{
+ Vector<int> v { 1, 2, 3, 4, 5, 6, 7, 8, 0 };
+
+ const auto expected = v.end() - 5;
+ const auto expected_in_reverse = v.rend() - 5;
+ EXPECT_EQ(*expected, *expected_in_reverse);
+}
+
+TEST_CASE(reverse_loop)
+{
+ Vector<int> v { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ int index = 9;
+ for (auto rev = v.rbegin(); rev != v.rend(); ++rev)
+ EXPECT_EQ(*rev, index--);
+}