diff --git a/test/AutoExpandbleMap/AutoExpandble_map_utest.cpp b/test/AutoExpandbleMap/AutoExpandble_map_utest.cpp index 6bcecc5..86849fc 100644 --- a/test/AutoExpandbleMap/AutoExpandble_map_utest.cpp +++ b/test/AutoExpandbleMap/AutoExpandble_map_utest.cpp @@ -2,46 +2,49 @@ #include "Map_test.h" -bool is_succeed(const DiscretePoint2D& Cell_coor, MapParams expected_param) { +bool test_expansion_by_cell_update(const DiscretePoint2D& Cell_coor, MapParams expected_param) { GridMap map(std::shared_ptr(new TinyBaseCellFactory), {1,1,1}); - MapParams param = test_auto_expand(Cell_coor, map); + + map.update_cell(Cell_coor, {0.5, 0.5}); + MapParams param(map.height(), map.width(), map.map_center_x(), map.map_center_y()); + return param == expected_param; } TEST(AutoExpandbleMapBaseTests, Expand_Right) { - EXPECT_TRUE(is_succeed({2,0}, {1,4,0,0})); + EXPECT_TRUE(test_expansion_by_cell_update({2,0}, {1,4,0,0})); } TEST(AutoExpandbleMapBaseTests, Expand_Top) { - EXPECT_TRUE(is_succeed({0,2}, {4,1,0,0})); + EXPECT_TRUE(test_expansion_by_cell_update({0,2}, {4,1,0,0})); } TEST(AutoExpandbleMapBaseTests, Expand_Left) { - EXPECT_TRUE(is_succeed({-2,0}, {1,4,3,0})); + EXPECT_TRUE(test_expansion_by_cell_update({-2,0}, {1,4,3,0})); } TEST(AutoExpandbleMapBaseTests, Expand_Down) { - EXPECT_TRUE(is_succeed({0,-2}, {4,1,0,3})); + EXPECT_TRUE(test_expansion_by_cell_update({0,-2}, {4,1,0,3})); } TEST(AutoExpandbleMapBaseTests, Expand_Right_Top) { - EXPECT_TRUE(is_succeed({2,2}, {4,4,0,0})); + EXPECT_TRUE(test_expansion_by_cell_update({2,2}, {4,4,0,0})); } TEST(AutoExpandbleMapBaseTests, Expand_Right_Down) { - EXPECT_TRUE(is_succeed({2,-2}, {4,4,0,3})); + EXPECT_TRUE(test_expansion_by_cell_update({2,-2}, {4,4,0,3})); } TEST(AutoExpandbleMapBaseTests, Expand_Left_Top) { - EXPECT_TRUE(is_succeed({-2,2}, {4,4,3,0})); + EXPECT_TRUE(test_expansion_by_cell_update({-2,2}, {4,4,3,0})); } TEST(AutoExpandbleMapBaseTests, Expand_Left_Down) { - EXPECT_TRUE(is_succeed({-2,-2}, {4,4,3,3})); + EXPECT_TRUE(test_expansion_by_cell_update({-2,-2}, {4,4,3,3})); } TEST(AutoExpandbleMapBaseTests, NoExpand) { - EXPECT_TRUE(is_succeed({0,0}, {1,1,0,0})); + EXPECT_TRUE(test_expansion_by_cell_update({0,0}, {1,1,0,0})); } TEST(AutoExpandbleMapBaseTests, CheckCellsValue) { diff --git a/test/AutoExpandbleMap/Map_test.h b/test/AutoExpandbleMap/Map_test.h index c5b5215..db446da 100644 --- a/test/AutoExpandbleMap/Map_test.h +++ b/test/AutoExpandbleMap/Map_test.h @@ -7,8 +7,8 @@ class MapParams { public: MapParams (int height = 0, int width = 0, int map_center_x = 0, int map_center_y = 0) : - _height(height), _width(width), _map_center_x(map_center_x), - _map_center_y(map_center_y) {} + _height(height), _width(width), + _map_center_x(map_center_x), _map_center_y(map_center_y) {} friend bool operator==(const MapParams &left, const MapParams &right); @@ -19,29 +19,17 @@ class MapParams { }; bool operator==(const MapParams &left, const MapParams &right) { - return (left._height == right._height)&&(left._map_center_x == right._map_center_x) - &&(left._width == right._width) &&(left._map_center_y == right._map_center_y); -} - -MapParams test_auto_expand(const DiscretePoint2D& Cell_coor, GridMap map) { - MapParams param; - - map.update_cell(Cell_coor, {0.5, 0.5}); - param._height = map.height(); - param._width = map.width(); - param._map_center_x = map.map_center_x(); - param._map_center_y = map.map_center_y(); - - return param; + return (left._height == right._height) && (left._map_center_x == right._map_center_x) + &&(left._width == right._width) && (left._map_center_y == right._map_center_y); } bool test_CellValueNotChange(GridMap map) { - bool is_centershifting_x = (map.map_center_x() == 0), - is_centershifting_y = (map.map_center_y() == 0); + bool is_center_x_shifted = (map.map_center_x() == 0), + is_center_y_shifted = (map.map_center_y() == 0); - int x0 = is_centershifting_x ? 0 : + int x0 = is_center_x_shifted ? 0 : (map.map_center_x() - 1 - map.width()); - int y0 = is_centershifting_y ? 0 : + int y0 = is_center_y_shifted ? 0 : (map.map_center_y() - 1 - map.height()); int i = 0, j = 0;