25 #define BOOST_TEST_MODULE ( PointIsolationAlg_test ) 26 #include "boost/test/unit_test.hpp" 49 Container_t grid({{{ 2U, 3U }}});
54 BOOST_TEST(grid.dims() == 2U);
56 BOOST_TEST(grid.size() == 6U);
57 BOOST_TEST(grid.sizeX() == 2U);
58 BOOST_TEST(grid.sizeY() == 3U);
62 BOOST_TEST(grid.index({{ 0, 0 }}) == 0U);
63 BOOST_TEST(grid.index({{ 1, 2 }}) == 5U);
64 BOOST_CHECK_NO_THROW(grid.index({{ 2, 2 }}));
66 BOOST_TEST( grid.has(0));
67 BOOST_TEST( grid.has(grid.size() - 1));
68 BOOST_TEST(!grid.has(grid.size()));
72 BOOST_TEST(grid.indexOffset({{ 0, 1 }}, {{ 1, 2 }}) == 4);
73 BOOST_TEST(grid.indexOffset({{ 1, 2 }}, {{ 0, 1 }}) == -4);
79 for (cellID[0] = 0; (size_t) cellID[0] < grid.sizeX(); ++cellID[0]) {
80 for (cellID[1] = 0; (size_t) cellID[1] < grid.sizeY(); ++cellID[1]) {
82 auto cellIndex = grid.index(cellID);
84 int count = cellID[0] + cellID[1];
86 if (count & 1) grid.insert(cellID, count);
87 else grid.insert(cellIndex, count);
96 for (cellID[0] = 0; (size_t) cellID[0] < grid.sizeX(); ++cellID[0]) {
97 for (cellID[1] = 0; (size_t) cellID[1] < grid.sizeY(); ++cellID[1]) {
99 int count = cellID[0] + cellID[1];
101 auto cellIndex = grid.index(cellID);
102 auto const& cell = (count & 1)? grid[cellIndex]: grid[cellID];
104 BOOST_TEST_CHECKPOINT
105 (
"[" << cellID[0] <<
"][" << cellID[1] <<
"]");
106 BOOST_TEST(cell.size() == (size_t) count);
108 for (
size_t k = 0;
k < cell.size(); ++
k) {
110 BOOST_TEST_CHECKPOINT(
" [" <<
k <<
"]");
111 BOOST_TEST(val == --count);
139 Container_t grid({{{ 2U, 3U, 4U }}});
144 BOOST_TEST(grid.dims() == 3U);
146 BOOST_TEST(grid.size() == 24U);
147 BOOST_TEST(grid.sizeX() == 2U);
148 BOOST_TEST(grid.sizeY() == 3U);
149 BOOST_TEST(grid.sizeZ() == 4U);
153 BOOST_TEST(grid.index({{ 0, 0, 0 }}) == 0U);
154 BOOST_TEST(grid.index({{ 1, 2, 3 }}) == 23U);
155 BOOST_CHECK_NO_THROW(grid.index({{ 2, 2, 3 }}));
157 BOOST_TEST( grid.has(0));
158 BOOST_TEST( grid.has(grid.size() - 1));
159 BOOST_TEST(!grid.has(grid.size()));
163 BOOST_TEST(grid.indexOffset({{ 0, 1, 2 }}, {{ 1, 2, 3 }}) == 17);
164 BOOST_TEST(grid.indexOffset({{ 1, 2, 3 }}, {{ 0, 1, 2 }}) == -17);
170 for (cellID[0] = 0; (size_t) cellID[0] < grid.sizeX(); ++cellID[0]) {
171 for (cellID[1] = 0; (size_t) cellID[1] < grid.sizeY(); ++cellID[1]) {
172 for (cellID[2] = 0; (size_t) cellID[2] < grid.sizeZ(); ++cellID[2]) {
174 auto cellIndex = grid.index(cellID);
176 int count = cellID[0] + cellID[1] + cellID[2];
177 while (count-- > 0) {
178 if (count & 1) grid.insert(cellID, count);
179 else grid.insert(cellIndex, count);
189 for (cellID[0] = 0; (size_t) cellID[0] < grid.sizeX(); ++cellID[0]) {
190 for (cellID[1] = 0; (size_t) cellID[1] < grid.sizeY(); ++cellID[1]) {
191 for (cellID[2] = 0; (size_t) cellID[2] < grid.sizeZ(); ++cellID[2]) {
193 int count = cellID[0] + cellID[1] + cellID[2];
195 auto cellIndex = grid.index(cellID);
196 auto const& cell = (count & 1)? grid[cellIndex]: grid[cellID];
198 BOOST_TEST_CHECKPOINT
199 (
"[" << cellID[0] <<
"][" << cellID[1] <<
"][" << cellID[2] <<
"]");
200 BOOST_TEST(cell.size() == (size_t) count);
202 for (
size_t k = 0;
k < cell.size(); ++
k) {
204 BOOST_TEST_CHECKPOINT(
" [" <<
k <<
"]");
205 BOOST_TEST(val == --count);
BOOST_AUTO_TEST_CASE(GridContainer2DTestCase)
Base class for a container of data arranged on a 2D-grid.
void GridContainer3DTest()
Test for a GridContainer3D of integers.
void GridContainer2DTest()
Test for a GridContainer2D of integers.
Containers with indices in 1, 2 and 3 dimensions.
Base class for a container of data arranged on a 3D-grid.