Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <gtest/gtest.h>
00018
00019 #include <timestamp_moving_average.h>
00020
00021 TEST(TimestampMovingAverage, ResetAndGo)
00022 {
00023 TimestampMovingAverage ma(3, ros::Duration(0.1));
00024 for (double t = 10.0; t < 11.0; t += 0.1)
00025 {
00026 ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
00027 }
00028 ma.reset();
00029 for (double t = 12.0; t < 13.0; t += 0.1)
00030 {
00031 ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
00032 }
00033 }
00034
00035 TEST(TimestampMovingAverage, MovingAverage)
00036 {
00037 TimestampMovingAverage ma(3, ros::Duration(0.1));
00038 ASSERT_EQ(ma.update(ros::Time(10.000)), ros::Time(10.000));
00039 ASSERT_EQ(ma.update(ros::Time(10.100)), ros::Time(10.100));
00040 ASSERT_EQ(ma.update(ros::Time(10.203)), ros::Time(10.201));
00041 ASSERT_EQ(ma.update(ros::Time(10.300)), ros::Time(10.301));
00042 ASSERT_EQ(ma.update(ros::Time(10.400)), ros::Time(10.401));
00043 ASSERT_EQ(ma.update(ros::Time(10.500)), ros::Time(10.500));
00044 }
00045
00046 TEST(TimestampMovingAverage, SkippedInput)
00047 {
00048 TimestampMovingAverage ma(3, ros::Duration(0.1));
00049 for (double t = 10.0; t < 11.0; t += 0.1)
00050 {
00051 ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
00052 }
00053
00054 for (double t = 11.5; t < 12.0; t += 0.1)
00055 {
00056 ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
00057 }
00058 }
00059
00060 int main(int argc, char **argv)
00061 {
00062 testing::InitGoogleTest(&argc, argv);
00063
00064 return RUN_ALL_TESTS();
00065 }