xy_index_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(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());
30 }
31 
32 TEST(XYIndexTest, CellLimitsProtoConstructor) {
33  proto::CellLimits limits;
34  limits.set_num_x_cells(1);
35  limits.set_num_y_cells(2);
36 
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);
40 }
41 
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;
49  int num_indices = 0;
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());
54  ++num_indices;
55  }
56  EXPECT_EQ(9, num_indices);
57 }
58 
59 } // namespace
60 } // namespace mapping_2d
61 } // 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:59