This is a trivial test for the Discrete Trajectory class, which checks for basic functionality of its features.
#include <iostream>
#include <cstdlib>
#include <gtest/gtest.h>
TEST(TrajectoryTest, TrajectoryTest)
{
size_t nPoints = 10;
start.setZero();
end << 9, 9;
for (
size_t i = 0;
i < timeArray.size();
i++)
{
ASSERT_EQ(stateArray[
i], stateTrajectory_lin.
eval(i));
}
for (
double i = 0;
i <= nPoints - 1;
i =
i + 0.2)
{
ASSERT_EQ(stateTrajectory_lin.
eval(
i), stateTrajectory_copied.eval(
i));
}
stateTrajectory_swapped.swapData(stateTrajectory_copied);
for (
double i = 0;
i <= nPoints - 1;
i =
i + 0.2)
{
ASSERT_EQ(stateTrajectory_lin.
eval(
i), stateTrajectory_swapped.eval(
i));
}
ASSERT_EQ(start, stateTrajectory_lin.
front());
ASSERT_EQ(end, stateTrajectory_lin.
back());
ASSERT_EQ(end, stateTrajectory_lin[nPoints - 1]);
stateTrajectory_shifted.shiftTime(
8.0);
ASSERT_EQ(stateArray[8], stateTrajectory_shifted.eval(0.0));
ASSERT_EQ(0.5 * (stateArray[8] + stateArray[9]), stateTrajectory_shifted.eval(0.5));
for (
double i = 0;
i <= nPoints - 1;
i =
i + 0.2)
{
ASSERT_EQ(stateTrajectory_lin.
eval(
i), stateTrajectory_assigned.eval(
i));
}
}
int main(
int argc,
char** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}