diff options
-rw-r--r-- | entityx/Entity_test.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/entityx/Entity_test.cc b/entityx/Entity_test.cc index a928e9b..cd7b2a1 100644 --- a/entityx/Entity_test.cc +++ b/entityx/Entity_test.cc @@ -542,3 +542,26 @@ TEST_CASE("TestComponentDestructorCalledWhenManagerDestroyed") { } REQUIRE(freed == true); } + +TEST_CASE("TestComponentDestructorCalledWhenEntityDestroyed") { + struct Freed { + explicit Freed(bool &yes) : yes(yes) {} + ~Freed() { yes = true; } + + bool &yes; + }; + + struct Test : Component<Test> { + Test(bool &yes) : freed(yes) {} + + Freed freed; + }; + + bool freed = false; + EntityX e; + auto test = e.entities.create(); + test.assign<Test>(freed); + REQUIRE(freed == false); + test.destroy(); + REQUIRE(freed == true); +} |