diff options
author | davidot <davidot@serenityos.org> | 2022-02-10 12:24:49 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-02-10 14:09:39 +0000 |
commit | fdbfe85a874f39c7e6a17f8f1cc0cd757200299e (patch) | |
tree | a622ec6fa8fc2b0832ff6fc7bbafcb180cf0ff91 /Tests/AK | |
parent | 2bddf157b11630298659a650b1030fb255085821 (diff) | |
download | serenity-fdbfe85a874f39c7e6a17f8f1cc0cd757200299e.zip |
AK: Clear minimum when removing last node of RedBlackTree
Diffstat (limited to 'Tests/AK')
-rw-r--r-- | Tests/AK/TestRedBlackTree.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Tests/AK/TestRedBlackTree.cpp b/Tests/AK/TestRedBlackTree.cpp index f6d1ddebac..0b0848bf67 100644 --- a/Tests/AK/TestRedBlackTree.cpp +++ b/Tests/AK/TestRedBlackTree.cpp @@ -128,3 +128,17 @@ TEST_CASE(find_smallest_not_below_iterator) EXPECT_EQ(smallest_not_below_three.key(), 3u); } } + +TEST_CASE(iterators_on_emptied_tree) +{ + RedBlackTree<size_t, size_t> test; + test.insert(1, 1); + test.remove(1); + EXPECT_EQ(test.size(), 0u); + auto begin_iterator = test.begin(); + auto end_iterator = test.end(); + EXPECT(begin_iterator.is_end()); + + EXPECT_EQ(begin_iterator, end_iterator); + EXPECT(!(begin_iterator != end_iterator)); +} |