summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-30 14:23:23 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-30 14:34:32 +0200
commitc584421592a480cfba24b8c31dc19439cc2d5df4 (patch)
treeed39628efacc6aa10189f4005b32f6edc4ca801e /Tests
parent259822493f86998b2ba488e54257afe9e9184a86 (diff)
downloadserenity-c584421592a480cfba24b8c31dc19439cc2d5df4.zip
AK: Make HashTable::operator=(HashTable&&) clear the moved-from table
This is consistent with how other AK containers behave when moved from.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/AK/TestHashTable.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Tests/AK/TestHashTable.cpp b/Tests/AK/TestHashTable.cpp
index 55c297e774..9729eac9a3 100644
--- a/Tests/AK/TestHashTable.cpp
+++ b/Tests/AK/TestHashTable.cpp
@@ -16,6 +16,31 @@ TEST_CASE(construct)
EXPECT_EQ(IntTable().size(), 0u);
}
+TEST_CASE(basic_move)
+{
+ HashTable<int> foo;
+ foo.set(1);
+ EXPECT_EQ(foo.size(), 1u);
+ auto bar = move(foo);
+ EXPECT_EQ(bar.size(), 1u);
+ EXPECT_EQ(foo.size(), 0u);
+ foo = move(bar);
+ EXPECT_EQ(bar.size(), 0u);
+ EXPECT_EQ(foo.size(), 1u);
+}
+
+TEST_CASE(move_is_not_swap)
+{
+ HashTable<int> foo;
+ foo.set(1);
+ HashTable<int> bar;
+ bar.set(2);
+ foo = move(bar);
+ EXPECT(foo.contains(2));
+ EXPECT(!bar.contains(1));
+ EXPECT_EQ(bar.size(), 0u);
+}
+
TEST_CASE(populate)
{
HashTable<String> strings;