34 #include <gtest/gtest.h> 41 template<
class iterator_type>
45 iterator_type end = it.end();
46 for ( ; it != end; ++it)
49 if (count >= max_iterations)
break;
54 TEST(WholeGrid, whole_grid)
63 ASSERT_EQ(i.x, count % info.
width);
64 ASSERT_EQ(i.y, count / info.
width);
70 TEST(WholeGrid, whole_grid_range)
78 ASSERT_EQ(i.x, count % info.
width);
79 ASSERT_EQ(i.y, count / info.
width);
92 std::vector<Index> vec;
93 std::copy(wg.
begin(), wg.
end(), std::back_inserter(vec));
94 for (
int count = 0; count < 16; ++count)
96 Index& i = vec[count];
97 ASSERT_EQ(i.x, count % info.
width);
98 ASSERT_EQ(i.y, count / info.
width);
110 ASSERT_EQ(i.x, static_cast<unsigned int>(1 + count % 2));
111 ASSERT_EQ(i.y, static_cast<unsigned int>(2 + count / 2));
129 ASSERT_FALSE(it1 == it2);
154 ASSERT_FALSE(it1 == it2);
157 TEST(CircleOutline, circle_outline)
164 unsigned int size = 0;
182 ASSERT_FALSE(it1 == it2);
207 ASSERT_FALSE(it1 == it2);
238 TEST(Line, signed_line_diff_res)
285 ASSERT_FALSE(it1 == it2);
290 nav_2d_msgs::Point2D pt;
303 nav_2d_msgs::Polygon2D simple_square;
304 simple_square.points.push_back(
make_point(1.4, 1.4));
305 simple_square.points.push_back(
make_point(1.4, 3.6));
306 simple_square.points.push_back(
make_point(3.6, 3.6));
307 simple_square.points.push_back(
make_point(3.6, 1.4));
329 nav_2d_msgs::Polygon2D empty_polygon;
341 nav_2d_msgs::Polygon2D simple_square;
342 simple_square.points.push_back(
make_point(1.4, 1.4));
343 simple_square.points.push_back(
make_point(1.4, 3.6));
344 simple_square.points.push_back(
make_point(3.6, 3.6));
345 simple_square.points.push_back(
make_point(3.6, 1.4));
347 nav_2d_msgs::Polygon2D triangle;
348 triangle.points.push_back(
make_point(1.4, 1.4));
349 triangle.points.push_back(
make_point(1.4, 3.6));
350 triangle.points.push_back(
make_point(3.6, 3.6));
355 ASSERT_FALSE(it1 == it2);
359 ASSERT_FALSE(it3 == it4);
370 nav_2d_msgs::Polygon2D simple_square;
371 simple_square.points.push_back(
make_point(1.4, 1.4));
372 simple_square.points.push_back(
make_point(1.4, 3.6));
373 simple_square.points.push_back(
make_point(3.6, 3.6));
374 simple_square.points.push_back(
make_point(3.6, 1.4));
377 whole_grid = whole_grid.
begin();
379 sub_grid = sub_grid.
begin();
385 spiral = spiral.
begin();
394 TEST(Iterators, test_assignment)
402 EXPECT_EQ((*iter1).x, 2U);
403 EXPECT_EQ((*iter1).y, 2U);
408 EXPECT_EQ((*iter1).x, 2U);
409 EXPECT_EQ((*iter1).y, 2U);
410 EXPECT_EQ((*iter2).x, 2U);
411 EXPECT_EQ((*iter2).y, 2U);
415 EXPECT_EQ((*iter1).x, 2U);
416 EXPECT_EQ((*iter1).y, 2U);
417 EXPECT_EQ((*iter2).x, 3U);
418 EXPECT_EQ((*iter2).y, 2U);
422 EXPECT_EQ((*iter1).x, 3U);
423 EXPECT_EQ((*iter1).y, 2U);
424 EXPECT_EQ((*iter2).x, 3U);
425 EXPECT_EQ((*iter2).y, 2U);
429 EXPECT_EQ((*iter1).x, 3U);
430 EXPECT_EQ((*iter1).y, 2U);
431 EXPECT_EQ((*iter2).x, 2U);
432 EXPECT_EQ((*iter2).y, 3U);
436 EXPECT_EQ((*iter1).x, 3U);
437 EXPECT_EQ((*iter1).y, 2U);
438 EXPECT_EQ((*iter2).x, 2U);
439 EXPECT_EQ((*iter2).y, 3U);
440 EXPECT_EQ((*iter3).x, 3U);
441 EXPECT_EQ((*iter3).y, 2U);
444 int main(
int argc,
char **argv)
446 testing::InitGoogleTest(&argc, argv);
447 return RUN_ALL_TESTS();
Line begin() const override
Helper function for range-style iteration Equivalent to the above constructor.
int countIterations(iterator_type it, int max_iterations=1000)
WholeGrid begin() const override
Helper function for range-style iteration Equivalent to the above constructor.
Iterates over all of the valid indexes on the outline of a polygon.
Iterates over all of the valid indexes that lie within a circle from the center out.
Iterates over all of the valid indexes that lie within a circle in row major order.
SubGrid begin() const override
Helper function for range-style iteration Equivalent to the above constructor.
GenericIndex< unsigned int > Index
int main(int argc, char **argv)
nav_2d_msgs::Point2D make_point(double x, double y)
Iterates over the valid indexes that lie on the outline of a circle.
WholeGrid end() const override
Helper function for range-style iteration.
CircleOutline begin() const override
Helper function for range-style iteration Equivalent to the above constructor.
Iterates over all of the valid indexes of a line.
Iterates over all of the valid indexes that lie within an arbitrary polygon in row major order...
TEST(WholeGrid, whole_grid)
PolygonFill begin() const override
Helper function for range-style iteration Equivalent to the above constructor.
Iterator for looping through every index within an aligned rectangular portion of the grid...
CircleFill begin() const override
Helper function for range-style iteration Equivalent to the above constructor.
Spiral begin() const override
Helper function for range-style iteration Equivalent to the above constructor.
PolygonOutline begin() const override
Helper function for range-style iteration Equivalent to the above constructor.