test_helpers.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 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/cloud/internal/testing/test_helpers.h"
00018 
00019 namespace cartographer {
00020 namespace cloud {
00021 namespace testing {
00022 
00023 template <>
00024 DataPredicateType BuildDataPredicateEquals<proto::AddImuDataRequest>(
00025     const proto::AddImuDataRequest &proto) {
00026   return [proto](const sensor::Data &data) {
00027     const auto *dispatchable =
00028         dynamic_cast<const sensor::Dispatchable<sensor::ImuData> *>(&data);
00029     CHECK_NOTNULL(dispatchable);
00030     return google::protobuf::util::MessageDifferencer::Equals(
00031                sensor::ToProto(dispatchable->data()), proto.imu_data()) &&
00032            dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
00033   };
00034 }
00035 
00036 template <>
00037 DataPredicateType BuildDataPredicateEquals<proto::AddFixedFramePoseDataRequest>(
00038     const proto::AddFixedFramePoseDataRequest &proto) {
00039   return [proto](const sensor::Data &data) {
00040     const auto *dispatchable =
00041         dynamic_cast<const sensor::Dispatchable<sensor::FixedFramePoseData> *>(
00042             &data);
00043     CHECK_NOTNULL(dispatchable);
00044     return google::protobuf::util::MessageDifferencer::Equals(
00045                sensor::ToProto(dispatchable->data()),
00046                proto.fixed_frame_pose_data()) &&
00047            dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
00048   };
00049 }
00050 
00051 template <>
00052 DataPredicateType BuildDataPredicateEquals<proto::AddOdometryDataRequest>(
00053     const proto::AddOdometryDataRequest &proto) {
00054   return [proto](const sensor::Data &data) {
00055     const auto *dispatchable =
00056         dynamic_cast<const sensor::Dispatchable<sensor::OdometryData> *>(&data);
00057     CHECK_NOTNULL(dispatchable);
00058     return google::protobuf::util::MessageDifferencer::Equals(
00059                sensor::ToProto(dispatchable->data()), proto.odometry_data()) &&
00060            dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
00061   };
00062 }
00063 
00064 template <>
00065 DataPredicateType BuildDataPredicateEquals<proto::AddLandmarkDataRequest>(
00066     const proto::AddLandmarkDataRequest &proto) {
00067   return [proto](const sensor::Data &data) {
00068     const auto *dispatchable =
00069         dynamic_cast<const sensor::Dispatchable<sensor::LandmarkData> *>(&data);
00070     CHECK_NOTNULL(dispatchable);
00071     return google::protobuf::util::MessageDifferencer::Equals(
00072                sensor::ToProto(dispatchable->data()), proto.landmark_data()) &&
00073            dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
00074   };
00075 }
00076 
00077 template <>
00078 DataPredicateType BuildDataPredicateEquals<proto::AddRangefinderDataRequest>(
00079     const proto::AddRangefinderDataRequest &proto) {
00080   return [proto](const sensor::Data &data) {
00081     const auto *dispatchable =
00082         dynamic_cast<const sensor::Dispatchable<sensor::TimedPointCloudData> *>(
00083             &data);
00084     CHECK_NOTNULL(dispatchable);
00085     return google::protobuf::util::MessageDifferencer::Equals(
00086                sensor::ToProto(dispatchable->data()),
00087                proto.timed_point_cloud_data()) &&
00088            dispatchable->GetSensorId() == proto.sensor_metadata().sensor_id();
00089   };
00090 }
00091 
00092 ProtoPredicateType BuildProtoPredicateEquals(
00093     const google::protobuf::Message *proto) {
00094   return [proto](const google::protobuf::Message &message) {
00095     return google::protobuf::util::MessageDifferencer::Equals(*proto, message);
00096   };
00097 }
00098 
00099 }  // namespace testing
00100 }  // namespace cloud
00101 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:36