diff options
author | Zack Mulgrew <zack@zackthehuman.com> | 2016-02-03 22:28:00 -0800 |
---|---|---|
committer | Zack Mulgrew <zack@zackthehuman.com> | 2016-02-03 22:28:00 -0800 |
commit | 11bacfc5c65c543a47a8634262a0a2664742031f (patch) | |
tree | 420997384a7b6fc7798785b7c3bad1629da2794f | |
parent | 249d97a975d0ef97be66e3ce201f169e3a27101c (diff) |
Add test 'TestComponentRemovedEventOnEntityDestroyed'
-rw-r--r-- | entityx/Entity_test.cc | 21 |
1 files changed, 21 insertions, 0 deletions
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<Direction>())); } +TEST_CASE_METHOD(EntityManagerFixture, "TestComponentRemovedEventOnEntityDestroyed") { + struct ComponentRemovedReceiver : public Receiver<ComponentRemovedReceiver> { + void receive(const ComponentRemovedEvent<Direction> &event) { + removed = true; + } + + bool removed = false; + }; + + ComponentRemovedReceiver receiver; + ev.subscribe<ComponentRemovedEvent<Direction>>(receiver); + + REQUIRE(!(receiver.removed)); + + Entity e = em.create(); + e.assign<Direction>(1.0, 2.0); + e.destroy(); + + REQUIRE(receiver.removed); +} + TEST_CASE_METHOD(EntityManagerFixture, "TestEntityAssignment") { Entity a, b; a = em.create(); |