motion: Test for underflow as well
parent
3fbdf8bb2b
commit
f1d938b57f
|
|
@ -287,7 +287,7 @@ TEST_CASE("motion::pos_overflow", "[motion]") {
|
||||||
mm::motion.SetPosition(mm::Pulley, pos_max);
|
mm::motion.SetPosition(mm::Pulley, pos_max);
|
||||||
REQUIRE(mm::motion.Position(mm::Pulley) == pos_max);
|
REQUIRE(mm::motion.Position(mm::Pulley) == pos_max);
|
||||||
|
|
||||||
// plan a move which will overflow
|
// plan a move that will overflow
|
||||||
mm::pos_t steps = 10;
|
mm::pos_t steps = 10;
|
||||||
mm::motion.PlanMove(mm::Pulley, steps, 1);
|
mm::motion.PlanMove(mm::Pulley, steps, 1);
|
||||||
|
|
||||||
|
|
@ -297,8 +297,23 @@ TEST_CASE("motion::pos_overflow", "[motion]") {
|
||||||
// step once to setup current_block
|
// step once to setup current_block
|
||||||
mm::motion.Step();
|
mm::motion.Step();
|
||||||
|
|
||||||
// ensure the move direction and step count is correct despite the overflow
|
// ensure the move direction and step count is correct despite the overflow - abuse
|
||||||
// abuse CurBlockShift to get both, accounting for the useless single step
|
// CurBlockShift to get both, accounting for the useless single step we performed just above
|
||||||
// we performed just above.
|
|
||||||
REQUIRE(mm::motion.CtrlForAxis(mm::Pulley).CurBlockShift() == steps - 1);
|
REQUIRE(mm::motion.CtrlForAxis(mm::Pulley).CurBlockShift() == steps - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("motion::pos_underflow", "[motion]") {
|
||||||
|
ResetMotionSim();
|
||||||
|
|
||||||
|
mm::pos_t pos_min = std::numeric_limits<mm::pos_t>::min();
|
||||||
|
mm::motion.SetPosition(mm::Pulley, pos_min);
|
||||||
|
REQUIRE(mm::motion.Position(mm::Pulley) == pos_min);
|
||||||
|
|
||||||
|
mm::pos_t steps = 10;
|
||||||
|
mm::motion.PlanMove(mm::Pulley, -steps, 1);
|
||||||
|
REQUIRE(mm::motion.Position(mm::Pulley) > pos_min);
|
||||||
|
|
||||||
|
mm::motion.Step();
|
||||||
|
|
||||||
|
REQUIRE(mm::motion.CtrlForAxis(mm::Pulley).CurBlockShift() == -(steps - 1));
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue