diff --git a/entityx/Entity_test.cc b/entityx/Entity_test.cc index 2b4ed6b..a928e9b 100644 --- a/entityx/Entity_test.cc +++ b/entityx/Entity_test.cc @@ -18,7 +18,7 @@ #include #include #include "entityx/3rdparty/catch.hpp" -#include "entityx/Entity.h" +#include "entityx/entityx.h" // using namespace std; using namespace entityx; @@ -519,3 +519,26 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestEntityInStdMap") { REQUIRE(entityMap[b] == 2); REQUIRE(entityMap[c] == 3); } + +TEST_CASE("TestComponentDestructorCalledWhenManagerDestroyed") { + struct Freed { + explicit Freed(bool &yes) : yes(yes) {} + ~Freed() { yes = true; } + + bool &yes; + }; + + struct Test : Component { + Test(bool &yes) : freed(yes) {} + + Freed freed; + }; + + bool freed = false; + { + EntityX e; + auto test = e.entities.create(); + test.assign(freed); + } + REQUIRE(freed == true); +}