34 #include <gtest/gtest.h> 50 unsigned int& match,
unsigned int& missed,
unsigned int& multiple)
59 for (
unsigned int x = 0;
x < info.
width;
x++)
61 for (
unsigned int y = 0;
y < info.
height;
y++)
83 EXPECT_THROW(
divideBounds(bounds, 0, 2), std::invalid_argument);
84 EXPECT_THROW(
divideBounds(bounds, 2, 0), std::invalid_argument);
85 EXPECT_THROW(
divideBounds(bounds, 0, 0), std::invalid_argument);
101 TEST(DivideBounds, iterative_tests)
107 unsigned int match, missed, multiple;
115 for (
unsigned int rows = 1; rows < 11u; rows++)
117 for (
unsigned int cols = 1; cols < 11u; cols++)
120 std::vector<UIntBounds> divided =
divideBounds(full_bounds, cols, rows);
121 ASSERT_LE(divided.size(), rows * cols) << info.
width <<
"x" << info.
height <<
" " << rows <<
"x" << cols;
124 EXPECT_FALSE(sub.isEmpty());
126 for (
unsigned int x = sub.getMinX();
x <= sub.getMaxX();
x++)
128 for (
unsigned int y = sub.getMinY();
y <= sub.getMaxY();
y++)
137 <<
" Requested divisions: " << rows <<
"x" << cols;
138 EXPECT_EQ(missed, 0u);
139 EXPECT_EQ(multiple, 0u);
151 TEST(DivideBounds, recursive_tests)
161 std::vector<UIntBounds> level_one =
divideBounds(full_bounds, 2, 2);
162 ASSERT_EQ(level_one.size(), 4u);
165 std::vector<UIntBounds> level_two =
divideBounds(sub, 2, 2);
166 ASSERT_EQ(level_two.size(), 4u);
169 EXPECT_GE(subsub.getMinX(), sub.getMinX());
170 EXPECT_LE(subsub.getMaxX(), sub.getMaxX());
171 EXPECT_GE(subsub.getMinY(), sub.getMinY());
172 EXPECT_LE(subsub.getMaxY(), sub.getMaxY());
174 for (
unsigned int x = subsub.getMinX();
x <= subsub.getMaxX();
x++)
176 for (
unsigned int y = subsub.getMinY();
y <= subsub.getMaxY();
y++)
185 unsigned int match = 0,
190 EXPECT_EQ(missed, 0u);
191 EXPECT_EQ(multiple, 0u);
195 int main(
int argc,
char** argv)
197 testing::InitGoogleTest(&argc, argv);
198 return RUN_ALL_TESTS();
std::vector< nav_core2::UIntBounds > divideBounds(const nav_core2::UIntBounds &original_bounds, unsigned int n_cols, unsigned int n_rows)
divide the given bounds up into sub-bounds of roughly equal size
void countValues(const nav_grid::VectorNavGrid< unsigned char > &grid, unsigned int &match, unsigned int &missed, unsigned int &multiple)
Count the values in a grid.
TFSIMD_FORCE_INLINE const tfScalar & y() const
void setInfo(const NavGridInfo &new_info) override
TFSIMD_FORCE_INLINE const tfScalar & x() const
void setValue(const unsigned int x, const unsigned int y, const T &value) override
TEST(DivideBounds, zeroes)
int main(int argc, char **argv)
NavGridInfo getInfo() const
nav_core2::UIntBounds getFullUIntBounds(const nav_grid::NavGridInfo &info)
return an integral bounds that covers the entire NavGrid