time_conversion_test.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer 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 "cartographer_ros/time_conversion.h"
00018 
00019 #include <chrono>
00020 
00021 #include "cartographer/common/time.h"
00022 #include "gtest/gtest.h"
00023 #include "ros/ros.h"
00024 
00025 namespace cartographer_ros {
00026 namespace {
00027 
00028 TEST(TimeConversion, testToRos) {
00029   std::vector<int64_t> values = {0, 1469091375, 1466481821, 1462101382,
00030                                  1468238899};
00031   for (int64_t seconds_since_epoch : values) {
00032     ::ros::Time ros_now;
00033     ros_now.fromSec(seconds_since_epoch);
00034     ::cartographer::common::Time cartographer_now(
00035         ::cartographer::common::FromSeconds(
00036             seconds_since_epoch +
00037             ::cartographer::common::kUtsEpochOffsetFromUnixEpochInSeconds));
00038     EXPECT_EQ(cartographer_now, ::cartographer_ros::FromRos(ros_now));
00039     EXPECT_EQ(ros_now, ::cartographer_ros::ToRos(cartographer_now));
00040   }
00041 }
00042 
00043 }  // namespace
00044 }  // namespace cartographer_ros


cartographer_ros
Author(s): The Cartographer Authors
autogenerated on Wed Jul 10 2019 04:10:28