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 }
TEST(CDynamicGrid, GetSetAndResize)
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:38
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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020