mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 00:53:35 +08:00
Unit tests: use EXPECT_FLOAT_EQ for float comparisons
as precaution to prevent failing tests because of small potential rounding errors on certain platforms or compilares.
This commit is contained in:
committed by
Lorenz Meier
parent
ee62d0296f
commit
ffff35a597
@@ -58,9 +58,9 @@ TEST_F(ManualVelocitySmoothingXYTest, setGet)
|
||||
_smoothing.setMaxVel(5.f);
|
||||
|
||||
// THEN: We should be able to get them back
|
||||
EXPECT_EQ(_smoothing.getMaxJerk(), 11.f);
|
||||
EXPECT_EQ(_smoothing.getMaxAccel(), 7.f);
|
||||
EXPECT_EQ(_smoothing.getMaxVel(), 5.f);
|
||||
EXPECT_FLOAT_EQ(_smoothing.getMaxJerk(), 11.f);
|
||||
EXPECT_FLOAT_EQ(_smoothing.getMaxAccel(), 7.f);
|
||||
EXPECT_FLOAT_EQ(_smoothing.getMaxVel(), 5.f);
|
||||
}
|
||||
|
||||
TEST_F(ManualVelocitySmoothingXYTest, getCurrentState)
|
||||
|
||||
@@ -172,9 +172,9 @@ TEST_F(VelocitySmoothingTest, testZeroSetpoint)
|
||||
|
||||
// THEN: All the trajectories should still be zero
|
||||
for (int i = 0; i < 3; i++) {
|
||||
EXPECT_EQ(_trajectories[i].getCurrentJerk(), 0.f);
|
||||
EXPECT_EQ(_trajectories[i].getCurrentAcceleration(), 0.f);
|
||||
EXPECT_EQ(_trajectories[i].getCurrentVelocity(), 0.f);
|
||||
EXPECT_EQ(_trajectories[i].getCurrentPosition(), 0.f);
|
||||
EXPECT_FLOAT_EQ(_trajectories[i].getCurrentJerk(), 0.f);
|
||||
EXPECT_FLOAT_EQ(_trajectories[i].getCurrentAcceleration(), 0.f);
|
||||
EXPECT_FLOAT_EQ(_trajectories[i].getCurrentVelocity(), 0.f);
|
||||
EXPECT_FLOAT_EQ(_trajectories[i].getCurrentPosition(), 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user