map_limits_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/mapping/2d/map_limits.h"
00018 
00019 #include "gtest/gtest.h"
00020 
00021 namespace cartographer {
00022 namespace mapping {
00023 namespace {
00024 
00025 TEST(MapLimitsTest, ToProto) {
00026   const MapLimits limits(42., Eigen::Vector2d(3., 0.), CellLimits(2, 3));
00027   const auto proto = ToProto(limits);
00028   EXPECT_EQ(limits.resolution(), proto.resolution());
00029   EXPECT_EQ(limits.max().x(), proto.max().x());
00030   EXPECT_EQ(limits.max().y(), proto.max().y());
00031   EXPECT_EQ(ToProto(limits.cell_limits()).DebugString(),
00032             proto.cell_limits().DebugString());
00033 }
00034 
00035 TEST(MapLimitsTest, ProtoConstructor) {
00036   proto::MapLimits limits;
00037   limits.set_resolution(1.);
00038   limits.mutable_max()->set_x(2.);
00039   limits.mutable_max()->set_y(3.);
00040   limits.mutable_cell_limits()->set_num_x_cells(4);
00041   limits.mutable_cell_limits()->set_num_y_cells(5);
00042 
00043   const MapLimits native(limits);
00044   EXPECT_EQ(limits.resolution(), native.resolution());
00045   EXPECT_EQ(limits.max().x(), native.max().x());
00046   EXPECT_EQ(limits.max().y(), native.max().y());
00047   EXPECT_EQ(limits.cell_limits().DebugString(),
00048             ToProto(native.cell_limits()).DebugString());
00049 }
00050 
00051 TEST(MapLimitsTest, ConstructAndGet) {
00052   const MapLimits limits(42., Eigen::Vector2d(3., 0.), CellLimits(2, 3));
00053 
00054   const CellLimits& cell_limits = limits.cell_limits();
00055   EXPECT_EQ(2, cell_limits.num_x_cells);
00056   EXPECT_EQ(3, cell_limits.num_y_cells);
00057 
00058   const Eigen::Vector2d& max = limits.max();
00059   EXPECT_EQ(3., max.x());
00060   EXPECT_EQ(0., max.y());
00061 
00062   EXPECT_EQ(42., limits.resolution());
00063 }
00064 
00065 }  // namespace
00066 }  // namespace mapping
00067 }  // namespace cartographer


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