aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Thomas <alec@swapoff.org>2015-03-19 14:15:09 +1100
committerAlec Thomas <alec@swapoff.org>2015-03-19 15:38:09 +1100
commit019b1e1727179b2953f2541c1d802b126a97a91a (patch)
treefc178e569e1e21eb125f6524e54e91b30efc6139
parent348fd031a2088b24935359ea2fec0c1e9382776e (diff)
Test for multiple event subscriptions.
-rw-r--r--entityx/Event_test.cc13
1 files changed, 13 insertions, 0 deletions
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<ExplosionSystem> {
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>(explosion_system);
+ em.subscribe<Collision>(explosion_system);
REQUIRE(0 == explosion_system.damage_received);
em.emit<Explosion>(10);
REQUIRE(10 == explosion_system.damage_received);
+ em.emit<Collision>(10);
+ REQUIRE(20 == explosion_system.damage_received);
}
TEST_CASE("TestUntypedEmitReceive") {