Explorar o código

test: stress get/get_as_tuple for empty types

Michele Caini %!s(int64=3) %!d(string=hai) anos
pai
achega
f48de1bac9
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      test/entt/entity/storage.cpp

+ 11 - 0
test/entt/entity/storage.cpp

@@ -282,6 +282,17 @@ TEST(Storage, EmptyType) {
 
 
     ASSERT_TRUE(pool.contains(entt::entity{99}));
     ASSERT_TRUE(pool.contains(entt::entity{99}));
     ASSERT_FALSE(other.contains(entt::entity{99}));
     ASSERT_FALSE(other.contains(entt::entity{99}));
+
+    ASSERT_NO_THROW(pool.get(entt::entity{99}));
+    ASSERT_EQ(pool.get_as_tuple(entt::entity{99}), std::tuple<>{});
+}
+
+ENTT_DEBUG_TEST(StorageDeathTest, EmptyType) {
+    entt::storage<empty_stable_type> pool;
+    pool.emplace(entt::entity{99});
+
+    ASSERT_DEATH(pool.get(entt::entity{3}), "");
+    ASSERT_DEATH([[maybe_unused]] auto tup = pool.get_as_tuple(entt::entity{3}), "");
 }
 }
 
 
 TEST(Storage, Insert) {
 TEST(Storage, Insert) {