diff --git a/tests/zecsy.cpp b/tests/zecsy.cpp index 5aa7360..9f654cb 100644 --- a/tests/zecsy.cpp +++ b/tests/zecsy.cpp @@ -129,3 +129,42 @@ TEST_CASE("Remove a component from an entity and verify it is no longer attached REQUIRE_FALSE(w.has(e)); } + +TEST_CASE("Addresses of removed components should be reused") +{ + world w; + std::vector entities; + std::vector addr; + + const int N = 4; + + for(int i = 0; i < 2; ++i) + { + for(int j = 0; j < N; ++j) + { + entities.emplace_back(w.make_entity()); + entities.back().set(); + } + + if(addr.empty()) + { + for(int j = 0; j < N; ++j) + { + addr.emplace_back(&entities[j].get()); + } + } + else + { + for(int j = 0; j < N; ++j) + { + REQUIRE(&entities[j].get() == addr[j]); + } + } + + for(auto e: entities) + { + e.remove(); + } + entities.clear(); + } +}