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::Entity player = world.entity();
|
||||
|
||||
// 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>();
|
||||
REQUIRE(ready == true);
|
||||
// just count down and should get the same number
|
||||
while(world.has_event<GUIEvent>()) {
|
||||
i--;
|
||||
}
|
||||
|
||||
REQUIRE(i == 0);
|
||||
|
||||
auto [event, entity, data] = world.recv<GUIEvent>();
|
||||
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);
|
||||
REQUIRE(string{"hello"} == str_data);
|
||||
|
||||
ready = world.has_event<GUIEvent>();
|
||||
bool ready = world.has_event<GUIEvent>();
|
||||
REQUIRE(ready == false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue