summaryrefslogtreecommitdiff
path: root/Tests/AK/TestDoublyLinkedList.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-05-06 01:19:30 -0700
committerAndreas Kling <kling@serenityos.org>2021-05-06 17:54:28 +0200
commit67322b0702836807e29265e86556ebf43bb9d510 (patch)
tree86d2e2099ecc377cf11ddcf9106c500969b1afbb /Tests/AK/TestDoublyLinkedList.cpp
parentfd0dbd1ebfbcbc29d46393061daa49dc7390caa7 (diff)
downloadserenity-67322b0702836807e29265e86556ebf43bb9d510.zip
Tests: Move AK tests to Tests/AK
Diffstat (limited to 'Tests/AK/TestDoublyLinkedList.cpp')
-rw-r--r--Tests/AK/TestDoublyLinkedList.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/Tests/AK/TestDoublyLinkedList.cpp b/Tests/AK/TestDoublyLinkedList.cpp
new file mode 100644
index 0000000000..407484e443
--- /dev/null
+++ b/Tests/AK/TestDoublyLinkedList.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2021, the SerenityOS developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibTest/TestCase.h>
+
+#include <AK/DoublyLinkedList.h>
+
+static DoublyLinkedList<int> make_list()
+{
+ DoublyLinkedList<int> list {};
+ list.append(0);
+ list.append(1);
+ list.append(2);
+ list.append(3);
+ list.append(4);
+ list.append(5);
+ list.append(6);
+ list.append(7);
+ list.append(8);
+ list.append(9);
+ return list;
+}
+
+TEST_CASE(should_find_mutable)
+{
+ auto sut = make_list();
+
+ EXPECT_EQ(4, *sut.find(4));
+
+ EXPECT_EQ(sut.end(), sut.find(42));
+}
+
+TEST_CASE(should_find_const)
+{
+ const auto sut = make_list();
+
+ EXPECT_EQ(4, *sut.find(4));
+
+ EXPECT_EQ(sut.end(), sut.find(42));
+}