map_limits_test.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer 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 
18 
19 #include "gtest/gtest.h"
20 
21 namespace cartographer {
22 namespace mapping_2d {
23 namespace {
24 
25 TEST(MapLimitsTest, ToProto) {
26  const MapLimits limits(42., Eigen::Vector2d(3., 0.), CellLimits(2, 3));
27  const auto proto = ToProto(limits);
28  EXPECT_EQ(limits.resolution(), proto.resolution());
29  EXPECT_EQ(limits.max().x(), proto.max().x());
30  EXPECT_EQ(limits.max().y(), proto.max().y());
31  EXPECT_EQ(ToProto(limits.cell_limits()).DebugString(),
32  proto.cell_limits().DebugString());
33 }
34 
35 TEST(MapLimitsTest, ProtoConstructor) {
36  proto::MapLimits limits;
37  limits.set_resolution(1.);
38  limits.mutable_max()->set_x(2.);
39  limits.mutable_max()->set_y(3.);
40  limits.mutable_cell_limits()->set_num_x_cells(4);
41  limits.mutable_cell_limits()->set_num_y_cells(5);
42 
43  const MapLimits native(limits);
44  EXPECT_EQ(limits.resolution(), native.resolution());
45  EXPECT_EQ(limits.max().x(), native.max().x());
46  EXPECT_EQ(limits.max().y(), native.max().y());
47  EXPECT_EQ(limits.cell_limits().DebugString(),
48  ToProto(native.cell_limits()).DebugString());
49 }
50 
51 TEST(MapLimitsTest, ConstructAndGet) {
52  const MapLimits limits(42., Eigen::Vector2d(3., 0.), CellLimits(2, 3));
53 
54  const CellLimits& cell_limits = limits.cell_limits();
55  EXPECT_EQ(2, cell_limits.num_x_cells);
56  EXPECT_EQ(3, cell_limits.num_y_cells);
57 
58  const Eigen::Vector2d& max = limits.max();
59  EXPECT_EQ(3., max.x());
60  EXPECT_EQ(0., max.y());
61 
62  EXPECT_EQ(42., limits.resolution());
63 }
64 
65 } // namespace
66 } // namespace mapping_2d
67 } // namespace cartographer
proto::MapLimits ToProto(const MapLimits &map_limits)
Definition: map_limits.h:93


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:58