Add test cases to TrapezoidProfile to verify it exactly reaches the goal.
Change-Id: I69531aae47ffdc3e70d8c88bfb99fe0172343d62
diff --git a/aos/common/util/trapezoid_profile_test.cc b/aos/common/util/trapezoid_profile_test.cc
index c6e811c..f9ae817 100644
--- a/aos/common/util/trapezoid_profile_test.cc
+++ b/aos/common/util/trapezoid_profile_test.cc
@@ -113,6 +113,16 @@
EXPECT_TRUE(At(4, 0));
}
+// Tests that the position and velocity exactly match at the end. Some code we
+// have assumes this to be true as a simplification.
+TEST_F(TrapezoidProfileTest, ExactlyReachesGoal) {
+ for (int i = 0; i < 450; ++i) {
+ RunIteration(1, 0);
+ }
+ EXPECT_EQ(position()(1), 0.0);
+ EXPECT_EQ(position()(0), 1.0);
+}
+
} // namespace testing
} // namespace util
} // namespace aos