From: Zack Mulgrew Date: Thu, 4 Feb 2016 06:28:00 +0000 (-0800) Subject: Add test 'TestComponentRemovedEventOnEntityDestroyed' X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=11bacfc5c65c543a47a8634262a0a2664742031f;p=clyne%2Fentityx.git Add test 'TestComponentRemovedEventOnEntityDestroyed' --- diff --git a/entityx/Entity_test.cc b/entityx/Entity_test.cc index 2076ed7..e07a567 100644 --- a/entityx/Entity_test.cc +++ b/entityx/Entity_test.cc @@ -405,6 +405,27 @@ TEST_CASE_METHOD(EntityManagerFixture, "TestComponentRemovedEvent") { REQUIRE(!(e.component())); } +TEST_CASE_METHOD(EntityManagerFixture, "TestComponentRemovedEventOnEntityDestroyed") { + struct ComponentRemovedReceiver : public Receiver { + void receive(const ComponentRemovedEvent &event) { + removed = true; + } + + bool removed = false; + }; + + ComponentRemovedReceiver receiver; + ev.subscribe>(receiver); + + REQUIRE(!(receiver.removed)); + + Entity e = em.create(); + e.assign(1.0, 2.0); + e.destroy(); + + REQUIRE(receiver.removed); +} + TEST_CASE_METHOD(EntityManagerFixture, "TestEntityAssignment") { Entity a, b; a = em.create();