test_timestamp_moving_average.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The urg_stamped Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <gtest/gtest.h>
18 
20 
22 {
24  for (double t = 10.0; t < 11.0; t += 0.1)
25  {
26  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
27  }
28  ma.reset();
29  for (double t = 12.0; t < 13.0; t += 0.1)
30  {
31  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
32  }
33 }
34 
36 {
38  ASSERT_EQ(ma.update(ros::Time(10.000)), ros::Time(10.000));
39  ASSERT_EQ(ma.update(ros::Time(10.100)), ros::Time(10.100));
40  ASSERT_EQ(ma.update(ros::Time(10.203)), ros::Time(10.201));
41  ASSERT_EQ(ma.update(ros::Time(10.300)), ros::Time(10.301));
42  ASSERT_EQ(ma.update(ros::Time(10.400)), ros::Time(10.401));
43  ASSERT_EQ(ma.update(ros::Time(10.500)), ros::Time(10.500));
44 }
45 
47 {
49  for (double t = 10.0; t < 11.0; t += 0.1)
50  {
51  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
52  }
53  // skip 0.5 sec.
54  for (double t = 11.5; t < 12.0; t += 0.1)
55  {
56  ASSERT_EQ(ma.update(ros::Time(t)), ros::Time(t));
57  }
58 }
59 
60 int main(int argc, char **argv)
61 {
62  testing::InitGoogleTest(&argc, argv);
63 
64  return RUN_ALL_TESTS();
65 }
TEST(TimestampMovingAverage, ResetAndGo)
ros::Time update(const ros::Time &stamp)
int main(int argc, char **argv)


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Thu Jun 6 2019 19:55:59