|
|
@@ -1210,82 +1210,6 @@ TEST(Registry, CreateManyEntitiesWithComponentsAtOnceWithListener) {
|
|
|
ASSERT_EQ(listener.counter, 6);
|
|
|
}
|
|
|
|
|
|
-TEST(Registry, CreateFromPrototype) {
|
|
|
- entt::registry registry;
|
|
|
-
|
|
|
- const auto prototype = registry.create();
|
|
|
- registry.assign<int>(prototype, 3);
|
|
|
- registry.assign<char>(prototype, 'c');
|
|
|
-
|
|
|
- const auto full = registry.create(prototype, registry);
|
|
|
-
|
|
|
- ASSERT_TRUE((registry.has<int, char>(full)));
|
|
|
- ASSERT_EQ(registry.get<int>(full), 3);
|
|
|
- ASSERT_EQ(registry.get<char>(full), 'c');
|
|
|
-
|
|
|
- const auto partial = registry.create<int>(prototype, registry);
|
|
|
-
|
|
|
- ASSERT_TRUE(registry.has<int>(partial));
|
|
|
- ASSERT_FALSE(registry.has<char>(partial));
|
|
|
- ASSERT_EQ(registry.get<int>(partial), 3);
|
|
|
-
|
|
|
- const auto exclude = registry.create(prototype, registry, entt::exclude<int>);
|
|
|
-
|
|
|
- ASSERT_FALSE(registry.has<int>(exclude));
|
|
|
- ASSERT_TRUE(registry.has<char>(exclude));
|
|
|
- ASSERT_EQ(registry.get<char>(exclude), 'c');
|
|
|
-}
|
|
|
-
|
|
|
-TEST(Registry, CreateManyFromPrototype) {
|
|
|
- entt::registry registry;
|
|
|
- entt::entity entities[2];
|
|
|
-
|
|
|
- const auto prototype = registry.create();
|
|
|
- registry.assign<int>(prototype, 3);
|
|
|
- registry.assign<char>(prototype, 'c');
|
|
|
-
|
|
|
- registry.create(std::begin(entities), std::end(entities), prototype, registry);
|
|
|
-
|
|
|
- ASSERT_TRUE((registry.has<int, char>(entities[0])));
|
|
|
- ASSERT_TRUE((registry.has<int, char>(entities[1])));
|
|
|
- ASSERT_EQ(registry.get<int>(entities[0]), 3);
|
|
|
- ASSERT_EQ(registry.get<char>(entities[1]), 'c');
|
|
|
-
|
|
|
- registry.create<int>(std::begin(entities), std::end(entities), prototype, registry);
|
|
|
-
|
|
|
- ASSERT_TRUE(registry.has<int>(entities[0]));
|
|
|
- ASSERT_FALSE(registry.has<char>(entities[1]));
|
|
|
- ASSERT_EQ(registry.get<int>(entities[0]), 3);
|
|
|
-
|
|
|
- registry.create(std::begin(entities), std::end(entities), prototype, registry, entt::exclude<int>);
|
|
|
-
|
|
|
- ASSERT_FALSE(registry.has<int>(entities[0]));
|
|
|
- ASSERT_TRUE(registry.has<char>(entities[1]));
|
|
|
- ASSERT_EQ(registry.get<char>(entities[0]), 'c');
|
|
|
-}
|
|
|
-
|
|
|
-TEST(Registry, CreateFromPrototypeWithListener) {
|
|
|
- entt::registry registry;
|
|
|
- entt::entity entities[3];
|
|
|
- listener listener;
|
|
|
-
|
|
|
- const auto prototype = registry.create();
|
|
|
- registry.assign<int>(prototype, 3);
|
|
|
- registry.assign<char>(prototype, 'c');
|
|
|
- registry.assign<empty_type>(prototype);
|
|
|
-
|
|
|
- registry.on_construct<int>().connect<&listener::incr<int>>(listener);
|
|
|
- registry.create<int, char>(std::begin(entities), std::end(entities), prototype, registry);
|
|
|
-
|
|
|
- ASSERT_EQ(listener.counter, 3);
|
|
|
-
|
|
|
- registry.on_construct<int>().disconnect<&listener::incr<int>>(listener);
|
|
|
- registry.on_construct<empty_type>().connect<&listener::incr<empty_type>>(listener);
|
|
|
- registry.create<char, empty_type>(std::begin(entities), std::end(entities), prototype, registry);
|
|
|
-
|
|
|
- ASSERT_EQ(listener.counter, 6);
|
|
|
-}
|
|
|
-
|
|
|
TEST(Registry, NonOwningGroupInterleaved) {
|
|
|
entt::registry registry;
|
|
|
typename entt::entity entity = entt::null;
|