Browse Source

test: increase code coverage

Michele Caini 3 years ago
parent
commit
80d55a226c
1 changed files with 12 additions and 2 deletions
  1. 12 2
      test/entt/entity/handle.cpp

+ 12 - 2
test/entt/entity/handle.cpp

@@ -298,6 +298,9 @@ TEST(BasicHandle, HandleStorageIterator) {
     const auto entity = registry.create();
     const auto entity = registry.create();
 
 
     registry.emplace<int>(entity);
     registry.emplace<int>(entity);
+    registry.emplace<double>(entity);
+    // required to test the find-first initialization step
+    registry.storage<entt::entity>().erase(entity);
 
 
     auto test = [](auto iterable) {
     auto test = [](auto iterable) {
         auto end{iterable.begin()};
         auto end{iterable.begin()};
@@ -313,6 +316,13 @@ TEST(BasicHandle, HandleStorageIterator) {
         ASSERT_EQ(++begin, iterable.end());
         ASSERT_EQ(++begin, iterable.end());
     };
     };
 
 
-    test(entt::handle{registry, entity}.storage());
-    test(entt::const_handle{std::as_const(registry), entity}.storage());
+    const auto handle = entt::handle{registry, entity};
+    const auto chandle = entt::const_handle{std::as_const(registry), entity};
+
+    ASSERT_FALSE(registry.valid(entity));
+    ASSERT_FALSE(handle);
+    ASSERT_FALSE(chandle);
+
+    test(handle.storage());
+    test(chandle.storage());
 }
 }