Skip to content

Commit 3523e07

Browse files
committed
Add test in for post with delay
1 parent ab9a0a9 commit 3523e07

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/tests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,22 @@ TEST_CASE("post event ordering") {
220220
REQUIRE(ran2);
221221
REQUIRE(ran3);
222222
}
223+
}
224+
225+
TEST_CASE("post event with delay to simulation") {
226+
simcpp20::simulation<> sim;
227+
228+
bool ran1 = false;
229+
bool ran2 = false;
230+
231+
auto ev1 = sim.post([&ran1]() { ran1 = true; }, 2.0);
232+
auto ev2 = sim.post([&ran2]() { ran2 = true; }, 1.0);
233+
234+
sim.step();
235+
REQUIRE_FALSE(ran1);
236+
REQUIRE(ran2);
237+
238+
sim.step();
239+
REQUIRE(ran1);
240+
REQUIRE(ran2);
223241
}

0 commit comments

Comments
 (0)