From 20fa95bd93611e1af2842a7a05efc7f38f2311e4 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 17 Aug 2025 10:18:06 -0400 Subject: [PATCH] Simple test to make sure world events actually loop. Closes #84. --- tests/dinkyecs.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/dinkyecs.cpp b/tests/dinkyecs.cpp index 59d4978..4393956 100644 --- a/tests/dinkyecs.cpp +++ b/tests/dinkyecs.cpp @@ -149,10 +149,18 @@ TEST_CASE("confirm that the event system works", "[ecs]") { DinkyECS::World world; DinkyECS::Entity player = world.entity(); - world.send(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::HIT, player, string{"hello"}); + } - bool ready = world.has_event(); - REQUIRE(ready == true); + // just count down and should get the same number + while(world.has_event()) { + i--; + } + + REQUIRE(i == 0); auto [event, entity, data] = world.recv(); REQUIRE(event == GUIEvent::HIT); @@ -160,7 +168,7 @@ TEST_CASE("confirm that the event system works", "[ecs]") { auto &str_data = std::any_cast(data); REQUIRE(string{"hello"} == str_data); - ready = world.has_event(); + bool ready = world.has_event(); REQUIRE(ready == false); }