code coverage

This commit is contained in:
Michele Caini
2019-11-09 16:13:11 +01:00
parent 786568fd2f
commit d6d79a2aa5
2 changed files with 11 additions and 7 deletions

View File

@@ -262,8 +262,12 @@ class basic_registry {
other.assure<Component>(static_cast<const pool_type<Component> &>(cpool));
};
pdata->set = [](basic_registry &other, const Entity entt, const void *instance) {
other.assign_or_replace<Component>(entt, *static_cast<const std::decay_t<Component> *>(instance));
pdata->set = [](basic_registry &other, const Entity entt, [[maybe_unused]] const void *instance) {
if constexpr(ENTT_ENABLE_ETO(Component)) {
other.assign_or_replace<Component>(entt);
} else {
other.assign_or_replace<Component>(entt, *static_cast<const std::decay_t<Component> *>(instance));
}
};
}
}

View File

@@ -1494,24 +1494,24 @@ TEST(Registry, StompExclude) {
const auto prototype = registry.create();
registry.assign<int>(prototype, 3);
registry.assign<char>(prototype, 'c');
registry.assign<empty_type>(prototype);
const auto entity = registry.create();
registry.stomp(entity, prototype, registry, entt::exclude<char>);
ASSERT_TRUE(registry.has<int>(entity));
ASSERT_TRUE((registry.has<int, empty_type>(entity)));
ASSERT_FALSE(registry.has<char>(entity));
ASSERT_EQ(registry.get<int>(entity), 3);
registry.replace<int>(prototype, 42);
registry.stomp(entity, prototype, registry, entt::exclude<int>);
ASSERT_TRUE((registry.has<int, char>(entity)));
ASSERT_TRUE((registry.has<int, char, empty_type>(entity)));
ASSERT_EQ(registry.get<int>(entity), 3);
ASSERT_EQ(registry.get<char>(entity), 'c');
registry.remove<int>(entity);
registry.remove<char>(entity);
registry.stomp(entity, prototype, registry, entt::exclude<int, char>);
registry.remove<int, char, empty_type>(entity);
registry.stomp(entity, prototype, registry, entt::exclude<int, char, empty_type>);
ASSERT_TRUE(registry.orphan(entity));
}