Simple test to make sure world events actually loop. Closes #84.
This commit is contained in:
parent
a86912705c
commit
20fa95bd93
1 changed files with 12 additions and 4 deletions
|
@ -149,10 +149,18 @@ TEST_CASE("confirm that the event system works", "[ecs]") {
|
||||||
DinkyECS::World world;
|
DinkyECS::World world;
|
||||||
DinkyECS::Entity player = world.entity();
|
DinkyECS::Entity player = world.entity();
|
||||||
|
|
||||||
world.send<GUIEvent>(GUIEvent::HIT, player, string{"hello"});
|
// this confirms we can send these in a for-loop and get them out
|
||||||
|
int i = 0;
|
||||||
|
for(; i < 10; i++) {
|
||||||
|
world.send<GUIEvent>(GUIEvent::HIT, player, string{"hello"});
|
||||||
|
}
|
||||||
|
|
||||||
bool ready = world.has_event<GUIEvent>();
|
// just count down and should get the same number
|
||||||
REQUIRE(ready == true);
|
while(world.has_event<GUIEvent>()) {
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
REQUIRE(i == 0);
|
||||||
|
|
||||||
auto [event, entity, data] = world.recv<GUIEvent>();
|
auto [event, entity, data] = world.recv<GUIEvent>();
|
||||||
REQUIRE(event == GUIEvent::HIT);
|
REQUIRE(event == GUIEvent::HIT);
|
||||||
|
@ -160,7 +168,7 @@ TEST_CASE("confirm that the event system works", "[ecs]") {
|
||||||
auto &str_data = std::any_cast<string&>(data);
|
auto &str_data = std::any_cast<string&>(data);
|
||||||
REQUIRE(string{"hello"} == str_data);
|
REQUIRE(string{"hello"} == str_data);
|
||||||
|
|
||||||
ready = world.has_event<GUIEvent>();
|
bool ready = world.has_event<GUIEvent>();
|
||||||
REQUIRE(ready == false);
|
REQUIRE(ready == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue