unbounded_plain_grid_map_test.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
3 #include <memory>
4 #include <ostream>
5 
6 #include "../mock_grid_cell.h"
7 
8 #include "../../../src/core/maps/plain_grid_map.h"
9 
10 class UnboundedPlainGridMapTest : public ::testing::Test {
11 protected: // methods
13  : map{std::make_shared<MockGridCell>(), {1, 1, 1}}
14  , data{true, {0.5, 0.5}, {-1, -1}, 0} {}
15 protected: // fields
18 };
19 
20 struct MapInfo {
21 // methods
22  MapInfo(int w_, int h_, int o_x, int o_y) : w{w_}, h{h_}, origin{o_x, o_y} {}
23  MapInfo(const GridMap& map) :
24  w{map.width()}, h{map.height()}, origin{map.origin()} {}
25 
26  bool operator==(const MapInfo& that) const {
27  return (w == that.w) && (h == that.h) && (origin == that.origin);
28  }
29 // fields
30  int w, h;
31  DiscretePoint2D origin;
32 };
33 
34 std::ostream &operator<<(std::ostream &stream, const MapInfo &mi) {
35  stream << "w: " << mi.w << ", h: " << mi.h;
36  return stream << ", origin: ("<< mi.origin.x << ", " << mi.origin.y << ")";
37 }
38 
40  map.update({2, 0}, data);
41  ASSERT_EQ(MapInfo(map), MapInfo(3, 1, 0, 0));
42 }
43 
45  map.update({0, 2}, data);
46  ASSERT_EQ(MapInfo(map), MapInfo(1, 3, 0, 0));
47 }
48 
50  map.update({-2, 0}, data);
51  ASSERT_EQ(MapInfo(map), MapInfo(3, 1, 2, 0));
52 }
53 
55  map.update({0, -2}, data);
56  ASSERT_EQ(MapInfo(map), MapInfo(1, 3, 0, 2));
57 }
58 
60  map.update({2, 2}, data);
61  ASSERT_EQ(MapInfo(map), MapInfo(3, 3, 0, 0));
62 }
63 
64 TEST_F(UnboundedPlainGridMapTest, expandRightDown) {
65  map.update({2, -2}, data);
66  ASSERT_EQ(MapInfo(map), MapInfo(3, 3, 0, 2));
67 }
68 
70  map.update({-2, 2}, data);
71  ASSERT_EQ(MapInfo(map), MapInfo(3, 3, 2, 0));
72 }
73 
75  map.update({-2, -2}, data);
76  ASSERT_EQ(MapInfo(map), MapInfo(3, 3, 2, 2));
77 }
78 
80  map.update({0, 0}, data);
81  ASSERT_EQ(MapInfo(map), MapInfo(1, 1, 0, 0));
82 }
83 
85  static constexpr int Lim = 50;
86  for (int i = -Lim; i != Lim; ++i) {
87  for (int j = -Lim; j != Lim; ++j) {
88  map.update({i, j}, {true, {(double)Lim * i + j, 0}, {0, 0}, 0});
89  }
90  }
91  for (int i = -Lim; i != Lim; ++i) {
92  for (int j = -Lim; j != Lim; ++j) {
93  ASSERT_EQ((map[{i, j}]), ((double)Lim * i + j));
94  }
95  }
96 
97 }
98 
99 int main (int argc, char *argv[]) {
100  ::testing::InitGoogleTest(&argc, argv);
101  return RUN_ALL_TESTS();
102 }
Coord origin() const override
void update(const Coord &area_id, const AreaOccupancyObservation &aoo) override
Updates area with a given observation.
MapInfo(int w_, int h_, int o_x, int o_y)
TEST_F(UnboundedPlainGridMapTest, expandRight)
bool operator==(const MapInfo &that) const
TFSIMD_FORCE_INLINE const tfScalar & w() const
virtual int height() const
std::ostream & operator<<(std::ostream &stream, const MapInfo &mi)
MapInfo(const GridMap &map)
int main(int argc, char *argv[])
virtual int width() const


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25