Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer/mapping/2d/xy_index.h"
00018
00019 #include "gtest/gtest.h"
00020
00021 namespace cartographer {
00022 namespace mapping {
00023 namespace {
00024
00025 TEST(XYIndexTest, CellLimitsToProto) {
00026 const CellLimits limits(1, 2);
00027 const auto proto = ToProto(limits);
00028 EXPECT_EQ(limits.num_x_cells, proto.num_x_cells());
00029 EXPECT_EQ(limits.num_y_cells, proto.num_y_cells());
00030 }
00031
00032 TEST(XYIndexTest, CellLimitsProtoConstructor) {
00033 proto::CellLimits limits;
00034 limits.set_num_x_cells(1);
00035 limits.set_num_y_cells(2);
00036
00037 auto native = CellLimits(limits);
00038 EXPECT_EQ(limits.num_x_cells(), native.num_x_cells);
00039 EXPECT_EQ(limits.num_y_cells(), native.num_y_cells);
00040 }
00041
00042 TEST(XYIndexTest, XYIndexRangeIterator) {
00043 const Eigen::Array2i min(1, 2);
00044 const Eigen::Array2i max(3, 4);
00045 XYIndexRangeIterator it(min, max);
00046 EXPECT_TRUE((min == *it.begin()).all()) << *it.begin();
00047 EXPECT_TRUE((Eigen::Array2i(1, 5) == *it.end()).all()) << *it.end();
00048 EXPECT_TRUE((min == *it).all()) << *it;
00049 int num_indices = 0;
00050 for (const Eigen::Array2i& xy_index : XYIndexRangeIterator(min, max)) {
00051 LOG(INFO) << xy_index;
00052 EXPECT_TRUE((xy_index >= min).all());
00053 EXPECT_TRUE((xy_index <= max).all());
00054 ++num_indices;
00055 }
00056 EXPECT_EQ(9, num_indices);
00057 }
00058
00059 }
00060 }
00061 }