Browse Source

test: registry emplace_or_replace empty - close #1228

Michele Caini 1 year ago
parent
commit
fc01149121
1 changed files with 15 additions and 0 deletions
  1. 15 0
      test/entt/entity/registry.cpp

+ 15 - 0
test/entt/entity/registry.cpp

@@ -1100,6 +1100,21 @@ TEST(Registry, EmplaceOrReplace) {
     ASSERT_EQ(ref, 0);
 }
 
+TEST(Registry, EmplaceOrReplaceEmpty) {
+    entt::registry registry{};
+    const auto entity = registry.create();
+
+    ASSERT_FALSE(registry.all_of<test::empty>(entity));
+
+    registry.emplace_or_replace<test::empty>(entity);
+
+    ASSERT_TRUE(registry.all_of<test::empty>(entity));
+
+    registry.emplace_or_replace<test::empty>(entity);
+
+    ASSERT_EQ(registry.storage<test::empty>().size(), 1u);
+}
+
 TEST(Registry, EmplaceOrReplaceAggregate) {
     entt::registry registry{};
     const auto entity = registry.create();