1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

AK: Make HashTable::operator=(HashTable&&) clear the moved-from table

This is consistent with how other AK containers behave when moved from.
This commit is contained in:
Andreas Kling 2021-05-30 14:23:23 +02:00
parent 259822493f
commit c584421592
2 changed files with 27 additions and 1 deletions

View file

@ -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;