From 7053755b0e14772c332604fcc360e39b95b2ac5c Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 22 Oct 2022 17:21:08 +0200 Subject: [PATCH 1/2] motion: Add tests for unscheduled moves in AbortPlannedMoves This catches the previously untested #228 --- tests/unit/modules/motion/test_motion.cpp | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/unit/modules/motion/test_motion.cpp b/tests/unit/modules/motion/test_motion.cpp index 7bbae19..25d1005 100644 --- a/tests/unit/modules/motion/test_motion.cpp +++ b/tests/unit/modules/motion/test_motion.cpp @@ -271,6 +271,37 @@ TEST_CASE("motion::queue_abort_1", "[motion]") { REQUIRE(!motion.QueueEmpty()); } +TEST_CASE("motion::queue_abort_2", "[motion]") { + // queue should start empty + ResetMotionSim(); + + // enqueue two moves on a single axis + motion.PlanMoveTo(Pulley, 10, 1); + motion.PlanMoveTo(Pulley, 20, 1); + REQUIRE(!motion.QueueEmpty(Pulley)); + + // abort before scheduling and check that both are gone + motion.AbortPlannedMoves(Pulley); + REQUIRE(motion.QueueEmpty(Pulley)); +} + +TEST_CASE("motion::queue_abort_3", "[motion]") { + // queue should start empty + ResetMotionSim(); + + // enqueue two moves on a single axis + motion.PlanMoveTo(Pulley, 10, 1); + motion.PlanMoveTo(Pulley, 20, 1); + REQUIRE(!motion.QueueEmpty(Pulley)); + + // step ~1/3 way through of the first move + REQUIRE(stepUntilDone(3) == -1); + + // abort the partial and unscheduled move + motion.AbortPlannedMoves(Pulley); + REQUIRE(motion.QueueEmpty(Pulley)); +} + TEST_CASE("motion::long_pulley_move", "[motion]") { ResetMotionSim(); constexpr auto mm400 = 400._mm; From 3567a3dcd5770ea50d05cda64559415c7cabb694 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 22 Oct 2022 17:39:09 +0200 Subject: [PATCH 2/2] motion: Also test for the simplest case of a single+unplanned move --- tests/unit/modules/motion/test_motion.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unit/modules/motion/test_motion.cpp b/tests/unit/modules/motion/test_motion.cpp index 25d1005..ee0e99b 100644 --- a/tests/unit/modules/motion/test_motion.cpp +++ b/tests/unit/modules/motion/test_motion.cpp @@ -302,6 +302,19 @@ TEST_CASE("motion::queue_abort_3", "[motion]") { REQUIRE(motion.QueueEmpty(Pulley)); } +TEST_CASE("motion::queue_abort_4", "[motion]") { + // queue should start empty + ResetMotionSim(); + + // enqueue a move on a single axis + motion.PlanMoveTo(Pulley, 10, 1); + REQUIRE(!motion.QueueEmpty(Pulley)); + + // abort the single unscheduled move + motion.AbortPlannedMoves(Pulley); + REQUIRE(motion.QueueEmpty(Pulley)); +} + TEST_CASE("motion::long_pulley_move", "[motion]") { ResetMotionSim(); constexpr auto mm400 = 400._mm;