|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|