summaryrefslogtreecommitdiff
path: root/Tests/AK
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2023-04-28 15:02:38 +0300
committerAndreas Kling <kling@serenityos.org>2023-04-28 18:11:44 +0200
commit4c6564e3c1143b27f29f3fd551cce3b99fa4b836 (patch)
tree73a95030a81a5387049795c1dea1c154da3fc067 /Tests/AK
parentc9c8f2413f425138e798e1cf57314fdc5a480053 (diff)
downloadserenity-4c6564e3c1143b27f29f3fd551cce3b99fa4b836.zip
AK: Add values() method in HashTable
Add HashTable::values() method that returns all values.
Diffstat (limited to 'Tests/AK')
-rw-r--r--Tests/AK/TestHashTable.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Tests/AK/TestHashTable.cpp b/Tests/AK/TestHashTable.cpp
index 9d25c48739..47b13da09f 100644
--- a/Tests/AK/TestHashTable.cpp
+++ b/Tests/AK/TestHashTable.cpp
@@ -10,6 +10,7 @@
#include <AK/DeprecatedString.h>
#include <AK/HashTable.h>
#include <AK/NonnullOwnPtr.h>
+#include <AK/Vector.h>
TEST_CASE(construct)
{
@@ -434,3 +435,18 @@ TEST_CASE(ordered_infinite_loop_clang_regression)
}
}
}
+
+TEST_CASE(values)
+{
+ OrderedHashTable<int> table;
+ table.set(10);
+ table.set(30);
+ table.set(20);
+
+ Vector<int> values = table.values();
+
+ EXPECT_EQ(values.size(), table.size());
+ EXPECT_EQ(values[0], 10);
+ EXPECT_EQ(values[1], 30);
+ EXPECT_EQ(values[2], 20);
+}