Main MRPT website > C++ reference for MRPT 1.9.9
CDynamicGrid_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
11 #include <mrpt/core/common.h>
12 #include <CTraitsTest.h>
13 
14 #include <gtest/gtest.h>
15 
16 template class mrpt::CTraitsTest<mrpt::containers::CDynamicGrid<double>>;
17 
19 
20 TEST(CDynamicGrid, GetSetAndResize)
21 {
22  CDynamicGrid<double> grid{-10.0, 10.0, -10.0, 10.0, 0.1};
23 
24  *grid.cellByPos(3.0, 4.0) = 8.0;
25  *grid.cellByPos(-2.0, -7.0) = 9.0;
26 
27  EXPECT_NEAR(*grid.cellByPos(3.0, 4.0), 8.0, 1e-10);
28  EXPECT_NEAR(*grid.cellByPos(-2.0, -7.0), 9.0, 1e-10);
29 
30  grid.resize(-20.0, 20.0, -20.0, 20.0, 0.0, 0.0);
31  EXPECT_NEAR(*grid.cellByPos(3.0, 4.0), 8.0, 1e-10);
32  EXPECT_NEAR(*grid.cellByPos(-2.0, -7.0), 9.0, 1e-10);
33 }
mrpt::containers::CDynamicGrid::cellByPos
T * cellByPos(double x, double y)
Returns a pointer to the contents of a cell given by its coordinates, or nullptr if it is out of the ...
Definition: CDynamicGrid.h:211
CDynamicGrid.h
common.h
mrpt::containers::CDynamicGrid
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:38
TEST
TEST(CDynamicGrid, GetSetAndResize)
Definition: CDynamicGrid_unittest.cpp:20



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST