34 #include <gtest/gtest.h> 41 TEST(VelocityIterator, basics)
48 EXPECT_FALSE(it.isFinished());
49 EXPECT_NEAR(it.getVelocity(), 3.0,
EPSILON);
50 EXPECT_FALSE(it.isFinished());
52 EXPECT_TRUE(it.isFinished());
54 EXPECT_FALSE(it.isFinished());
55 EXPECT_NEAR(it.getVelocity(), 1.0,
EPSILON);
58 TEST(VelocityIterator, limits)
63 EXPECT_NEAR(it.getVelocity(), 2.5,
EPSILON);
66 TEST(VelocityIterator, acceleration)
71 EXPECT_NEAR(it.getVelocity(), 2.5,
EPSILON);
75 TEST(VelocityIterator, time)
80 EXPECT_NEAR(it.getVelocity(), 2.5,
EPSILON);
83 TEST(VelocityIterator, samples)
88 EXPECT_NEAR(it.getVelocity(), 2.0,
EPSILON);
90 EXPECT_NEAR(it.getVelocity(), 3.0,
EPSILON);
92 EXPECT_TRUE(it.isFinished());
96 TEST(VelocityIterator, samples2)
101 EXPECT_NEAR(it.getVelocity(), 1.5,
EPSILON);
103 EXPECT_NEAR(it.getVelocity(), 2.0,
EPSILON);
105 EXPECT_NEAR(it.getVelocity(), 2.5,
EPSILON);
107 EXPECT_NEAR(it.getVelocity(), 3.0,
EPSILON);
109 EXPECT_TRUE(it.isFinished());
112 TEST(VelocityIterator, around_zero)
117 EXPECT_NEAR(it.getVelocity(), 0.0,
EPSILON);
119 EXPECT_NEAR(it.getVelocity(), 1.0,
EPSILON);
123 TEST(VelocityIterator, around_zero2)
128 EXPECT_NEAR(it.getVelocity(), -0.3333,
EPSILON);
130 EXPECT_NEAR(it.getVelocity(), 0.0,
EPSILON);
132 EXPECT_NEAR(it.getVelocity(), 0.3333,
EPSILON);
134 EXPECT_NEAR(it.getVelocity(), 1.0,
EPSILON);
138 int main(
int argc,
char **argv)
140 testing::InitGoogleTest(&argc, argv);
141 return RUN_ALL_TESTS();
int main(int argc, char **argv)
TEST(VelocityIterator, basics)
An iterator for generating a number of samples in a range.
double getVelocity() const
Get the next velocity available.
void reset()
Reset back to the first velocity.