diff --git a/test/entt/entity/poly_storage.cpp b/test/entt/entity/poly_storage.cpp index 01161a289..d5261ea83 100644 --- a/test/entt/entity/poly_storage.cpp +++ b/test/entt/entity/poly_storage.cpp @@ -13,10 +13,7 @@ struct PolyStorage: entt::type_list_cat_t< entt::type_list< void(entt::basic_registry &, const Entity, const void *), const void *(const Entity) const, - const Entity *() const, - const void *() const, - std::size_t() const, - void(entt::basic_registry &, const Entity *, const void *, const std::size_t) + void(entt::basic_registry &, entt::basic_registry &) > > { using entity_type = Entity; @@ -34,20 +31,8 @@ struct PolyStorage: entt::type_list_cat_t< return entt::poly_call(*this, entity); } - const entity_type * data() const { - return entt::poly_call(*this); - } - - const void * raw() const { - return entt::poly_call(*this); - } - - size_type size() const { - return entt::poly_call(*this); - } - - void insert(entt::basic_registry &owner, const Entity *entity, const void *instance, const std::size_t length) { - entt::poly_call(*this, owner, entity, instance, length); + void copy(entt::basic_registry &owner, entt::basic_registry &other) { + entt::poly_call(*this, owner, other); } }; @@ -61,9 +46,8 @@ struct PolyStorage: entt::type_list_cat_t< return &self.get(entity); } - static void insert(Type &self, entt::basic_registry &owner, const entity_type *entity, const void *instance, const size_type length) { - const auto *value = static_cast(instance); - self.insert(owner, entity, entity + length, value, value + length); + static void copy(Type &self, entt::basic_registry &owner, entt::basic_registry &other) { + other.template insert(self.data(), self.data() + self.size(), self.raw(), self.raw() + self.size()); } }; @@ -73,10 +57,7 @@ struct PolyStorage: entt::type_list_cat_t< entt::value_list< &members::emplace, &members::get, - &Type::data, - entt::overload(&Type::raw), - &Type::size, - &members::insert + &members::copy > >; }; @@ -118,20 +99,19 @@ TEST(PolyStorage, CopyRegistry) { registry.insert(std::begin(entities), std::end(entities), 42); registry.insert(std::begin(entities), std::end(entities), 'c'); - other.prepare(); - other.prepare(); - ASSERT_EQ(registry.size(), 10u); ASSERT_EQ(other.size(), 0u); other.assign(registry.data(), registry.data() + registry.size(), registry.destroyed()); - - registry.visit([&](const auto info) { - auto storage = registry.storage(info); - other.storage(info)->insert(other, storage->data(), storage->raw(), storage->size()); - }); + registry.visit([&](const auto info) { registry.storage(info)->copy(registry, other); }); ASSERT_EQ(registry.size(), other.size()); + ASSERT_EQ((registry.view().size_hint()), (other.view().size_hint())); + ASSERT_NE((other.view().size_hint()), 0u); + + for(const auto entity: registry.view()) { + ASSERT_EQ((registry.get(entity)), (other.get(entity))); + } } TEST(PolyStorage, Constness) {