Skip to content

Commit

Permalink
7341 rm function, fixed names
Browse files Browse the repository at this point in the history
  • Loading branch information
gam4ik committed Oct 5, 2016
1 parent 07e258b commit ffac1c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
25 changes: 14 additions & 11 deletions test/AutoExpandbleMap/AutoExpandble_map_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GridCellFactory>(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) {
Expand Down
28 changes: 8 additions & 20 deletions test/AutoExpandbleMap/Map_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;

Expand Down

0 comments on commit ffac1c1

Please sign in to comment.