diff --git a/test/entt/entity/entity.cpp b/test/entt/entity/entity.cpp index d84256c9d..f1f52face 100644 --- a/test/entt/entity/entity.cpp +++ b/test/entt/entity/entity.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "../common/custom_entity.h" struct custom_entity_traits { @@ -28,21 +27,20 @@ TYPED_TEST_SUITE(Entity, EntityTypes, ); TYPED_TEST(Entity, Traits) { using entity_type = typename TestFixture::type; using traits_type = entt::entt_traits; - constexpr entity_type tombstone = entt::tombstone; - constexpr entity_type null = entt::null; - entt::basic_registry registry{}; - registry.destroy(registry.create()); - const auto entity = registry.create(); - const auto other = registry.create(); + constexpr entity_type tombstone{entt::tombstone}; + constexpr entity_type null{entt::null}; + + const entity_type entity = traits_type::construct(42u, 1u); + const entity_type other = traits_type::construct(3u, 0u); ASSERT_EQ(entt::to_integral(entity), entt::to_integral(entity)); ASSERT_NE(entt::to_integral(entity), entt::to_integral(entt::null)); ASSERT_NE(entt::to_integral(entity), entt::to_integral(entity_type{})); - ASSERT_EQ(entt::to_entity(entity), 0u); + ASSERT_EQ(entt::to_entity(entity), 42u); ASSERT_EQ(entt::to_version(entity), 1u); - ASSERT_EQ(entt::to_entity(other), 1u); + ASSERT_EQ(entt::to_entity(other), 3u); ASSERT_EQ(entt::to_version(other), 0u); ASSERT_EQ(traits_type::construct(entt::to_entity(entity), entt::to_version(entity)), entity); @@ -64,61 +62,45 @@ TYPED_TEST(Entity, Traits) { TYPED_TEST(Entity, Null) { using entity_type = typename TestFixture::type; using traits_type = entt::entt_traits; - constexpr entity_type null = entt::null; + + constexpr entity_type null{entt::null}; ASSERT_FALSE(entity_type{} == entt::null); ASSERT_TRUE(entt::null == entt::null); ASSERT_FALSE(entt::null != entt::null); - entt::basic_registry registry{}; - const auto entity = registry.create(); + const entity_type entity{42u}; ASSERT_EQ(traits_type::combine(entt::null, entt::to_integral(entity)), (traits_type::construct(entt::to_entity(null), entt::to_version(entity)))); ASSERT_EQ(traits_type::combine(entt::null, entt::to_integral(null)), null); ASSERT_EQ(traits_type::combine(entt::null, entt::tombstone), null); - registry.template emplace(entity, 42); - ASSERT_FALSE(entity == entt::null); ASSERT_FALSE(entt::null == entity); ASSERT_TRUE(entity != entt::null); ASSERT_TRUE(entt::null != entity); - - const entity_type other = entt::null; - - ASSERT_FALSE(registry.valid(other)); - ASSERT_NE(registry.create(other), other); } TYPED_TEST(Entity, Tombstone) { using entity_type = typename TestFixture::type; using traits_type = entt::entt_traits; - constexpr entity_type tombstone = entt::tombstone; + + constexpr entity_type tombstone{entt::tombstone}; ASSERT_FALSE(entity_type{} == entt::tombstone); ASSERT_TRUE(entt::tombstone == entt::tombstone); ASSERT_FALSE(entt::tombstone != entt::tombstone); - entt::basic_registry registry{}; - const auto entity = registry.create(); + const entity_type entity{42u}; ASSERT_EQ(traits_type::combine(entt::to_integral(entity), entt::tombstone), (traits_type::construct(entt::to_entity(entity), entt::to_version(tombstone)))); ASSERT_EQ(traits_type::combine(entt::tombstone, entt::to_integral(tombstone)), tombstone); ASSERT_EQ(traits_type::combine(entt::tombstone, entt::null), tombstone); - registry.template emplace(entity, 42); - ASSERT_FALSE(entity == entt::tombstone); ASSERT_FALSE(entt::tombstone == entity); ASSERT_TRUE(entity != entt::tombstone); ASSERT_TRUE(entt::tombstone != entity); - - constexpr auto vers = entt::to_version(tombstone); - const auto other = traits_type::construct(entt::to_entity(entity), vers); - - ASSERT_FALSE(registry.valid(entt::tombstone)); - ASSERT_NE(registry.destroy(entity, vers), vers); - ASSERT_NE(registry.create(other), other); }