19 #include "gtest/gtest.h" 22 namespace mapping_2d {
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());
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);
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());
51 TEST(MapLimitsTest, ConstructAndGet) {
52 const MapLimits limits(42., Eigen::Vector2d(3., 0.), CellLimits(2, 3));
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);
58 const Eigen::Vector2d& max = limits.max();
59 EXPECT_EQ(3., max.x());
60 EXPECT_EQ(0., max.y());
62 EXPECT_EQ(42., limits.resolution());
proto::MapLimits ToProto(const MapLimits &map_limits)