33 #include <gtest/gtest.h> 39 template <
int BLOCK_WIDTH>
48 TEST(BlockmemGridmap, BlockWidth)
56 TEST(BlockmemGridmap, ResetClear)
60 for (
int s = 4;
s <= 6;
s += 2)
66 for (i[0] = 0; i[0] <
s; ++i[0])
68 for (i[1] = 0; i[1] < s; ++i[1])
70 for (i[2] = 0; i[2] < s; ++i[2])
72 ASSERT_EQ(gm[i], 0.0);
78 for (i[0] = 0; i[0] < s; ++i[0])
80 for (i[1] = 0; i[1] < s; ++i[1])
82 for (i[2] = 0; i[2] < s; ++i[2])
84 ASSERT_EQ(gm[i], 3.0);
91 TEST(BlockmemGridmap, ClearAndCopyPartially)
95 gm_base.
reset(base_size);
98 for (p[1] = 0; p[1] < base_size[1]; ++p[1])
100 for (p[2] = 0; p[2] < base_size[2]; ++p[2])
102 gm_base[p] = p[0] * base_size[1] * base_size[2] + p[1] * base_size[2] + p[2];
116 for (p[1] = 0; p[1] < base_size[1]; ++p[1])
118 for (p[2] = 0; p[2] < base_size[2]; ++p[2])
120 if ((copy_min_pos[0] <= p[0]) && (p[0] < copy_max_pos[0]) &&
121 (copy_min_pos[1] <= p[1]) && (p[1] < copy_max_pos[1]) &&
122 (copy_min_pos[2] <= p[2]) && (p[2] < copy_max_pos[2]))
124 EXPECT_EQ(gm[p], -1) << p[0] <<
"," << p[1] <<
"," << p[2];
128 EXPECT_EQ(gm[p], gm_base[p]) << p[0] <<
"," << p[1] <<
"," << p[2];
135 gm_update.
reset(base_size);
138 for (p[1] = 0; p[1] < base_size[1]; ++p[1])
140 for (p[2] = 0; p[2] < base_size[2]; ++p[2])
142 gm_update[p] = p[0] * base_size[1] * base_size[2] + p[1] * base_size[2] + p[2] * -1;
152 for (p[1] = 0; p[1] < base_size[1]; ++p[1])
154 for (p[2] = 0; p[2] < base_size[2]; ++p[2])
156 if ((copy_min_pos[0] <= p[0]) && (p[0] < copy_max_pos[0]) &&
157 (copy_min_pos[1] <= p[1]) && (p[1] < copy_max_pos[1]) &&
158 (copy_min_pos[2] <= p[2]) && (p[2] < copy_max_pos[2]))
160 ASSERT_EQ(gm[p], gm_update[p]);
164 ASSERT_EQ(gm[p], gm_base[p]);
171 TEST(BlockmemGridmap, WriteRead)
180 for (i[0] = 0; i[0] < s; ++i[0])
182 for (i[1] = 0; i[1] < s; ++i[1])
184 for (i[2] = 0; i[2] < s; ++i[2])
186 gm[i] = i[2] * 100 + i[1] * 10 + i[0];
191 for (i[0] = 0; i[0] < s; ++i[0])
193 for (i[1] = 0; i[1] < s; ++i[1])
195 for (i[2] = 0; i[2] < s; ++i[2])
197 ASSERT_EQ(gm[i], i[2] * 100 + i[1] * 10 + i[0]);
203 TEST(BlockmemGridmap, OuterBoundary)
212 const int outer = 0x10;
213 for (i[0] = -outer; i[0] < s + outer; ++i[0])
215 for (i[1] = -outer; i[1] < s + outer; ++i[1])
217 for (i[2] = -outer; i[2] < s + outer; ++i[2])
219 if (i[0] >= 0 && i[1] >= 0 && i[2] >= 0 &&
220 i[0] < s && i[1] < s && i[2] < s)
236 int main(
int argc,
char** argv)
238 testing::InitGoogleTest(&argc, argv);
240 return RUN_ALL_TESTS();
void reset(const CyclicVecInt< DIM, NONCYCLIC > &size)
TEST(BlockmemGridmap, BlockWidth)
size_t getBlockBit() const
bool validate(const CyclicVecInt< DIM, NONCYCLIC > &pos, const int tolerance=0) const
static constexpr size_t block_bit_
void clear_partially(const T zero, const CyclicVecInt< DIM, NONCYCLIC > &min, const CyclicVecInt< DIM, NONCYCLIC > &max)
int main(int argc, char **argv)
void copy_partially(const BlockMemGridmapBase< T, DIM, NONCYCLIC > &base, const CyclicVecInt< DIM, NONCYCLIC > &min, const CyclicVecInt< DIM, NONCYCLIC > &max)