From 5ddddbb16f187bb6cfa6708395265bede43831bf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Oct 2023 12:33:06 +0200 Subject: [PATCH] test/util/TestIntrusiveForwardList: add push_back() test --- test/util/TestIntrusiveForwardList.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/util/TestIntrusiveForwardList.cxx b/test/util/TestIntrusiveForwardList.cxx index e242e1eda..a9959c55d 100644 --- a/test/util/TestIntrusiveForwardList.cxx +++ b/test/util/TestIntrusiveForwardList.cxx @@ -133,6 +133,26 @@ TEST(IntrusiveForwardList, CacheLast) list.reverse(); ASSERT_EQ(ToString(list), ""); + /* test push_back() */ + + for (auto &i : items) + list.push_back(i); + + ASSERT_EQ(ToString(list), "abc"); + ASSERT_EQ(&list.back(), &items[2]); + + list.clear(); + + /* test push_back() again to see if clear() has worked */ + + for (auto &i : items) + list.push_back(i); + + ASSERT_EQ(ToString(list), "abc"); + ASSERT_EQ(&list.back(), &items[2]); + + list.clear(); + for (auto &i : items) list.push_front(i);