#include <set>
#include <map>
#include "entityx/3rdparty/catch.hpp"
-#include "entityx/Entity.h"
+#include "entityx/entityx.h"
// using namespace std;
using namespace entityx;
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> {
+ Test(bool &yes) : freed(yes) {}
+
+ Freed freed;
+ };
+
+ bool freed = false;
+ {
+ EntityX e;
+ auto test = e.entities.create();
+ test.assign<Test>(freed);
+ }
+ REQUIRE(freed == true);
+}