From: Alec Thomas Date: Thu, 19 Mar 2015 03:15:09 +0000 (+1100) Subject: Test for multiple event subscriptions. X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=019b1e1727179b2953f2541c1d802b126a97a91a;p=clyne%2Fentityx.git Test for multiple event subscriptions. --- diff --git a/entityx/Event_test.cc b/entityx/Event_test.cc index 0cf70e0..c643ee9 100644 --- a/entityx/Event_test.cc +++ b/entityx/Event_test.cc @@ -26,11 +26,21 @@ struct Explosion { int damage; }; + +struct Collision { + explicit Collision(int damage) : damage(damage) {} + int damage; +}; + struct ExplosionSystem : public Receiver { void receive(const Explosion &explosion) { damage_received += explosion.damage; } + void receive(const Collision &collision) { + damage_received += collision.damage; + } + int damage_received = 0; }; @@ -38,9 +48,12 @@ TEST_CASE("TestEmitReceive") { EventManager em; ExplosionSystem explosion_system; em.subscribe(explosion_system); + em.subscribe(explosion_system); REQUIRE(0 == explosion_system.damage_received); em.emit(10); REQUIRE(10 == explosion_system.damage_received); + em.emit(10); + REQUIRE(20 == explosion_system.damage_received); } TEST_CASE("TestUntypedEmitReceive") {