test_timestamp_outlier_remover.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The urg_stamped Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include <gtest/gtest.h>
00018 
00019 #include <timestamp_outlier_remover.h>
00020 
00021 TEST(TimestampOutlierRemoval, RemoveOneOutlier)
00022 {
00023   TimestampOutlierRemover remover(ros::Duration(0.01), ros::Duration(0.1));
00024 
00025   ASSERT_EQ(remover.update(ros::Time(10.000)), ros::Time(10.000));
00026   ASSERT_EQ(remover.update(ros::Time(10.105)), ros::Time(10.105));
00027   ASSERT_EQ(remover.update(ros::Time(10.200)), ros::Time(10.200));
00028   ASSERT_EQ(remover.update(ros::Time(10.320)), ros::Time(10.300));  // outlier
00029   ASSERT_EQ(remover.update(ros::Time(10.400)), ros::Time(10.400));
00030   ASSERT_EQ(remover.update(ros::Time(10.500)), ros::Time(10.500));
00031 }
00032 
00033 TEST(TimestampOutlierRemoval, MoreThanTwoOutlier)
00034 {
00035   TimestampOutlierRemover remover(ros::Duration(0.01), ros::Duration(0.1));
00036 
00037   ASSERT_EQ(remover.update(ros::Time(10.000)), ros::Time(10.000));
00038   ASSERT_EQ(remover.update(ros::Time(10.105)), ros::Time(10.105));
00039   ASSERT_EQ(remover.update(ros::Time(10.200)), ros::Time(10.200));
00040   ASSERT_EQ(remover.update(ros::Time(10.320)), ros::Time(10.300));  // outlier
00041   ASSERT_EQ(remover.update(ros::Time(10.440)), ros::Time(10.440));  // fix only first outlier
00042 }
00043 
00044 int main(int argc, char **argv)
00045 {
00046   testing::InitGoogleTest(&argc, argv);
00047 
00048   return RUN_ALL_TESTS();
00049 }


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Thu Jun 6 2019 18:59:51