From dcf49f08d8fad4d791b9aaa875d62435adc6c60b Mon Sep 17 00:00:00 2001 From: Trent Houliston Date: Tue, 30 Apr 2024 13:59:36 +1000 Subject: [PATCH] fix delay test --- tests/dsl/emit/Delay.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/dsl/emit/Delay.cpp b/tests/dsl/emit/Delay.cpp index 84f6b46b4..27e84c728 100644 --- a/tests/dsl/emit/Delay.cpp +++ b/tests/dsl/emit/Delay.cpp @@ -81,22 +81,20 @@ class TestReactor : public test_util::TestBase { on().then([this] { - // Get our jump size in milliseconds - const int jump_unit = (TimeUnit::period::num * 1000) / TimeUnit::period::den; // Delay with consistent jumps for (int i = 0; i < test_loops; ++i) { - auto delay = std::chrono::milliseconds(jump_unit * i); + auto delay = TimeUnit(i * 2); emit(std::make_unique(delay), delay); } // Target time with consistent jumps that interleave the first set for (int i = 0; i < test_loops; ++i) { - auto target = NUClear::clock::now() + std::chrono::milliseconds(jump_unit / 2 + jump_unit * i); + auto target = NUClear::clock::now() + TimeUnit(1 + (2 * i)); emit(std::make_unique(target), target); } // Emit a shutdown one time unit after - emit(std::make_unique(), std::chrono::milliseconds(jump_unit * (test_loops + 1))); + emit(std::make_unique(), TimeUnit((test_loops + 1) * 2)); }); } }; @@ -111,15 +109,15 @@ TEST_CASE("Testing the delay emit", "[api][emit][delay]") { const std::vector expected = { "delayed 0 received 0", - "at_time 0 received 0", - "delayed 1 received 1", "at_time 1 received 1", "delayed 2 received 2", - "at_time 2 received 2", - "delayed 3 received 3", "at_time 3 received 3", "delayed 4 received 4", - "at_time 4 received 4", + "at_time 5 received 5", + "delayed 6 received 6", + "at_time 7 received 7", + "delayed 8 received 8", + "at_time 9 received 9", "Finished", };