From 9b77623be1c932d8e2eda93a22be56da3949377c Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 11 Jul 2021 22:19:44 +0200 Subject: [PATCH] PulseGen: ensure Abort calculates the current remainder correctly Instead of stepping halfway, step ~1/3 of the way through. This ensures we can check if the steps performed is correct due to the internal step subtraction. --- tests/unit/modules/pulse_gen/test_pulse_gen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/modules/pulse_gen/test_pulse_gen.cpp b/tests/unit/modules/pulse_gen/test_pulse_gen.cpp index 208a1a6..3a2b105 100644 --- a/tests/unit/modules/pulse_gen/test_pulse_gen.cpp +++ b/tests/unit/modules/pulse_gen/test_pulse_gen.cpp @@ -202,9 +202,9 @@ TEST_CASE("pulse_gen::queue_abort", "[pulse_gen]") { // queue should start empty REQUIRE(pg.QueueEmpty()); - // enqueue a move and step halfway through + // enqueue a move and step ~1/3 through REQUIRE(pg.PlanMoveTo(10, 1)); - REQUIRE(stepUntilDone(pg, mp, 5) == -1); + REQUIRE(stepUntilDone(pg, mp, 3) == -1); // abort the queue pg.AbortPlannedMoves(); @@ -214,7 +214,9 @@ TEST_CASE("pulse_gen::queue_abort", "[pulse_gen]") { bool st = ReadPin(IDLER_STEP_PIN) == Level::high; REQUIRE(pg.Step(mp) == 0); REQUIRE(st == (ReadPin(IDLER_STEP_PIN) == Level::high)); - REQUIRE(pg.Position() == 5); + + // check that the aborted position matches + REQUIRE(pg.Position() == 3); } TEST_CASE("pulse_gen::accel_ramp", "[pulse_gen]") {