diff --git a/test/entt/entity/group.cpp b/test/entt/entity/group.cpp index 41ea04b52..a342b4bbf 100644 --- a/test/entt/entity/group.cpp +++ b/test/entt/entity/group.cpp @@ -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); auto cgroup = std::as_const(registry).group_if_exists(entt::get); @@ -319,7 +319,7 @@ TEST(NonOwningGroup, SortAsAPool) { } registry.sort(std::less{}); - group.sort_as(*group.storage()); + group.sort_as(*group.storage()); // NOLINT ASSERT_EQ((group.get(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(entt::get); auto cgroup = std::as_const(registry).group_if_exists(entt::get); diff --git a/test/entt/entity/handle.cpp b/test/entt/entity/handle.cpp index 2ec83d9e1..bfa20d1a6 100644 --- a/test/entt/entity/handle.cpp +++ b/test/entt/entity/handle.cpp @@ -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 handle{registry, entity}; + const entt::handle_view handle{registry, entity}; ASSERT_EQ(3, handle.emplace(3)); ASSERT_EQ('c', handle.emplace_or_replace('c')); @@ -208,7 +208,7 @@ TYPED_TEST(BasicHandle, FromEntity) { registry.emplace(entity, 42); registry.emplace(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 &>>(); @@ -281,7 +281,7 @@ TYPED_TEST(BasicHandle, HandleStorageIterator) { // required to test the find-first initialization step registry.storage().erase(entity); - handle_type handle{registry, entity}; + const handle_type handle{registry, entity}; auto iterable = handle.storage(); ASSERT_FALSE(registry.valid(entity)); diff --git a/test/entt/entity/helper.cpp b/test/entt/entity/helper.cpp index b0756b35b..b3419dc52 100644 --- a/test/entt/entity/helper.cpp +++ b/test/entt/entity/helper.cpp @@ -112,8 +112,8 @@ TYPED_TEST(ToEntityDeprecated, Functionalities) { constexpr auto page_size = entt::storage_type_t::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(); @@ -129,21 +129,21 @@ TYPED_TEST(ToEntityDeprecated, Functionalities) { registry.emplace(other); registry.emplace(next); - ASSERT_EQ(entt::to_entity(registry, registry.get(entity)), entity); - ASSERT_EQ(entt::to_entity(registry, registry.get(other)), other); - ASSERT_EQ(entt::to_entity(registry, registry.get(next)), next); + ASSERT_EQ(entt::to_entity(registry, registry.get(entity)), entity); // NOLINT + ASSERT_EQ(entt::to_entity(registry, registry.get(other)), other); // NOLINT + ASSERT_EQ(entt::to_entity(registry, registry.get(next)), next); // NOLINT ASSERT_EQ(®istry.get(entity) + page_size - (1u + traits_type::in_place_delete), ®istry.get(other)); registry.destroy(other); - ASSERT_EQ(entt::to_entity(registry, registry.get(entity)), entity); - ASSERT_EQ(entt::to_entity(registry, registry.get(next)), next); + ASSERT_EQ(entt::to_entity(registry, registry.get(entity)), entity); // NOLINT + ASSERT_EQ(entt::to_entity(registry, registry.get(next)), next); // NOLINT ASSERT_EQ(®istry.get(entity) + page_size - 1u, ®istry.get(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) { diff --git a/test/entt/entity/organizer.cpp b/test/entt/entity/organizer.cpp index 82db3f94f..b39ac9452 100644 --- a/test/entt/entity/organizer.cpp +++ b/test/entt/entity/organizer.cpp @@ -28,7 +28,7 @@ void to_args_integrity(entt::view> 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"); diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index 34d40a22f..07edf90f7 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -199,7 +199,7 @@ TEST(Registry, ContextAsRef) { ASSERT_EQ(registry.ctx().get(), 42); ASSERT_EQ(value, 42); - value = 3; + value = 3; // NOLINT ASSERT_EQ(std::as_const(registry).ctx().get(), 3); } @@ -215,7 +215,7 @@ TEST(Registry, ContextAsConstRef) { ASSERT_NE(std::as_const(registry).ctx().find(), nullptr); ASSERT_EQ(registry.ctx().get(), 3); - value = 42; + value = 42; // NOLINT ASSERT_EQ(std::as_const(registry).ctx().get(), 42); } @@ -1911,7 +1911,7 @@ TEST(Registry, TryGet) { } TEST(Registry, Constness) { - entt::registry registry; + entt::registry registry; // NOLINT testing::StaticAssertTypeEq({})), int &>(); testing::StaticAssertTypeEq({})), 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>(); diff --git a/test/entt/entity/runtime_view.cpp b/test/entt/entity/runtime_view.cpp index 259c91bca..4e7b2701d 100644 --- a/test/entt/entity/runtime_view.cpp +++ b/test/entt/entity/runtime_view.cpp @@ -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)); } diff --git a/test/entt/entity/sigh_mixin.cpp b/test/entt/entity/sigh_mixin.cpp index e9e4ed268..9c82bdc43 100644 --- a/test/entt/entity/sigh_mixin.cpp +++ b/test/entt/entity/sigh_mixin.cpp @@ -244,13 +244,13 @@ TEST(SighMixin, VoidType) { entt::sigh_mixin> 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); - ASSERT_TRUE(std::is_move_assignable_v); + static_assert(std::is_move_constructible_v, "Move constructible type required"); + static_assert(std::is_move_assignable_v, "Move assignable type required"); + ASSERT_EQ(pool.type(), entt::type_id()); entt::sigh_mixin> other{std::move(pool)}; - ASSERT_TRUE(pool.empty()); + ASSERT_TRUE(pool.empty()); // NOLINT ASSERT_FALSE(other.empty()); ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(pool.at(0u), static_cast(entt::null)); + ASSERT_EQ(pool.at(0u), static_cast(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::null)); + ASSERT_EQ(other.at(0u), static_cast(entt::null)); // NOLINT other = entt::sigh_mixin>{}; 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::null)); + ASSERT_EQ(pool.at(0u), static_cast(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 allocator{}; + const test::throwing_allocator allocator{}; entt::sigh_mixin>> 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); diff --git a/test/entt/entity/snapshot.cpp b/test/entt/entity/snapshot.cpp index 4d89afd99..47fffadb9 100644 --- a/test/entt/entity/snapshot.cpp +++ b/test/entt/entity/snapshot.cpp @@ -21,13 +21,13 @@ struct shadow { }; TEST(BasicSnapshot, Constructors) { - ASSERT_FALSE(std::is_default_constructible_v>); - ASSERT_FALSE(std::is_copy_constructible_v>); - ASSERT_FALSE(std::is_copy_assignable_v>); - ASSERT_TRUE(std::is_move_constructible_v>); - ASSERT_TRUE(std::is_move_assignable_v>); + static_assert(!std::is_default_constructible_v>, "Default constructible type not allowed"); + static_assert(!std::is_copy_constructible_v>, "Copy constructible type not allowed"); + static_assert(!std::is_copy_assignable_v>, "Copy assignable type not allowed"); + static_assert(std::is_move_constructible_v>, "Move constructible type required"); + static_assert(std::is_move_assignable_v>, "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::registry registry; - entt::basic_snapshot snapshot{registry}; + const entt::basic_snapshot snapshot{registry}; const auto &storage = registry.storage(); std::vector data{}; @@ -86,7 +86,7 @@ TEST(BasicSnapshot, GetType) { using traits_type = entt::entt_traits; entt::registry registry; - entt::basic_snapshot snapshot{registry}; + const entt::basic_snapshot snapshot{registry}; const auto &storage = registry.storage(); entt::entity entity[3u]; @@ -132,7 +132,7 @@ TEST(BasicSnapshot, GetEmptyType) { using traits_type = entt::entt_traits; entt::registry registry; - entt::basic_snapshot snapshot{registry}; + const entt::basic_snapshot snapshot{registry}; const auto &storage = registry.storage(); entt::entity entity[3u]; @@ -171,7 +171,7 @@ TEST(BasicSnapshot, GetTypeSparse) { using traits_type = entt::entt_traits; 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>); - ASSERT_FALSE(std::is_copy_constructible_v>); - ASSERT_FALSE(std::is_copy_assignable_v>); - ASSERT_TRUE(std::is_move_constructible_v>); - ASSERT_TRUE(std::is_move_assignable_v>); + static_assert(!std::is_default_constructible_v>, "Default constructible type not allowed"); + static_assert(!std::is_copy_constructible_v>, "Copy constructible type not allowed"); + static_assert(!std::is_copy_assignable_v>, "Copy assignable type not allowed"); + static_assert(std::is_move_constructible_v>, "Move constructible type required"); + static_assert(std::is_move_assignable_v>, "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(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>); - ASSERT_FALSE(std::is_copy_constructible_v>); - ASSERT_FALSE(std::is_copy_assignable_v>); - ASSERT_TRUE(std::is_move_constructible_v>); - ASSERT_TRUE(std::is_move_assignable_v>); + static_assert(!std::is_default_constructible_v>, "Default constructible type not allowed"); + static_assert(!std::is_copy_constructible_v>, "Copy constructible type not allowed"); + static_assert(!std::is_copy_assignable_v>, "Copy assignable type not allowed"); + static_assert(std::is_move_constructible_v>, "Move constructible type required"); + static_assert(std::is_move_assignable_v>, "Move assignable type required"); entt::registry registry; entt::basic_continuous_loader loader{registry}; diff --git a/test/entt/entity/sparse_set.cpp b/test/entt/entity/sparse_set.cpp index c02e5dca0..8032afce8 100644 --- a/test/entt/entity/sparse_set.cpp +++ b/test/entt/entity/sparse_set.cpp @@ -89,56 +89,56 @@ TYPED_TEST(SparseSet, Move) { set.push(entity_type{42}); - ASSERT_TRUE(std::is_move_constructible_v); - ASSERT_TRUE(std::is_move_assignable_v); + static_assert(std::is_move_constructible_v, "Move constructible type required"); + static_assert(std::is_move_assignable_v, "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(entt::null)); + ASSERT_EQ(set.at(0u), static_cast(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(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(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(entt::null)); - ASSERT_EQ(extended.at(0u), static_cast(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(entt::null)); // NOLINT + ASSERT_EQ(extended.at(0u), static_cast(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(entt::null)); + ASSERT_EQ(set.at(0u), static_cast(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; 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 allocator{}; + const test::throwing_allocator allocator{}; entt::basic_sparse_set> set{policy, allocator}; ASSERT_EQ(set.get_allocator(), allocator); @@ -2096,17 +2096,17 @@ TYPED_TEST(SparseSet, CustomAllocator) { entt::basic_sparse_set> 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); diff --git a/test/entt/entity/storage.cpp b/test/entt/entity/storage.cpp index 1811c9f81..8f7736e16 100644 --- a/test/entt/entity/storage.cpp +++ b/test/entt/entity/storage.cpp @@ -97,31 +97,31 @@ TYPED_TEST(Storage, Move) { pool.emplace(entt::entity{3}, 3); - ASSERT_TRUE(std::is_move_constructible_v); - ASSERT_TRUE(std::is_move_assignable_v); + static_assert(std::is_move_constructible_v, "Move constructible type required"); + static_assert(std::is_move_assignable_v, "Move assignable type required"); entt::storage other{std::move(pool)}; - ASSERT_TRUE(pool.empty()); + ASSERT_TRUE(pool.empty()); // NOLINT ASSERT_FALSE(other.empty()); - ASSERT_EQ(pool.type(), entt::type_id()); + ASSERT_EQ(pool.type(), entt::type_id()); // NOLINT ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(pool.at(0u), static_cast(entt::null)); + ASSERT_EQ(pool.at(0u), static_cast(entt::null)); // NOLINT ASSERT_EQ(other.at(0u), entt::entity{3}); ASSERT_EQ(other.get(entt::entity{3}), value_type{3}); entt::storage extended{std::move(other), std::allocator{}}; - ASSERT_TRUE(other.empty()); + ASSERT_TRUE(other.empty()); // NOLINT ASSERT_FALSE(extended.empty()); - ASSERT_EQ(other.type(), entt::type_id()); + ASSERT_EQ(other.type(), entt::type_id()); // NOLINT ASSERT_EQ(extended.type(), entt::type_id()); - ASSERT_EQ(other.at(0u), static_cast(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(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()); - ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(extended.type(), entt::type_id()); + ASSERT_EQ(other.type(), entt::type_id()); // NOLINT + ASSERT_EQ(extended.type(), entt::type_id()); // NOLINT ASSERT_EQ(pool.at(0u), entt::entity{3}); - ASSERT_EQ(other.at(0u), static_cast(entt::null)); - ASSERT_EQ(extended.at(0u), static_cast(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(entt::null)); // NOLINT + ASSERT_EQ(extended.at(0u), static_cast(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()); + ASSERT_EQ(pool.type(), entt::type_id()); // NOLINT ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(pool.at(0u), static_cast(entt::null)); + ASSERT_EQ(pool.at(0u), static_cast(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::iterator it = pool.begin(); + const typename entt::storage::iterator it = pool.begin(); typename entt::storage::const_iterator cit = it; testing::StaticAssertTypeEq(); @@ -614,7 +614,7 @@ TEST(Storage, EmplaceAggregate) { TEST(Storage, EmplaceSelfMoveSupport) { // see #37 - this test shouldn't crash, that's all entt::storage> 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> 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 pool; - entt::entity entity{42}; + const entt::entity entity{42}; auto callback = [](auto &&elem) { if constexpr(std::is_class_v>) { @@ -901,7 +901,7 @@ TYPED_TEST(Storage, CrossErase) { entt::storage 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 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(); entt::storage 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(); entt::storage 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::iterable::iterator it = pool.each().begin(); + const typename entt::storage::iterable::iterator it = pool.each().begin(); typename entt::storage::const_iterable::iterator cit = it; testing::StaticAssertTypeEq>(); @@ -1198,7 +1198,7 @@ TYPED_TEST(Storage, ReverseIterable) { testing::StaticAssertTypeEq(); entt::storage 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(); entt::storage 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::reverse_iterable::iterator it = pool.reach().begin(); + const typename entt::storage::reverse_iterable::iterator it = pool.reach().begin(); typename entt::storage::const_reverse_iterable::iterator cit = it; testing::StaticAssertTypeEq>(); @@ -1411,7 +1411,7 @@ TYPED_TEST(Storage, SortN) { TYPED_TEST(Storage, SortAsDisjoint) { using value_type = typename TestFixture::type; entt::storage lhs; - entt::storage rhs; + const entt::storage 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, "Copy assignable types not allowed"); static_assert(std::is_move_assignable_v, "Move assignable type required"); // the purpose is to ensure that move only components are always accepted - [[maybe_unused]] entt::storage pool; + [[maybe_unused]] const entt::storage pool; } TEST(Storage, NonMovableComponent) { using value_type = std::pair; static_assert(!std::is_move_assignable_v, "Move assignable types not allowed"); // the purpose is to ensure that non-movable components are always accepted - [[maybe_unused]] entt::storage pool; + [[maybe_unused]] const entt::storage 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 allocator{}; + const test::throwing_allocator allocator{}; entt::basic_storage> 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); diff --git a/test/entt/entity/storage_entity.cpp b/test/entt/entity/storage_entity.cpp index dedbfcbb6..cb100fcc8 100644 --- a/test/entt/entity/storage_entity.cpp +++ b/test/entt/entity/storage_entity.cpp @@ -31,56 +31,56 @@ TEST(StorageEntity, Move) { pool.emplace(entt::entity{3}); - ASSERT_TRUE(std::is_move_constructible_v); - ASSERT_TRUE(std::is_move_assignable_v); + static_assert(std::is_move_constructible_v, "Move constructible type required"); + static_assert(std::is_move_assignable_v, "Move assignable type required"); entt::storage other{std::move(pool)}; - ASSERT_TRUE(pool.empty()); + ASSERT_TRUE(pool.empty()); // NOLINT ASSERT_FALSE(other.empty()); - ASSERT_EQ(pool.type(), entt::type_id()); + ASSERT_EQ(pool.type(), entt::type_id()); // NOLINT ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(pool.at(0u), static_cast(entt::null)); + ASSERT_EQ(pool.at(0u), static_cast(entt::null)); // NOLINT ASSERT_EQ(other.at(0u), entt::entity{3}); entt::storage extended{std::move(other), std::allocator{}}; - ASSERT_TRUE(other.empty()); + ASSERT_TRUE(other.empty()); // NOLINT ASSERT_FALSE(extended.empty()); - ASSERT_EQ(other.type(), entt::type_id()); + ASSERT_EQ(other.type(), entt::type_id()); // NOLINT ASSERT_EQ(extended.type(), entt::type_id()); - ASSERT_EQ(other.at(0u), static_cast(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(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()); - ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(extended.type(), entt::type_id()); + ASSERT_EQ(other.type(), entt::type_id()); // NOLINT + ASSERT_EQ(extended.type(), entt::type_id()); // NOLINT ASSERT_EQ(pool.at(0u), entt::entity{3}); - ASSERT_EQ(other.at(0u), static_cast(entt::null)); - ASSERT_EQ(extended.at(0u), static_cast(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(entt::null)); // NOLINT + ASSERT_EQ(extended.at(0u), static_cast(entt::null)); // NOLINT other = entt::storage{}; 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()); + ASSERT_EQ(pool.type(), entt::type_id()); // NOLINT ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(pool.at(0u), static_cast(entt::null)); + ASSERT_EQ(pool.at(0u), static_cast(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 pool; pool.emplace(entt::entity{3}); - typename entt::storage::iterable::iterator it = pool.each().begin(); + const typename entt::storage::iterable::iterator it = pool.each().begin(); typename entt::storage::const_iterable::iterator cit = it; testing::StaticAssertTypeEq>(); @@ -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 pool; pool.emplace(entt::entity{3}); - typename entt::storage::reverse_iterable::iterator it = pool.reach().begin(); + const typename entt::storage::reverse_iterable::iterator it = pool.reach().begin(); typename entt::storage::const_reverse_iterable::iterator cit = it; testing::StaticAssertTypeEq>(); @@ -609,7 +609,7 @@ TEST(StorageEntity, SortN) { TEST(StorageEntity, SortAsDisjoint) { entt::storage lhs; - entt::storage rhs; + const entt::storage rhs; entt::entity lhs_entity[3u]{entt::entity{3}, entt::entity{12}, entt::entity{42}}; diff --git a/test/entt/entity/storage_no_instance.cpp b/test/entt/entity/storage_no_instance.cpp index a7dc561d0..c88dbabaf 100644 --- a/test/entt/entity/storage_no_instance.cpp +++ b/test/entt/entity/storage_no_instance.cpp @@ -74,56 +74,56 @@ TYPED_TEST(StorageNoInstance, Move) { pool.emplace(entt::entity{3}); - ASSERT_TRUE(std::is_move_constructible_v); - ASSERT_TRUE(std::is_move_assignable_v); + static_assert(std::is_move_constructible_v, "Move constructible type required"); + static_assert(std::is_move_assignable_v, "Move assignable type required"); entt::storage other{std::move(pool)}; - ASSERT_TRUE(pool.empty()); + ASSERT_TRUE(pool.empty()); // NOLINT ASSERT_FALSE(other.empty()); - ASSERT_EQ(pool.type(), entt::type_id()); + ASSERT_EQ(pool.type(), entt::type_id()); // NOLINT ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(pool.at(0u), static_cast(entt::null)); + ASSERT_EQ(pool.at(0u), static_cast(entt::null)); // NOLINT ASSERT_EQ(other.at(0u), entt::entity{3}); entt::storage extended{std::move(other), std::allocator{}}; - ASSERT_TRUE(other.empty()); + ASSERT_TRUE(other.empty()); // NOLINT ASSERT_FALSE(extended.empty()); - ASSERT_EQ(other.type(), entt::type_id()); + ASSERT_EQ(other.type(), entt::type_id()); // NOLINT ASSERT_EQ(extended.type(), entt::type_id()); - ASSERT_EQ(other.at(0u), static_cast(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(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()); - ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(extended.type(), entt::type_id()); + ASSERT_EQ(other.type(), entt::type_id()); // NOLINT + ASSERT_EQ(extended.type(), entt::type_id()); // NOLINT ASSERT_EQ(pool.at(0u), entt::entity{3}); - ASSERT_EQ(other.at(0u), static_cast(entt::null)); - ASSERT_EQ(extended.at(0u), static_cast(entt::null)); + ASSERT_EQ(other.at(0u), static_cast(entt::null)); // NOLINT + ASSERT_EQ(extended.at(0u), static_cast(entt::null)); // NOLINT other = entt::storage{}; 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()); + ASSERT_EQ(pool.type(), entt::type_id()); // NOLINT ASSERT_EQ(other.type(), entt::type_id()); - ASSERT_EQ(pool.at(0u), static_cast(entt::null)); + ASSERT_EQ(pool.at(0u), static_cast(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 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(); entt::storage 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(); entt::storage 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::iterable::iterator it = pool.each().begin(); + const typename entt::storage::iterable::iterator it = pool.each().begin(); typename entt::storage::const_iterable::iterator cit = it; testing::StaticAssertTypeEq>(); @@ -442,7 +442,7 @@ TYPED_TEST(StorageNoInstance, ReverseIterable) { testing::StaticAssertTypeEq(); entt::storage 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(); entt::storage 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::reverse_iterable::iterator it = pool.reach().begin(); + const typename entt::storage::reverse_iterable::iterator it = pool.reach().begin(); typename entt::storage::const_reverse_iterable::iterator cit = it; testing::StaticAssertTypeEq>(); @@ -617,7 +617,7 @@ TYPED_TEST(StorageNoInstance, SortN) { TYPED_TEST(StorageNoInstance, SortAsDisjoint) { using value_type = typename TestFixture::type; entt::storage lhs; - entt::storage rhs; + const entt::storage rhs; entt::entity lhs_entity[3u]{entt::entity{3}, entt::entity{12}, entt::entity{42}}; diff --git a/test/entt/entity/view.cpp b/test/entt/entity/view.cpp index a6272f9a8..856fc4b16 100644 --- a/test/entt/entity/view.cpp +++ b/test/entt/entity/view.cpp @@ -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 storage{}; - entt::view> invalid{}; - entt::basic_view from_storage{storage}; - entt::basic_view from_tuple{std::forward_as_tuple(storage)}; + const entt::view> 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(entt::exclude); auto cview = std::as_const(registry).view(); @@ -418,9 +418,9 @@ TEST(SingleComponentView, FrontBack) { } TEST(SingleComponentView, DeductionGuide) { - entt::registry registry; - entt::storage_type_t istorage; - entt::storage_type_t sstorage; + entt::registry registry; // NOLINT + entt::storage_type_t istorage; // NOLINT + entt::storage_type_t sstorage; // NOLINT testing::StaticAssertTypeEq>, entt::exclude_t<>>, decltype(entt::basic_view{istorage})>(); testing::StaticAssertTypeEq>, 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 storage{}; - entt::view> invalid{}; - entt::basic_view from_storage{storage, storage}; - entt::basic_view from_tuple{std::forward_as_tuple(storage, storage)}; + const entt::view> 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(entity[0u]); registry.emplace(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(entt::exclude); auto cview = std::as_const(registry).view(); @@ -1259,10 +1259,9 @@ TEST(MultiComponentView, ExtendedGet) { } TEST(MultiComponentView, DeductionGuide) { - entt::registry registry; - entt::storage_type_t istorage; - entt::storage_type_t dstorage; - entt::storage_type_t sstorage; + entt::storage_type_t istorage; // NOLINT + entt::storage_type_t dstorage; // NOLINT + entt::storage_type_t sstorage; // NOLINT testing::StaticAssertTypeEq, entt::storage_type_t>, entt::exclude_t<>>, decltype(entt::basic_view{istorage, dstorage})>(); testing::StaticAssertTypeEq, entt::storage_type_t>, entt::exclude_t<>>, decltype(entt::basic_view{std::as_const(istorage), dstorage})>();