diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-06-15 23:46:54 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-15 23:59:21 +0100 |
commit | 8c7fe8d6c8cca71334c3b46ed201809843d9cf07 (patch) | |
tree | d802a66576dc67da67c29e7ccbd50d70bda667f0 /Tests/AK | |
parent | 08ff148bc38de2db28781b6f37f55c3b1ee66421 (diff) | |
download | serenity-8c7fe8d6c8cca71334c3b46ed201809843d9cf07.zip |
AK: Add support for removing SinglyLinkedList nodes during iteration
This commit also fixes the now-broken usage of SinglyLinkedList::remove
in the Piano application.
Diffstat (limited to 'Tests/AK')
-rw-r--r-- | Tests/AK/TestSinglyLinkedList.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Tests/AK/TestSinglyLinkedList.cpp b/Tests/AK/TestSinglyLinkedList.cpp index 3df43d2cb5..750940f74e 100644 --- a/Tests/AK/TestSinglyLinkedList.cpp +++ b/Tests/AK/TestSinglyLinkedList.cpp @@ -59,3 +59,14 @@ TEST_CASE(should_find_const_with_predicate) EXPECT_EQ(sut.end(), sut.find_if([](const auto v) { return v == 42; })); } + +TEST_CASE(removal_during_iteration) +{ + auto list = make_list(); + auto size = list.size_slow(); + + for (auto it = list.begin(); it != list.end(); ++it, --size) { + VERIFY(list.size_slow() == size); + it.remove(list); + } +} |