unbounded_lazy_tiled_grid_map_test.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
3 #include <memory>
4 
5 #include "../mock_grid_cell.h"
6 
7 #include "../../../src/core/maps/lazy_tiled_grid_map.h"
8 
9 class UnboundedLazyTiledGridMapTest : public ::testing::Test {
10 protected: // methods
12  : map{std::make_shared<MockGridCell>(), {1, 1, 1}}
13  , data{true, {0.5, 0.5}, {-1, -1}, 0} {}
14 protected: // fields
17 };
18 
19 struct MapInfo {
20 // methods
21  MapInfo(int w_, int h_, int o_x, int o_y) : w{w_}, h{h_}, origin{o_x, o_y} {}
22  MapInfo(const GridMap& map) :
23  w{map.width()}, h{map.height()}, origin{map.origin()} {}
24 
25  bool operator==(const MapInfo& that) const {
26  return (w == that.w) && (h == that.h) && (origin == that.origin);
27  }
28 // fields
29  int w, h;
31 };
32 
33 std::ostream &operator<<(std::ostream &stream, const MapInfo &mi) {
34  stream << "w: " << mi.w << ", h: " << mi.h;
35  return stream << ", origin: ("<< mi.origin.x << ", " << mi.origin.y << ")";
36 }
37 
39  static constexpr int Lim = 50;
40  for (int i = -Lim; i != Lim; ++i) {
41  for (int j = -Lim; j != Lim; ++j) {
42  map.update({i, j}, {true, {(double)Lim * i + j, 0}, {0, 0}, 0});
43  }
44  }
45  UnboundedLazyTiledGridMap map_copy = map;
46 
47  for (int i = -Lim; i != Lim; ++i) {
48  for (int j = -Lim; j != Lim; ++j) {
49  ASSERT_EQ((map[{i, j}]), ((double)Lim * i + j));
50  ASSERT_EQ((map_copy[{i, j}]), ((double)Lim * i + j));
51  }
52  }
53 
54 }
55 
57  static constexpr int Lim = 50;
58  for (int i = -Lim; i != Lim; ++i) {
59  for (int j = -Lim; j != Lim; ++j) {
60  map.update({i, j}, {true, {(double)Lim * i + j, 0}, {0, 0}, 0});
61  }
62  }
63  UnboundedLazyTiledGridMap map_copy = map;
64  for (int i = -Lim; i != Lim; ++i) {
65  for (int j = -Lim; j != Lim; ++j) {
66  map_copy.update({i, j}, {true, {(double)2*Lim * i + j, 0}, {0, 0}, 0});
67  }
68  }
69 
70  for (int i = -Lim; i != Lim; ++i) {
71  for (int j = -Lim; j != Lim; ++j) {
72  ASSERT_EQ((map[{i, j}]), ((double)Lim * i + j));
73  ASSERT_EQ((map_copy[{i, j}]), ((double)2*Lim * i + j));
74  }
75  }
76 
77 }
78 
79 
80 int main (int argc, char *argv[]) {
81  ::testing::InitGoogleTest(&argc, argv);
82  return RUN_ALL_TESTS();
83 }
MapInfo(int w_, int h_, int o_x, int o_y)
TEST_F(UnboundedLazyTiledGridMapTest, readMapCopy)
void update(const Coord &area_id, const AreaOccupancyObservation &aoo) override
Updates area with a given observation.
std::ostream & operator<<(std::ostream &stream, const MapInfo &mi)
bool operator==(const MapInfo &that) const
TFSIMD_FORCE_INLINE const tfScalar & w() const
int main(int argc, char *argv[])
virtual int height() const
DiscretePoint2D origin() const override
MapInfo(const GridMap &map)
virtual int width() const


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