19 #include "gtest/gtest.h" 22 namespace mapping_2d {
25 TEST(XYIndexTest, CellLimitsToProto) {
26 const CellLimits limits(1, 2);
27 const auto proto =
ToProto(limits);
28 EXPECT_EQ(limits.num_x_cells, proto.num_x_cells());
29 EXPECT_EQ(limits.num_y_cells, proto.num_y_cells());
32 TEST(XYIndexTest, CellLimitsProtoConstructor) {
33 proto::CellLimits limits;
34 limits.set_num_x_cells(1);
35 limits.set_num_y_cells(2);
37 auto native = CellLimits(limits);
38 EXPECT_EQ(limits.num_x_cells(), native.num_x_cells);
39 EXPECT_EQ(limits.num_y_cells(), native.num_y_cells);
42 TEST(XYIndexTest, XYIndexRangeIterator) {
43 const Eigen::Array2i min(1, 2);
44 const Eigen::Array2i max(3, 4);
45 XYIndexRangeIterator it(min, max);
46 EXPECT_TRUE((min == *it.begin()).all()) << *it.begin();
47 EXPECT_TRUE((Eigen::Array2i(1, 5) == *it.end()).all()) << *it.end();
48 EXPECT_TRUE((min == *it).all()) << *it;
50 for (
const Eigen::Array2i& xy_index : XYIndexRangeIterator(min, max)) {
51 LOG(INFO) << xy_index;
52 EXPECT_TRUE((xy_index >= min).all());
53 EXPECT_TRUE((xy_index <= max).all());
56 EXPECT_EQ(9, num_indices);
proto::MapLimits ToProto(const MapLimits &map_limits)