test: [[nodiscard]], const-correctness and other linter related stuff

This commit is contained in:
Michele Caini
2023-12-19 11:06:08 +01:00
parent 2271fb8c0f
commit 3208281d94
13 changed files with 245 additions and 245 deletions

View File

@@ -69,7 +69,7 @@ TEST(NonOwningGroup, Functionalities) {
ASSERT_EQ(group.capacity(), 0u);
decltype(group) invalid{};
const decltype(group) invalid{};
ASSERT_TRUE(group);
ASSERT_TRUE(cgroup);
@@ -175,7 +175,7 @@ TEST(NonOwningGroup, Empty) {
TEST(NonOwningGroup, Each) {
entt::registry registry;
entt::entity entity[2]{registry.create(), registry.create()};
const entt::entity entity[2]{registry.create(), registry.create()};
auto group = registry.group(entt::get<int, char>);
auto cgroup = std::as_const(registry).group_if_exists(entt::get<const int, const char>);
@@ -319,7 +319,7 @@ TEST(NonOwningGroup, SortAsAPool) {
}
registry.sort<unsigned int>(std::less<unsigned int>{});
group.sort_as(*group.storage<unsigned int>());
group.sort_as(*group.storage<unsigned int>()); // NOLINT
ASSERT_EQ((group.get<const int, unsigned int>(e0)), (std::make_tuple(0, 0u)));
ASSERT_EQ((group.get<0, 1>(e1)), (std::make_tuple(1, 1u)));
@@ -820,7 +820,7 @@ TEST(OwningGroup, Functionalities) {
ASSERT_EQ(cgroup.rbegin(), cgroup.rend());
ASSERT_TRUE(group.empty());
decltype(group) invalid{};
const decltype(group) invalid{};
ASSERT_TRUE(group);
ASSERT_TRUE(cgroup);
@@ -924,7 +924,7 @@ TEST(OwningGroup, Empty) {
TEST(OwningGroup, Each) {
entt::registry registry;
entt::entity entity[2]{registry.create(), registry.create()};
const entt::entity entity[2]{registry.create(), registry.create()};
auto group = registry.group<int>(entt::get<char>);
auto cgroup = std::as_const(registry).group_if_exists<const int>(entt::get<const char>);

View File

@@ -36,7 +36,7 @@ TYPED_TEST(BasicHandle, Construction) {
entt::registry registry;
const auto entity = registry.create();
handle_type handle{registry, entity};
const handle_type handle{registry, entity};
ASSERT_FALSE(entt::null == handle.entity());
ASSERT_EQ(entity, handle);
@@ -146,7 +146,7 @@ TYPED_TEST(BasicHandle, Comparison) {
entt::registry diff;
handle = {registry, entity};
handle_type other = {diff, diff.create()};
const handle_type other = {diff, diff.create()};
ASSERT_NE(handle, other);
ASSERT_FALSE(other == handle);
@@ -158,7 +158,7 @@ TYPED_TEST(BasicHandle, Comparison) {
TEST(BasicHandle, Component) {
entt::registry registry;
const auto entity = registry.create();
entt::handle_view<int, char, double> handle{registry, entity};
const entt::handle_view<int, char, double> handle{registry, entity};
ASSERT_EQ(3, handle.emplace<int>(3));
ASSERT_EQ('c', handle.emplace_or_replace<char>('c'));
@@ -208,7 +208,7 @@ TYPED_TEST(BasicHandle, FromEntity) {
registry.emplace<int>(entity, 42);
registry.emplace<char>(entity, 'c');
handle_type handle{registry, entity};
const handle_type handle{registry, entity};
ASSERT_TRUE(handle);
ASSERT_EQ(entity, handle.entity());
@@ -256,7 +256,7 @@ TYPED_TEST(BasicHandle, Storage) {
entt::registry registry;
const auto entity = registry.create();
handle_type handle{registry, entity};
const handle_type handle{registry, entity};
testing::StaticAssertTypeEq<decltype(*handle.storage().begin()), std::pair<entt::id_type, entt::constness_as_t<entt::sparse_set, typename handle_type::registry_type> &>>();
@@ -281,7 +281,7 @@ TYPED_TEST(BasicHandle, HandleStorageIterator) {
// required to test the find-first initialization step
registry.storage<entt::entity>().erase(entity);
handle_type handle{registry, entity};
const handle_type handle{registry, entity};
auto iterable = handle.storage();
ASSERT_FALSE(registry.valid(entity));

View File

@@ -112,8 +112,8 @@ TYPED_TEST(ToEntityDeprecated, Functionalities) {
constexpr auto page_size = entt::storage_type_t<value_type>::traits_type::page_size;
const value_type value{42};
ASSERT_EQ(entt::to_entity(registry, value_type{42}), null);
ASSERT_EQ(entt::to_entity(registry, value), null);
ASSERT_EQ(entt::to_entity(registry, value_type{42}), null); // NOLINT
ASSERT_EQ(entt::to_entity(registry, value), null); // NOLINT
const auto entity = registry.create();
auto &&storage = registry.storage<value_type>();
@@ -129,21 +129,21 @@ TYPED_TEST(ToEntityDeprecated, Functionalities) {
registry.emplace<value_type>(other);
registry.emplace<value_type>(next);
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(entity)), entity);
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(other)), other);
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(next)), next);
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(entity)), entity); // NOLINT
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(other)), other); // NOLINT
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(next)), next); // NOLINT
ASSERT_EQ(&registry.get<value_type>(entity) + page_size - (1u + traits_type::in_place_delete), &registry.get<value_type>(other));
registry.destroy(other);
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(entity)), entity);
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(next)), next);
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(entity)), entity); // NOLINT
ASSERT_EQ(entt::to_entity(registry, registry.get<value_type>(next)), next); // NOLINT
ASSERT_EQ(&registry.get<value_type>(entity) + page_size - 1u, &registry.get<value_type>(next));
ASSERT_EQ(entt::to_entity(registry, value_type{42}), null);
ASSERT_EQ(entt::to_entity(registry, value), null);
ASSERT_EQ(entt::to_entity(registry, value_type{42}), null); // NOLINT
ASSERT_EQ(entt::to_entity(registry, value), null); // NOLINT
}
TEST(SighHelper, Functionalities) {

View File

@@ -28,7 +28,7 @@ void to_args_integrity(entt::view<entt::get_t<int>> view, std::size_t &value, en
TEST(Organizer, EmplaceFreeFunction) {
entt::organizer organizer;
entt::registry registry;
entt::registry registry; // NOLINT
organizer.emplace<&ro_int_rw_char_double>("t1");
organizer.emplace<&ro_char_rw_int>("t2");
@@ -84,7 +84,7 @@ TEST(Organizer, EmplaceFreeFunction) {
TEST(Organizer, EmplaceMemberFunction) {
entt::organizer organizer;
entt::registry registry;
entt::registry registry; // NOLINT
clazz instance;
organizer.emplace<&clazz::ro_int_char_double>(instance, "t1");
@@ -140,7 +140,7 @@ TEST(Organizer, EmplaceMemberFunction) {
TEST(Organizer, EmplaceFreeFunctionWithPayload) {
entt::organizer organizer;
entt::registry registry;
entt::registry registry; // NOLINT
clazz instance;
organizer.emplace<&clazz::ro_int_char_double>(instance, "t1");
@@ -204,7 +204,7 @@ TEST(Organizer, EmplaceFreeFunctionWithPayload) {
TEST(Organizer, EmplaceDirectFunction) {
entt::organizer organizer;
entt::registry registry;
entt::registry registry; // NOLINT
clazz instance;
// no aggressive comdat
@@ -277,7 +277,7 @@ TEST(Organizer, EmplaceDirectFunction) {
TEST(Organizer, SyncPoint) {
entt::organizer organizer;
entt::registry registry;
entt::registry registry; // NOLINT
clazz instance;
organizer.emplace<&ro_int_double>("before");

View File

@@ -199,7 +199,7 @@ TEST(Registry, ContextAsRef) {
ASSERT_EQ(registry.ctx().get<int>(), 42);
ASSERT_EQ(value, 42);
value = 3;
value = 3; // NOLINT
ASSERT_EQ(std::as_const(registry).ctx().get<const int>(), 3);
}
@@ -215,7 +215,7 @@ TEST(Registry, ContextAsConstRef) {
ASSERT_NE(std::as_const(registry).ctx().find<const int>(), nullptr);
ASSERT_EQ(registry.ctx().get<const int>(), 3);
value = 42;
value = 42; // NOLINT
ASSERT_EQ(std::as_const(registry).ctx().get<const int>(), 42);
}
@@ -1911,7 +1911,7 @@ TEST(Registry, TryGet) {
}
TEST(Registry, Constness) {
entt::registry registry;
entt::registry registry; // NOLINT
testing::StaticAssertTypeEq<decltype(registry.emplace<int>({})), int &>();
testing::StaticAssertTypeEq<decltype(registry.emplace<test::empty>({})), void>();
@@ -2229,7 +2229,7 @@ TEST(Registry, RegistryStorageIteratorConversion) {
auto proxy = registry.storage();
auto cproxy = std::as_const(registry).storage();
typename decltype(proxy)::iterator it = proxy.begin();
const typename decltype(proxy)::iterator it = proxy.begin();
typename decltype(cproxy)::iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), std::pair<entt::id_type, entt::sparse_set &>>();

View File

@@ -87,7 +87,7 @@ TYPED_TEST(RuntimeView, Constructors) {
ASSERT_TRUE(view.contains(entity));
runtime_view_type temp{view, view.get_allocator()};
runtime_view_type other{std::move(temp), view.get_allocator()};
const runtime_view_type other{std::move(temp), view.get_allocator()};
ASSERT_TRUE(view.contains(entity));
ASSERT_FALSE(temp.contains(entity));
@@ -140,7 +140,7 @@ TYPED_TEST(RuntimeView, Move) {
runtime_view_type other{std::move(view)};
ASSERT_FALSE(view.contains(entity));
ASSERT_FALSE(view.contains(entity)); // NOLINT
ASSERT_TRUE(other.contains(entity));
view = other;
@@ -151,7 +151,7 @@ TYPED_TEST(RuntimeView, Move) {
other = std::move(view);
ASSERT_FALSE(view.contains(entity));
ASSERT_FALSE(view.contains(entity)); // NOLINT
ASSERT_TRUE(other.contains(entity));
}

View File

@@ -244,13 +244,13 @@ TEST(SighMixin, VoidType) {
entt::sigh_mixin<entt::storage<void>> other{std::move(pool)};
ASSERT_FALSE(pool.contains(entt::entity{99}));
ASSERT_FALSE(pool.contains(entt::entity{99})); // NOLINT
ASSERT_TRUE(other.contains(entt::entity{99}));
pool = std::move(other);
ASSERT_TRUE(pool.contains(entt::entity{99}));
ASSERT_FALSE(other.contains(entt::entity{99}));
ASSERT_FALSE(other.contains(entt::entity{99})); // NOLINT
pool.clear();
@@ -336,26 +336,27 @@ TYPED_TEST(SighMixin, Move) {
pool.emplace(entt::entity{3}, 3);
ASSERT_TRUE(std::is_move_constructible_v<decltype(pool)>);
ASSERT_TRUE(std::is_move_assignable_v<decltype(pool)>);
static_assert(std::is_move_constructible_v<decltype(pool)>, "Move constructible type required");
static_assert(std::is_move_assignable_v<decltype(pool)>, "Move assignable type required");
ASSERT_EQ(pool.type(), entt::type_id<value_type>());
entt::sigh_mixin<entt::storage<value_type>> other{std::move(pool)};
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
pool = std::move(other);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_EQ(pool.at(0u), entt::entity{3});
ASSERT_EQ(pool.get(entt::entity{3}), value_type{3});
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
other = entt::sigh_mixin<entt::storage<value_type>>{};
other.bind(entt::forward_as_any(registry));
@@ -363,9 +364,9 @@ TYPED_TEST(SighMixin, Move) {
other.emplace(entt::entity{42}, 42);
other = std::move(pool);
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
@@ -449,7 +450,7 @@ TYPED_TEST(SighMixin, CustomRegistry) {
TYPED_TEST(SighMixin, CustomAllocator) {
using value_type = typename TestFixture::type;
test::throwing_allocator<entt::entity> allocator{};
const test::throwing_allocator<entt::entity> allocator{};
entt::sigh_mixin<entt::basic_storage<value_type, entt::entity, test::throwing_allocator<value_type>>> pool{allocator};
using registry_type = typename decltype(pool)::registry_type;
@@ -471,17 +472,17 @@ TYPED_TEST(SighMixin, CustomAllocator) {
decltype(pool) other{std::move(pool), allocator};
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.capacity(), 0u);
ASSERT_EQ(pool.capacity(), 0u); // NOLINT
ASSERT_NE(other.capacity(), 0u);
ASSERT_EQ(other.size(), 2u);
pool = std::move(other);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_EQ(other.capacity(), 0u);
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_EQ(other.capacity(), 0u); // NOLINT
ASSERT_NE(pool.capacity(), 0u);
ASSERT_EQ(pool.size(), 2u);
@@ -489,8 +490,8 @@ TYPED_TEST(SighMixin, CustomAllocator) {
pool = std::move(other);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_EQ(other.capacity(), 0u);
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_EQ(other.capacity(), 0u); // NOLINT
ASSERT_NE(pool.capacity(), 0u);
ASSERT_EQ(pool.size(), 2u);

View File

@@ -21,13 +21,13 @@ struct shadow {
};
TEST(BasicSnapshot, Constructors) {
ASSERT_FALSE(std::is_default_constructible_v<entt::basic_snapshot<entt::registry>>);
ASSERT_FALSE(std::is_copy_constructible_v<entt::basic_snapshot<entt::registry>>);
ASSERT_FALSE(std::is_copy_assignable_v<entt::basic_snapshot<entt::registry>>);
ASSERT_TRUE(std::is_move_constructible_v<entt::basic_snapshot<entt::registry>>);
ASSERT_TRUE(std::is_move_assignable_v<entt::basic_snapshot<entt::registry>>);
static_assert(!std::is_default_constructible_v<entt::basic_snapshot<entt::registry>>, "Default constructible type not allowed");
static_assert(!std::is_copy_constructible_v<entt::basic_snapshot<entt::registry>>, "Copy constructible type not allowed");
static_assert(!std::is_copy_assignable_v<entt::basic_snapshot<entt::registry>>, "Copy assignable type not allowed");
static_assert(std::is_move_constructible_v<entt::basic_snapshot<entt::registry>>, "Move constructible type required");
static_assert(std::is_move_assignable_v<entt::basic_snapshot<entt::registry>>, "Move assignable type required");
entt::registry registry;
const entt::registry registry;
entt::basic_snapshot snapshot{registry};
entt::basic_snapshot other{std::move(snapshot)};
@@ -39,7 +39,7 @@ TEST(BasicSnapshot, GetEntityType) {
using traits_type = entt::entt_traits<entt::entity>;
entt::registry registry;
entt::basic_snapshot snapshot{registry};
const entt::basic_snapshot snapshot{registry};
const auto &storage = registry.storage<entt::entity>();
std::vector<entt::any> data{};
@@ -86,7 +86,7 @@ TEST(BasicSnapshot, GetType) {
using traits_type = entt::entt_traits<entt::entity>;
entt::registry registry;
entt::basic_snapshot snapshot{registry};
const entt::basic_snapshot snapshot{registry};
const auto &storage = registry.storage<int>();
entt::entity entity[3u];
@@ -132,7 +132,7 @@ TEST(BasicSnapshot, GetEmptyType) {
using traits_type = entt::entt_traits<entt::entity>;
entt::registry registry;
entt::basic_snapshot snapshot{registry};
const entt::basic_snapshot snapshot{registry};
const auto &storage = registry.storage<test::empty>();
entt::entity entity[3u];
@@ -171,7 +171,7 @@ TEST(BasicSnapshot, GetTypeSparse) {
using traits_type = entt::entt_traits<entt::entity>;
entt::registry registry;
entt::basic_snapshot snapshot{registry};
const entt::basic_snapshot snapshot{registry};
entt::entity entity[3u];
const int values[3u]{1, 2, 3};
@@ -215,11 +215,11 @@ TEST(BasicSnapshot, GetTypeSparse) {
}
TEST(BasicSnapshotLoader, Constructors) {
ASSERT_FALSE(std::is_default_constructible_v<entt::basic_snapshot_loader<entt::registry>>);
ASSERT_FALSE(std::is_copy_constructible_v<entt::basic_snapshot_loader<entt::registry>>);
ASSERT_FALSE(std::is_copy_assignable_v<entt::basic_snapshot_loader<entt::registry>>);
ASSERT_TRUE(std::is_move_constructible_v<entt::basic_snapshot_loader<entt::registry>>);
ASSERT_TRUE(std::is_move_assignable_v<entt::basic_snapshot_loader<entt::registry>>);
static_assert(!std::is_default_constructible_v<entt::basic_snapshot_loader<entt::registry>>, "Default constructible type not allowed");
static_assert(!std::is_copy_constructible_v<entt::basic_snapshot_loader<entt::registry>>, "Copy constructible type not allowed");
static_assert(!std::is_copy_assignable_v<entt::basic_snapshot_loader<entt::registry>>, "Copy assignable type not allowed");
static_assert(std::is_move_constructible_v<entt::basic_snapshot_loader<entt::registry>>, "Move constructible type required");
static_assert(std::is_move_assignable_v<entt::basic_snapshot_loader<entt::registry>>, "Move assignable type required");
entt::registry registry;
entt::basic_snapshot_loader loader{registry};
@@ -232,7 +232,7 @@ ENTT_DEBUG_TEST(BasicSnapshotLoaderDeathTest, Constructors) {
entt::registry registry;
registry.emplace<int>(registry.create());
ASSERT_DEATH([[maybe_unused]] entt::basic_snapshot_loader loader{registry}, "");
ASSERT_DEATH([[maybe_unused]] const entt::basic_snapshot_loader loader{registry}, "");
}
TEST(BasicSnapshotLoader, GetEntityType) {
@@ -491,11 +491,11 @@ TEST(BasicSnapshotLoader, Orphans) {
}
TEST(BasicContinuousLoader, Constructors) {
ASSERT_FALSE(std::is_default_constructible_v<entt::basic_continuous_loader<entt::registry>>);
ASSERT_FALSE(std::is_copy_constructible_v<entt::basic_continuous_loader<entt::registry>>);
ASSERT_FALSE(std::is_copy_assignable_v<entt::basic_continuous_loader<entt::registry>>);
ASSERT_TRUE(std::is_move_constructible_v<entt::basic_continuous_loader<entt::registry>>);
ASSERT_TRUE(std::is_move_assignable_v<entt::basic_continuous_loader<entt::registry>>);
static_assert(!std::is_default_constructible_v<entt::basic_continuous_loader<entt::registry>>, "Default constructible type not allowed");
static_assert(!std::is_copy_constructible_v<entt::basic_continuous_loader<entt::registry>>, "Copy constructible type not allowed");
static_assert(!std::is_copy_assignable_v<entt::basic_continuous_loader<entt::registry>>, "Copy assignable type not allowed");
static_assert(std::is_move_constructible_v<entt::basic_continuous_loader<entt::registry>>, "Move constructible type required");
static_assert(std::is_move_assignable_v<entt::basic_continuous_loader<entt::registry>>, "Move assignable type required");
entt::registry registry;
entt::basic_continuous_loader loader{registry};

View File

@@ -89,56 +89,56 @@ TYPED_TEST(SparseSet, Move) {
set.push(entity_type{42});
ASSERT_TRUE(std::is_move_constructible_v<decltype(set)>);
ASSERT_TRUE(std::is_move_assignable_v<decltype(set)>);
static_assert(std::is_move_constructible_v<decltype(set)>, "Move constructible type required");
static_assert(std::is_move_assignable_v<decltype(set)>, "Move assignable type required");
sparse_set_type other{std::move(set)};
ASSERT_TRUE(set.empty());
ASSERT_TRUE(set.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(set.policy(), policy);
ASSERT_EQ(set.policy(), policy); // NOLINT
ASSERT_EQ(other.policy(), policy);
ASSERT_EQ(set.at(0u), static_cast<entity_type>(entt::null));
ASSERT_EQ(set.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entity_type{42});
sparse_set_type extended{std::move(other), allocator_type{}};
ASSERT_TRUE(other.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_FALSE(extended.empty());
ASSERT_EQ(other.policy(), policy);
ASSERT_EQ(other.policy(), policy); // NOLINT
ASSERT_EQ(extended.policy(), policy);
ASSERT_EQ(other.at(0u), static_cast<entity_type>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), entity_type{42});
set = std::move(extended);
ASSERT_FALSE(set.empty());
ASSERT_TRUE(other.empty());
ASSERT_TRUE(extended.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_TRUE(extended.empty()); // NOLINT
ASSERT_EQ(set.policy(), policy);
ASSERT_EQ(other.policy(), policy);
ASSERT_EQ(extended.policy(), policy);
ASSERT_EQ(other.policy(), policy); // NOLINT
ASSERT_EQ(extended.policy(), policy); // NOLINT
ASSERT_EQ(set.at(0u), entity_type{42});
ASSERT_EQ(other.at(0u), static_cast<entity_type>(entt::null));
ASSERT_EQ(extended.at(0u), static_cast<entity_type>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
other = sparse_set_type{policy};
other.push(entity_type{3});
other = std::move(set);
ASSERT_TRUE(set.empty());
ASSERT_TRUE(set.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(set.policy(), policy);
ASSERT_EQ(set.policy(), policy); // NOLINT
ASSERT_EQ(other.policy(), policy);
ASSERT_EQ(set.at(0u), static_cast<entity_type>(entt::null));
ASSERT_EQ(set.at(0u), static_cast<entity_type>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entity_type{42});
}
}
@@ -934,7 +934,7 @@ ENTT_DEBUG_TYPED_TEST(SparseSetDeathTest, Index) {
using entity_type = typename sparse_set_type::entity_type;
for(const auto policy: this->deletion_policy) {
sparse_set_type set{policy};
const sparse_set_type set{policy};
// index works the same in all cases, test only once
switch(policy) {
@@ -986,7 +986,7 @@ ENTT_DEBUG_TYPED_TEST(SparseSetDeathTest, Indexing) {
using sparse_set_type = entt::basic_sparse_set<typename TestFixture::type>;
for(const auto policy: this->deletion_policy) {
sparse_set_type set{policy};
const sparse_set_type set{policy};
// operator[] works the same in all cases, test only once
switch(policy) {
@@ -1768,8 +1768,8 @@ ENTT_DEBUG_TYPED_TEST(SparseSetDeathTest, Sort) {
for(const auto policy: this->deletion_policy) {
sparse_set_type set{policy};
entity_type entity{42};
entity_type other{3};
const entity_type entity{42};
const entity_type other{3};
set.push(entity);
set.push(other);
@@ -1828,8 +1828,8 @@ ENTT_DEBUG_TYPED_TEST(SparseSetDeathTest, SortN) {
for(const auto policy: this->deletion_policy) {
sparse_set_type set{policy};
entity_type entity{42};
entity_type other{3};
const entity_type entity{42};
const entity_type other{3};
ASSERT_DEATH(set.sort_n(1u, std::less{}), "");
@@ -1860,7 +1860,7 @@ TYPED_TEST(SparseSet, SortAsDisjoint) {
for(const auto policy: this->deletion_policy) {
sparse_set_type lhs{policy};
sparse_set_type rhs{policy};
const sparse_set_type rhs{policy};
entity_type lhs_entity[3u]{entity_type{3}, entity_type{12}, entity_type{42}};
@@ -1868,7 +1868,7 @@ TYPED_TEST(SparseSet, SortAsDisjoint) {
ASSERT_TRUE(std::equal(std::rbegin(lhs_entity), std::rend(lhs_entity), lhs.begin(), lhs.end()));
lhs.sort_as(rhs);
lhs.sort_as(rhs); // NOLINT
ASSERT_TRUE(std::equal(std::rbegin(lhs_entity), std::rend(lhs_entity), lhs.begin(), lhs.end()));
}
@@ -1891,7 +1891,7 @@ TYPED_TEST(SparseSet, SortAsOverlap) {
ASSERT_TRUE(std::equal(std::rbegin(lhs_entity), std::rend(lhs_entity), lhs.begin(), lhs.end()));
ASSERT_TRUE(std::equal(std::rbegin(rhs_entity), std::rend(rhs_entity), rhs.begin(), rhs.end()));
lhs.sort_as(rhs);
lhs.sort_as(rhs); // NOLINT
auto begin = lhs.begin();
auto end = lhs.end();
@@ -1920,7 +1920,7 @@ TYPED_TEST(SparseSet, SortAsOrdered) {
ASSERT_TRUE(std::equal(std::rbegin(lhs_entity), std::rend(lhs_entity), lhs.begin(), lhs.end()));
ASSERT_TRUE(std::equal(std::rbegin(rhs_entity), std::rend(rhs_entity), rhs.begin(), rhs.end()));
rhs.sort_as(lhs);
rhs.sort_as(lhs); // NOLINT
ASSERT_TRUE(std::equal(std::rbegin(rhs_entity), std::rend(rhs_entity), rhs.begin(), rhs.end()));
}
@@ -1943,7 +1943,7 @@ TYPED_TEST(SparseSet, SortAsReverse) {
ASSERT_TRUE(std::equal(std::rbegin(lhs_entity), std::rend(lhs_entity), lhs.begin(), lhs.end()));
ASSERT_TRUE(std::equal(std::rbegin(rhs_entity), std::rend(rhs_entity), rhs.begin(), rhs.end()));
rhs.sort_as(lhs);
rhs.sort_as(lhs); // NOLINT
auto begin = rhs.begin();
auto end = rhs.end();
@@ -1975,7 +1975,7 @@ TYPED_TEST(SparseSet, SortAsUnordered) {
ASSERT_TRUE(std::equal(std::rbegin(lhs_entity), std::rend(lhs_entity), lhs.begin(), lhs.end()));
ASSERT_TRUE(std::equal(std::rbegin(rhs_entity), std::rend(rhs_entity), rhs.begin(), rhs.end()));
rhs.sort_as(lhs);
rhs.sort_as(lhs); // NOLINT
auto begin = rhs.begin();
auto end = rhs.end();
@@ -2008,7 +2008,7 @@ TYPED_TEST(SparseSet, SortAsInvalid) {
ASSERT_TRUE(std::equal(std::rbegin(lhs_entity), std::rend(lhs_entity), lhs.begin(), lhs.end()));
ASSERT_TRUE(std::equal(std::rbegin(rhs_entity), std::rend(rhs_entity), rhs.begin(), rhs.end()));
rhs.sort_as(lhs);
rhs.sort_as(lhs); // NOLINT
auto begin = rhs.begin();
auto end = rhs.end();
@@ -2036,12 +2036,12 @@ ENTT_DEBUG_TYPED_TEST(SparseSetDeathTest, SortAs) {
SUCCEED();
} break;
case entt::deletion_policy::in_place: {
entity_type entity{42};
const entity_type entity{42};
lhs.push(entity);
lhs.erase(entity);
ASSERT_DEATH(lhs.sort_as(rhs), "");
ASSERT_DEATH(lhs.sort_as(rhs), ""); // NOLINT
} break;
case entt::deletion_policy::swap_only: {
entity_type entity[3u]{entity_type{3}, entity_type{42}, entity_type{9}};
@@ -2051,7 +2051,7 @@ ENTT_DEBUG_TYPED_TEST(SparseSetDeathTest, SortAs) {
lhs.erase(entity[0u]);
lhs.bump(entity[0u]);
ASSERT_DEATH(lhs.sort_as(rhs), "");
ASSERT_DEATH(lhs.sort_as(rhs), ""); // NOLINT
} break;
}
}
@@ -2082,7 +2082,7 @@ TYPED_TEST(SparseSet, CustomAllocator) {
using entity_type = typename sparse_set_type::entity_type;
for(const auto policy: this->deletion_policy) {
test::throwing_allocator<entity_type> allocator{};
const test::throwing_allocator<entity_type> allocator{};
entt::basic_sparse_set<entity_type, test::throwing_allocator<entity_type>> set{policy, allocator};
ASSERT_EQ(set.get_allocator(), allocator);
@@ -2096,17 +2096,17 @@ TYPED_TEST(SparseSet, CustomAllocator) {
entt::basic_sparse_set<entity_type, test::throwing_allocator<entity_type>> other{std::move(set), allocator};
ASSERT_TRUE(set.empty());
ASSERT_TRUE(set.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(set.capacity(), 0u);
ASSERT_EQ(set.capacity(), 0u); // NOLINT
ASSERT_EQ(other.capacity(), 2u);
ASSERT_EQ(other.size(), 2u);
set = std::move(other);
ASSERT_FALSE(set.empty());
ASSERT_TRUE(other.empty());
ASSERT_EQ(other.capacity(), 0u);
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_EQ(other.capacity(), 0u); // NOLINT
ASSERT_EQ(set.capacity(), 2u);
ASSERT_EQ(set.size(), 2u);
@@ -2114,8 +2114,8 @@ TYPED_TEST(SparseSet, CustomAllocator) {
set = std::move(other);
ASSERT_FALSE(set.empty());
ASSERT_TRUE(other.empty());
ASSERT_EQ(other.capacity(), 0u);
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_EQ(other.capacity(), 0u); // NOLINT
ASSERT_EQ(set.capacity(), 2u);
ASSERT_EQ(set.size(), 2u);

View File

@@ -97,31 +97,31 @@ TYPED_TEST(Storage, Move) {
pool.emplace(entt::entity{3}, 3);
ASSERT_TRUE(std::is_move_constructible_v<decltype(pool)>);
ASSERT_TRUE(std::is_move_assignable_v<decltype(pool)>);
static_assert(std::is_move_constructible_v<decltype(pool)>, "Move constructible type required");
static_assert(std::is_move_assignable_v<decltype(pool)>, "Move assignable type required");
entt::storage<value_type> other{std::move(pool)};
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
entt::storage<value_type> extended{std::move(other), std::allocator<value_type>{}};
ASSERT_TRUE(other.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_FALSE(extended.empty());
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(other.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(extended.type(), entt::type_id<value_type>());
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), entt::entity{3});
ASSERT_EQ(extended.get(entt::entity{3}), value_type{3});
@@ -129,16 +129,16 @@ TYPED_TEST(Storage, Move) {
pool = std::move(extended);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_TRUE(extended.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_TRUE(extended.empty()); // NOLINT
ASSERT_EQ(pool.type(), entt::type_id<value_type>());
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(extended.type(), entt::type_id<value_type>());
ASSERT_EQ(other.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(extended.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(pool.at(0u), entt::entity{3});
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(pool.get(entt::entity{3}), value_type{3});
@@ -146,13 +146,13 @@ TYPED_TEST(Storage, Move) {
other.emplace(entt::entity{42}, 42);
other = std::move(pool);
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
ASSERT_EQ(other.get(entt::entity{3}), value_type{3});
@@ -508,7 +508,7 @@ TYPED_TEST(Storage, IteratorConversion) {
pool.emplace(entt::entity{3}, 42);
typename entt::storage<value_type>::iterator it = pool.begin();
const typename entt::storage<value_type>::iterator it = pool.begin();
typename entt::storage<value_type>::const_iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), value_type &>();
@@ -614,7 +614,7 @@ TEST(Storage, EmplaceAggregate) {
TEST(Storage, EmplaceSelfMoveSupport) {
// see #37 - this test shouldn't crash, that's all
entt::storage<std::unordered_set<int>> pool;
entt::entity entity{42};
const entt::entity entity{42};
ASSERT_EQ(pool.policy(), entt::deletion_policy::swap_and_pop);
@@ -627,7 +627,7 @@ TEST(Storage, EmplaceSelfMoveSupport) {
TEST(Storage, EmplaceSelfMoveSupportInPlaceDelete) {
// see #37 - this test shouldn't crash, that's all
entt::storage<std::unordered_set<char>> pool;
entt::entity entity{42};
const entt::entity entity{42};
ASSERT_EQ(pool.policy(), entt::deletion_policy::in_place);
@@ -779,7 +779,7 @@ TYPED_TEST(Storage, Patch) {
using value_type = typename TestFixture::type;
entt::storage<value_type> pool;
entt::entity entity{42};
const entt::entity entity{42};
auto callback = [](auto &&elem) {
if constexpr(std::is_class_v<std::remove_reference_t<decltype(elem)>>) {
@@ -901,7 +901,7 @@ TYPED_TEST(Storage, CrossErase) {
entt::storage<value_type> pool;
entt::sparse_set set;
entt::entity entity[2u]{entt::entity{3}, entt::entity{42}};
const entt::entity entity[2u]{entt::entity{3}, entt::entity{42}};
pool.emplace(entity[0u], 3);
pool.emplace(entity[1u], 42);
@@ -961,7 +961,7 @@ TYPED_TEST(Storage, CrossRemove) {
entt::storage<value_type> pool;
entt::sparse_set set;
entt::entity entity[2u]{entt::entity{3}, entt::entity{42}};
const entt::entity entity[2u]{entt::entity{3}, entt::entity{42}};
pool.emplace(entity[0u], 3);
pool.emplace(entity[1u], 42);
@@ -1076,7 +1076,7 @@ TYPED_TEST(Storage, Iterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1}, 99);
pool.emplace(entt::entity{3}, 42);
@@ -1123,7 +1123,7 @@ TYPED_TEST(Storage, ConstIterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1}, 99);
pool.emplace(entt::entity{3}, 42);
@@ -1167,7 +1167,7 @@ TYPED_TEST(Storage, IterableIteratorConversion) {
pool.emplace(entt::entity{3}, 42);
typename entt::storage<value_type>::iterable::iterator it = pool.each().begin();
const typename entt::storage<value_type>::iterable::iterator it = pool.each().begin();
typename entt::storage<value_type>::const_iterable::iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), std::tuple<entt::entity, value_type &>>();
@@ -1198,7 +1198,7 @@ TYPED_TEST(Storage, ReverseIterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1}, 99);
pool.emplace(entt::entity{3}, 42);
@@ -1245,7 +1245,7 @@ TYPED_TEST(Storage, ConstReverseIterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1}, 99);
pool.emplace(entt::entity{3}, 42);
@@ -1289,7 +1289,7 @@ TYPED_TEST(Storage, ReverseIterableIteratorConversion) {
pool.emplace(entt::entity{3}, 42);
typename entt::storage<value_type>::reverse_iterable::iterator it = pool.reach().begin();
const typename entt::storage<value_type>::reverse_iterable::iterator it = pool.reach().begin();
typename entt::storage<value_type>::const_reverse_iterable::iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), std::tuple<entt::entity, value_type &>>();
@@ -1411,7 +1411,7 @@ TYPED_TEST(Storage, SortN) {
TYPED_TEST(Storage, SortAsDisjoint) {
using value_type = typename TestFixture::type;
entt::storage<value_type> lhs;
entt::storage<value_type> rhs;
const entt::storage<value_type> rhs;
entt::entity lhs_entity[3u]{entt::entity{3}, entt::entity{12}, entt::entity{42}};
value_type lhs_values[3u]{value_type{3}, value_type{6}, value_type{9}};
@@ -1579,14 +1579,14 @@ TEST(Storage, MoveOnlyComponent) {
static_assert(!std::is_copy_assignable_v<value_type>, "Copy assignable types not allowed");
static_assert(std::is_move_assignable_v<value_type>, "Move assignable type required");
// the purpose is to ensure that move only components are always accepted
[[maybe_unused]] entt::storage<value_type> pool;
[[maybe_unused]] const entt::storage<value_type> pool;
}
TEST(Storage, NonMovableComponent) {
using value_type = std::pair<const int, const int>;
static_assert(!std::is_move_assignable_v<value_type>, "Move assignable types not allowed");
// the purpose is to ensure that non-movable components are always accepted
[[maybe_unused]] entt::storage<value_type> pool;
[[maybe_unused]] const entt::storage<value_type> pool;
}
ENTT_DEBUG_TEST(StorageDeathTest, NonMovableComponent) {
@@ -1695,7 +1695,7 @@ TEST(Storage, CreateFromConstructor) {
TYPED_TEST(Storage, CustomAllocator) {
using value_type = typename TestFixture::type;
test::throwing_allocator<entt::entity> allocator{};
const test::throwing_allocator<entt::entity> allocator{};
entt::basic_storage<value_type, entt::entity, test::throwing_allocator<value_type>> pool{allocator};
pool.reserve(1u);
@@ -1707,17 +1707,17 @@ TYPED_TEST(Storage, CustomAllocator) {
decltype(pool) other{std::move(pool), allocator};
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.capacity(), 0u);
ASSERT_EQ(pool.capacity(), 0u); // NOLINT
ASSERT_NE(other.capacity(), 0u);
ASSERT_EQ(other.size(), 2u);
pool = std::move(other);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_EQ(other.capacity(), 0u);
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_EQ(other.capacity(), 0u); // NOLINT
ASSERT_NE(pool.capacity(), 0u);
ASSERT_EQ(pool.size(), 2u);
@@ -1725,8 +1725,8 @@ TYPED_TEST(Storage, CustomAllocator) {
pool = std::move(other);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_EQ(other.capacity(), 0u);
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_EQ(other.capacity(), 0u); // NOLINT
ASSERT_NE(pool.capacity(), 0u);
ASSERT_EQ(pool.size(), 2u);

View File

@@ -31,56 +31,56 @@ TEST(StorageEntity, Move) {
pool.emplace(entt::entity{3});
ASSERT_TRUE(std::is_move_constructible_v<decltype(pool)>);
ASSERT_TRUE(std::is_move_assignable_v<decltype(pool)>);
static_assert(std::is_move_constructible_v<decltype(pool)>, "Move constructible type required");
static_assert(std::is_move_assignable_v<decltype(pool)>, "Move assignable type required");
entt::storage<entt::entity> other{std::move(pool)};
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(pool.type(), entt::type_id<void>()); // NOLINT
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
entt::storage<entt::entity> extended{std::move(other), std::allocator<entt::entity>{}};
ASSERT_TRUE(other.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_FALSE(extended.empty());
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>()); // NOLINT
ASSERT_EQ(extended.type(), entt::type_id<void>());
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), entt::entity{3});
pool = std::move(extended);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_TRUE(extended.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_TRUE(extended.empty()); // NOLINT
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(extended.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>()); // NOLINT
ASSERT_EQ(extended.type(), entt::type_id<void>()); // NOLINT
ASSERT_EQ(pool.at(0u), entt::entity{3});
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
other = entt::storage<entt::entity>{};
other.emplace(entt::entity{42});
other = std::move(pool);
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(pool.type(), entt::type_id<void>()); // NOLINT
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
}
@@ -153,13 +153,13 @@ TEST(StorageEntity, Emplace) {
ASSERT_EQ(pool.emplace(traits_type::construct(1, 1)), entt::entity{4});
ASSERT_EQ(pool.emplace(traits_type::construct(6, 3)), traits_type::construct(6, 3));
ASSERT_LT(pool.index(entt::entity{0}), pool.in_use());
ASSERT_LT(pool.index(entt::entity{1}), pool.in_use());
ASSERT_LT(pool.index(entt::entity{2}), pool.in_use());
ASSERT_LT(pool.index(entt::entity{3}), pool.in_use());
ASSERT_LT(pool.index(entt::entity{4}), pool.in_use());
ASSERT_GE(pool.index(entt::entity{5}), pool.in_use());
ASSERT_LT(pool.index(traits_type::construct(6, 3)), pool.in_use());
ASSERT_LT(pool.index(entt::entity{0}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{1}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{2}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{3}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{4}), pool.in_use()); // NOLINT
ASSERT_GE(pool.index(entt::entity{5}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(traits_type::construct(6, 3)), pool.in_use()); // NOLINT
ASSERT_EQ(pool.emplace(traits_type::construct(5, 42)), traits_type::construct(5, 42));
ASSERT_EQ(pool.emplace(traits_type::construct(5, 43)), entt::entity{7});
@@ -186,12 +186,12 @@ TEST(StorageEntity, TryEmplace) {
ASSERT_EQ(*pool.push(traits_type::construct(1, 1)), entt::entity{3});
ASSERT_EQ(*pool.push(traits_type::construct(5, 3)), traits_type::construct(5, 3));
ASSERT_LT(pool.index(entt::entity{0}), pool.in_use());
ASSERT_LT(pool.index(entt::entity{1}), pool.in_use());
ASSERT_LT(pool.index(entt::entity{2}), pool.in_use());
ASSERT_LT(pool.index(entt::entity{3}), pool.in_use());
ASSERT_GE(pool.index(entt::entity{4}), pool.in_use());
ASSERT_LT(pool.index(traits_type::construct(5, 3)), pool.in_use());
ASSERT_LT(pool.index(entt::entity{0}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{1}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{2}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{3}), pool.in_use()); // NOLINT
ASSERT_GE(pool.index(entt::entity{4}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(traits_type::construct(5, 3)), pool.in_use()); // NOLINT
ASSERT_EQ(*pool.push(traits_type::construct(4, 42)), traits_type::construct(4, 42));
ASSERT_EQ(*pool.push(traits_type::construct(4, 43)), entt::entity{6});
@@ -205,12 +205,12 @@ TEST(StorageEntity, TryEmplace) {
ASSERT_EQ(pool.current(entity[1u]), 4);
ASSERT_EQ(pool.current(entt::entity{2}), 1);
ASSERT_LT(pool.index(entt::entity{0}), pool.in_use());
ASSERT_GE(pool.index(traits_type::construct(1, 1)), pool.in_use());
ASSERT_GE(pool.index(traits_type::construct(2, 1)), pool.in_use());
ASSERT_LT(pool.index(entt::entity{3}), pool.in_use());
ASSERT_LT(pool.index(traits_type::construct(4, 42)), pool.in_use());
ASSERT_GE(pool.index(traits_type::construct(5, 4)), pool.in_use());
ASSERT_LT(pool.index(entt::entity{0}), pool.in_use()); // NOLINT
ASSERT_GE(pool.index(traits_type::construct(1, 1)), pool.in_use()); // NOLINT
ASSERT_GE(pool.index(traits_type::construct(2, 1)), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(entt::entity{3}), pool.in_use()); // NOLINT
ASSERT_LT(pool.index(traits_type::construct(4, 42)), pool.in_use()); // NOLINT
ASSERT_GE(pool.index(traits_type::construct(5, 4)), pool.in_use()); // NOLINT
ASSERT_EQ(*pool.push(entt::null), traits_type::construct(2, 1));
ASSERT_EQ(*pool.push(traits_type::construct(1, 3)), traits_type::construct(1, 3));
@@ -251,13 +251,13 @@ TEST(StorageEntity, Insert) {
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.in_use(), 2u);
ASSERT_EQ(pool.in_use(), 2u); // NOLINT
pool.erase(std::begin(entity), std::end(entity));
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.in_use(), 0u);
ASSERT_EQ(pool.in_use(), 0u); // NOLINT
pool.insert(entity, entity + 1u);
@@ -266,7 +266,7 @@ TEST(StorageEntity, Insert) {
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.in_use(), 1u);
ASSERT_EQ(pool.in_use(), 1u); // NOLINT
}
TEST(StorageEntity, Pack) {
@@ -276,7 +276,7 @@ TEST(StorageEntity, Pack) {
pool.push(entity, entity + 3u);
std::swap(entity[0u], entity[1u]);
const auto len = pool.pack(entity + 1u, entity + 3u);
const auto len = pool.pack(entity + 1u, entity + 3u); // NOLINT
auto it = pool.each().cbegin().base();
ASSERT_NE(it, pool.cbegin());
@@ -299,17 +299,17 @@ TEST(StorageEntity, InUse) {
pool.emplace(entt::entity{0});
ASSERT_EQ(pool.in_use(), 1u);
ASSERT_EQ(pool.in_use(), 1u); // NOLINT
ASSERT_EQ(pool.free_list(), 1u);
pool.in_use(0u);
pool.in_use(0u); // NOLINT
ASSERT_EQ(pool.in_use(), 0u);
ASSERT_EQ(pool.in_use(), 0u); // NOLINT
ASSERT_EQ(pool.free_list(), 0u);
pool.in_use(1u);
pool.in_use(1u); // NOLINT
ASSERT_EQ(pool.in_use(), 1u);
ASSERT_EQ(pool.in_use(), 1u); // NOLINT
ASSERT_EQ(pool.free_list(), 1u);
}
@@ -318,7 +318,7 @@ ENTT_DEBUG_TEST(StorageEntityDeathTest, InUse) {
pool.emplace(entt::entity{0});
ASSERT_DEATH(pool.in_use(2u), "");
ASSERT_DEATH(pool.in_use(2u), ""); // NOLINT
}
TEST(StorageEntity, Iterable) {
@@ -348,7 +348,7 @@ TEST(StorageEntity, Iterable) {
ASSERT_NE(begin, end);
ASSERT_NE(begin.base(), pool.begin());
ASSERT_EQ(begin.base(), pool.end() - pool.in_use());
ASSERT_EQ(begin.base(), pool.end() - pool.in_use()); // NOLINT
ASSERT_EQ(end.base(), pool.end());
ASSERT_EQ(std::get<0>(*begin.operator->().operator->()), entt::entity{42});
@@ -392,7 +392,7 @@ TEST(StorageEntity, ConstIterable) {
ASSERT_NE(begin, end);
ASSERT_NE(begin.base(), pool.begin());
ASSERT_EQ(begin.base(), pool.end() - pool.in_use());
ASSERT_EQ(begin.base(), pool.end() - pool.in_use()); // NOLINT
ASSERT_EQ(end.base(), pool.end());
ASSERT_EQ(std::get<0>(*begin.operator->().operator->()), entt::entity{42});
@@ -413,7 +413,7 @@ TEST(StorageEntity, IterableIteratorConversion) {
entt::storage<entt::entity> pool;
pool.emplace(entt::entity{3});
typename entt::storage<entt::entity>::iterable::iterator it = pool.each().begin();
const typename entt::storage<entt::entity>::iterable::iterator it = pool.each().begin();
typename entt::storage<entt::entity>::const_iterable::iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), std::tuple<entt::entity>>();
@@ -460,7 +460,7 @@ TEST(StorageEntity, ReverseIterable) {
ASSERT_NE(begin, end);
ASSERT_EQ(begin.base(), pool.rbegin());
ASSERT_EQ(end.base(), pool.rbegin() + pool.in_use());
ASSERT_EQ(end.base(), pool.rbegin() + pool.in_use()); // NOLINT
ASSERT_NE(end.base(), pool.rend());
ASSERT_EQ(std::get<0>(*begin.operator->().operator->()), entt::entity{1});
@@ -504,7 +504,7 @@ TEST(StorageEntity, ReverseConstIterable) {
ASSERT_NE(begin, end);
ASSERT_EQ(begin.base(), pool.rbegin());
ASSERT_EQ(end.base(), pool.rbegin() + pool.in_use());
ASSERT_EQ(end.base(), pool.rbegin() + pool.in_use()); // NOLINT
ASSERT_NE(end.base(), pool.rend());
ASSERT_EQ(std::get<0>(*begin.operator->().operator->()), entt::entity{1});
@@ -525,7 +525,7 @@ TEST(StorageEntity, ReverseIterableIteratorConversion) {
entt::storage<entt::entity> pool;
pool.emplace(entt::entity{3});
typename entt::storage<entt::entity>::reverse_iterable::iterator it = pool.reach().begin();
const typename entt::storage<entt::entity>::reverse_iterable::iterator it = pool.reach().begin();
typename entt::storage<entt::entity>::const_reverse_iterable::iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), std::tuple<entt::entity>>();
@@ -609,7 +609,7 @@ TEST(StorageEntity, SortN) {
TEST(StorageEntity, SortAsDisjoint) {
entt::storage<entt::entity> lhs;
entt::storage<entt::entity> rhs;
const entt::storage<entt::entity> rhs;
entt::entity lhs_entity[3u]{entt::entity{3}, entt::entity{12}, entt::entity{42}};

View File

@@ -74,56 +74,56 @@ TYPED_TEST(StorageNoInstance, Move) {
pool.emplace(entt::entity{3});
ASSERT_TRUE(std::is_move_constructible_v<decltype(pool)>);
ASSERT_TRUE(std::is_move_assignable_v<decltype(pool)>);
static_assert(std::is_move_constructible_v<decltype(pool)>, "Move constructible type required");
static_assert(std::is_move_assignable_v<decltype(pool)>, "Move assignable type required");
entt::storage<value_type> other{std::move(pool)};
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
entt::storage<value_type> extended{std::move(other), std::allocator<value_type>{}};
ASSERT_TRUE(other.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_FALSE(extended.empty());
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(other.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(extended.type(), entt::type_id<value_type>());
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), entt::entity{3});
pool = std::move(extended);
ASSERT_FALSE(pool.empty());
ASSERT_TRUE(other.empty());
ASSERT_TRUE(extended.empty());
ASSERT_TRUE(other.empty()); // NOLINT
ASSERT_TRUE(extended.empty()); // NOLINT
ASSERT_EQ(pool.type(), entt::type_id<value_type>());
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(extended.type(), entt::type_id<value_type>());
ASSERT_EQ(other.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(extended.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(pool.at(0u), entt::entity{3});
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(extended.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
other = entt::storage<value_type>{};
other.emplace(entt::entity{42}, 42);
other = std::move(pool);
ASSERT_TRUE(pool.empty());
ASSERT_TRUE(pool.empty()); // NOLINT
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.type(), entt::type_id<value_type>()); // NOLINT
ASSERT_EQ(other.type(), entt::type_id<value_type>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null)); // NOLINT
ASSERT_EQ(other.at(0u), entt::entity{3});
}
@@ -261,7 +261,7 @@ TYPED_TEST(StorageNoInstance, Patch) {
using value_type = typename TestFixture::type;
entt::storage<value_type> pool;
entt::entity entity{42};
const entt::entity entity{42};
int counter = 0;
auto callback = [&counter]() { ++counter; };
@@ -326,7 +326,7 @@ TYPED_TEST(StorageNoInstance, Iterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1});
pool.emplace(entt::entity{3});
@@ -370,7 +370,7 @@ TYPED_TEST(StorageNoInstance, ConstIterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1});
pool.emplace(entt::entity{3});
@@ -410,7 +410,7 @@ TYPED_TEST(StorageNoInstance, IterableIteratorConversion) {
pool.emplace(entt::entity{3});
typename entt::storage<value_type>::iterable::iterator it = pool.each().begin();
const typename entt::storage<value_type>::iterable::iterator it = pool.each().begin();
typename entt::storage<value_type>::const_iterable::iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), std::tuple<entt::entity>>();
@@ -442,7 +442,7 @@ TYPED_TEST(StorageNoInstance, ReverseIterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1});
pool.emplace(entt::entity{3});
@@ -486,7 +486,7 @@ TYPED_TEST(StorageNoInstance, ConstReverseIterable) {
testing::StaticAssertTypeEq<typename iterator::reference, typename iterator::value_type>();
entt::storage<value_type> pool;
entt::sparse_set &base = pool;
const entt::sparse_set &base = pool;
pool.emplace(entt::entity{1});
pool.emplace(entt::entity{3});
@@ -526,7 +526,7 @@ TYPED_TEST(StorageNoInstance, ReverseIterableIteratorConversion) {
pool.emplace(entt::entity{3});
typename entt::storage<value_type>::reverse_iterable::iterator it = pool.reach().begin();
const typename entt::storage<value_type>::reverse_iterable::iterator it = pool.reach().begin();
typename entt::storage<value_type>::const_reverse_iterable::iterator cit = it;
testing::StaticAssertTypeEq<decltype(*it), std::tuple<entt::entity>>();
@@ -617,7 +617,7 @@ TYPED_TEST(StorageNoInstance, SortN) {
TYPED_TEST(StorageNoInstance, SortAsDisjoint) {
using value_type = typename TestFixture::type;
entt::storage<value_type> lhs;
entt::storage<value_type> rhs;
const entt::storage<value_type> rhs;
entt::entity lhs_entity[3u]{entt::entity{3}, entt::entity{12}, entt::entity{42}};

View File

@@ -61,7 +61,7 @@ TEST(SingleComponentView, Functionalities) {
ASSERT_EQ(view.rbegin(), view.rend());
ASSERT_TRUE(view.empty());
decltype(view) invalid{};
const decltype(view) invalid{};
ASSERT_TRUE(view);
ASSERT_TRUE(cview);
@@ -107,9 +107,9 @@ TEST(SingleComponentView, InvalidView) {
TEST(SingleComponentView, Constructors) {
entt::storage<int> storage{};
entt::view<entt::get_t<int>> invalid{};
entt::basic_view from_storage{storage};
entt::basic_view from_tuple{std::forward_as_tuple(storage)};
const entt::view<entt::get_t<int>> invalid{};
const entt::basic_view from_storage{storage};
const entt::basic_view from_tuple{std::forward_as_tuple(storage)};
ASSERT_FALSE(invalid);
ASSERT_TRUE(from_storage);
@@ -210,7 +210,7 @@ TEST(SingleComponentView, Empty) {
TEST(SingleComponentView, Each) {
entt::registry registry;
entt::entity entity[2]{registry.create(), registry.create()};
const entt::entity entity[2]{registry.create(), registry.create()};
auto view = registry.view<int>(entt::exclude<double>);
auto cview = std::as_const(registry).view<const int>();
@@ -418,9 +418,9 @@ TEST(SingleComponentView, FrontBack) {
}
TEST(SingleComponentView, DeductionGuide) {
entt::registry registry;
entt::storage_type_t<int> istorage;
entt::storage_type_t<test::pointer_stable> sstorage;
entt::registry registry; // NOLINT
entt::storage_type_t<int> istorage; // NOLINT
entt::storage_type_t<test::pointer_stable> sstorage; // NOLINT
testing::StaticAssertTypeEq<entt::basic_view<entt::get_t<entt::storage_type_t<int>>, entt::exclude_t<>>, decltype(entt::basic_view{istorage})>();
testing::StaticAssertTypeEq<entt::basic_view<entt::get_t<const entt::storage_type_t<int>>, entt::exclude_t<>>, decltype(entt::basic_view{std::as_const(istorage)})>();
@@ -636,7 +636,7 @@ TEST(MultiComponentView, Functionalities) {
ASSERT_EQ(cview.get<1u>(entity), '2');
}
decltype(view) invalid{};
const decltype(view) invalid{};
ASSERT_TRUE(view);
ASSERT_TRUE(cview);
@@ -686,9 +686,9 @@ TEST(MultiComponentView, InvalidView) {
TEST(MultiComponentView, Constructors) {
entt::storage<int> storage{};
entt::view<entt::get_t<int, int>> invalid{};
entt::basic_view from_storage{storage, storage};
entt::basic_view from_tuple{std::forward_as_tuple(storage, storage)};
const entt::view<entt::get_t<int, int>> invalid{};
const entt::basic_view from_storage{storage, storage};
const entt::basic_view from_tuple{std::forward_as_tuple(storage, storage)};
ASSERT_FALSE(invalid);
ASSERT_TRUE(from_storage);
@@ -854,7 +854,7 @@ TEST(MultiComponentView, SizeHint) {
TEST(MultiComponentView, UseAndRefresh) {
entt::registry registry;
entt::entity entity[3]{registry.create(), registry.create(), registry.create()};
const entt::entity entity[3]{registry.create(), registry.create(), registry.create()};
registry.emplace<int>(entity[0u]);
registry.emplace<int>(entity[1u]);
@@ -884,7 +884,7 @@ TEST(MultiComponentView, UseAndRefresh) {
TEST(MultiComponentView, Each) {
entt::registry registry;
entt::entity entity[2]{registry.create(), registry.create()};
const entt::entity entity[2]{registry.create(), registry.create()};
auto view = registry.view<int, char>(entt::exclude<double>);
auto cview = std::as_const(registry).view<const int, const char>();
@@ -1259,10 +1259,9 @@ TEST(MultiComponentView, ExtendedGet) {
}
TEST(MultiComponentView, DeductionGuide) {
entt::registry registry;
entt::storage_type_t<int> istorage;
entt::storage_type_t<double> dstorage;
entt::storage_type_t<test::pointer_stable> sstorage;
entt::storage_type_t<int> istorage; // NOLINT
entt::storage_type_t<double> dstorage; // NOLINT
entt::storage_type_t<test::pointer_stable> sstorage; // NOLINT
testing::StaticAssertTypeEq<entt::basic_view<entt::get_t<entt::storage_type_t<int>, entt::storage_type_t<double>>, entt::exclude_t<>>, decltype(entt::basic_view{istorage, dstorage})>();
testing::StaticAssertTypeEq<entt::basic_view<entt::get_t<const entt::storage_type_t<int>, entt::storage_type_t<double>>, entt::exclude_t<>>, decltype(entt::basic_view{std::as_const(istorage), dstorage})>();