Addresses of removed components should be reused
This commit is contained in:
parent
84b132f853
commit
6737ffb2eb
1 changed files with 39 additions and 0 deletions
|
@ -129,3 +129,42 @@ TEST_CASE("Remove a component from an entity and verify it is no longer attached
|
|||
|
||||
REQUIRE_FALSE(w.has<ChoosenOne>(e));
|
||||
}
|
||||
|
||||
TEST_CASE("Addresses of removed components should be reused")
|
||||
{
|
||||
world w;
|
||||
std::vector<entity> entities;
|
||||
std::vector<ChoosenOne*> 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<ChoosenOne>();
|
||||
}
|
||||
|
||||
if(addr.empty())
|
||||
{
|
||||
for(int j = 0; j < N; ++j)
|
||||
{
|
||||
addr.emplace_back(&entities[j].get<ChoosenOne>());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int j = 0; j < N; ++j)
|
||||
{
|
||||
REQUIRE(&entities[j].get<ChoosenOne>() == addr[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for(auto e: entities)
|
||||
{
|
||||
e.remove<ChoosenOne>();
|
||||
}
|
||||
entities.clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue