table: more tests

This commit is contained in:
Michele Caini
2024-04-29 10:38:34 +02:00
parent 3729eab7d5
commit 7ca3f84891

View File

@@ -16,3 +16,49 @@ TEST(Table, Constructors) {
ASSERT_NO_THROW([[maybe_unused]] auto alloc = table.get_allocator());
}
TEST(Table, Move) {
entt::table<int, char> table;
table.emplace(3, 'c');
static_assert(std::is_move_constructible_v<decltype(table)>, "Move constructible type required");
static_assert(std::is_move_assignable_v<decltype(table)>, "Move assignable type required");
entt::table<int, char> other{std::move(table)};
test::is_initialized(table);
ASSERT_TRUE(table.empty());
ASSERT_FALSE(other.empty());
ASSERT_EQ(other[0u], std::make_tuple(3, 'c'));
entt::table<int, char> extended{std::move(other), std::allocator<void>{}};
test::is_initialized(other);
ASSERT_TRUE(other.empty());
ASSERT_FALSE(extended.empty());
ASSERT_EQ(extended[0u], std::make_tuple(3, 'c'));
table = std::move(extended);
test::is_initialized(extended);
ASSERT_FALSE(table.empty());
ASSERT_TRUE(other.empty());
ASSERT_TRUE(extended.empty());
ASSERT_EQ(table[0u], std::make_tuple(3, 'c'));
other = entt::table<int, char>{};
other.emplace(1, 'a');
other = std::move(table);
test::is_initialized(table);
ASSERT_TRUE(table.empty());
ASSERT_FALSE(other.empty());
ASSERT_EQ(other[0u], std::make_tuple(3, 'c'));
}