xy_index_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/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 }  // namespace
00060 }  // namespace mapping
00061 }  // namespace cartographer


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