aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Thomas <alec@swapoff.org>2015-09-15 11:19:36 +1000
committerAlec Thomas <alec@swapoff.org>2015-09-15 11:19:53 +1000
commit6729c8341f15d046b87c0ac7f4f15e1c49c11440 (patch)
treebcc5cf201c067fba94b3e34c46c1e4717caf0e20
parentb14b35e14370d71f86f41e5f59d1bdb6f558c193 (diff)
Test that receivers are only called once for each emit.
See #109.
-rw-r--r--entityx/Event_test.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/entityx/Event_test.cc b/entityx/Event_test.cc
index c643ee9..c315051 100644
--- a/entityx/Event_test.cc
+++ b/entityx/Event_test.cc
@@ -35,12 +35,15 @@ struct Collision {
struct ExplosionSystem : public Receiver<ExplosionSystem> {
void receive(const Explosion &explosion) {
damage_received += explosion.damage;
+ received_count++;
}
void receive(const Collision &collision) {
damage_received += collision.damage;
+ received_count++;
}
+ int received_count = 0;
int damage_received = 0;
};
@@ -51,9 +54,11 @@ TEST_CASE("TestEmitReceive") {
em.subscribe<Collision>(explosion_system);
REQUIRE(0 == explosion_system.damage_received);
em.emit<Explosion>(10);
+ REQUIRE(1 == explosion_system.received_count);
REQUIRE(10 == explosion_system.damage_received);
em.emit<Collision>(10);
REQUIRE(20 == explosion_system.damage_received);
+ REQUIRE(2 == explosion_system.received_count);
}
TEST_CASE("TestUntypedEmitReceive") {
@@ -63,6 +68,7 @@ TEST_CASE("TestUntypedEmitReceive") {
REQUIRE(0 == explosion_system.damage_received);
Explosion explosion(10);
em.emit(explosion);
+ REQUIRE(1 == explosion_system.received_count);
REQUIRE(10 == explosion_system.damage_received);
}