9 #include <boost/test/unit_test.hpp>
24 GeometryIdentifier makeId(
int volume = 0,
int layer = 0,
int sensitive = 0) {
39 #define CHECK_ENTRY(container, query, compare) \
41 auto ret = container.find(query); \
42 BOOST_CHECK_NE(ret, container.end()); \
43 if (ret != container.end()) { \
44 auto idx = std::distance(container.begin(), ret); \
45 BOOST_CHECK_EQUAL(container.idAt(idx), compare); \
49 BOOST_TEST_DONT_PRINT_LOG_VALUE(Container::Iterator)
50 BOOST_TEST_DONT_PRINT_LOG_VALUE(Thing)
52 BOOST_AUTO_TEST_SUITE(GeometryHierarchyMap)
56 BOOST_CHECK_EQUAL(c.begin(), c.end());
57 BOOST_CHECK(c.empty());
58 BOOST_CHECK_EQUAL(c.size(), 0
u);
62 std::vector<std::pair<GeometryIdentifier, Thing>> entries = {
63 {makeId(2, 4, 6), {1.0}},
64 {makeId(3, 5), {1.0}},
67 {makeId(2, 4, 6), {2.0}},
69 BOOST_CHECK_THROW(Container(
std::move(entries)), std::invalid_argument);
71 std::vector<std::pair<GeometryIdentifier, Thing>> defaults = {
76 BOOST_CHECK_THROW(Container(
std::move(defaults)), std::invalid_argument);
81 {makeId(0, 1, 2), {1.0}},
82 {makeId(3, 4), {3.0}},
86 BOOST_CHECK_EQUAL(
std::next(c.begin(), 4), c.end());
87 BOOST_CHECK(not c.empty());
88 BOOST_CHECK_EQUAL(c.size(), 4
u);
97 {makeId(1, 2, 3), {2.0}},
98 {makeId(3, 4, 5), {2.5}},
99 {makeId(3, 5), {3.0}},
100 {makeId(4, 5, 7), {4.0}},
103 BOOST_CHECK(not
c.empty());
104 BOOST_CHECK_EQUAL(
c.size(), 4
u);
107 for (
auto i =
c.size(); 0 <
i--;) {
109 BOOST_CHECK_NE(
c.idAt(
i), GeometryIdentifier());
111 BOOST_CHECK_NE(
c.valueAt(
i).value, Thing().value);
114 BOOST_CHECK_THROW(
c.idAt(
c.size()), std::out_of_range);
115 BOOST_CHECK_THROW(
c.valueAt(
c.size()), std::out_of_range);
121 {makeId(2, 4, 6), {-23.0}},
123 {makeId(2, 8), {5.0}},
128 {makeId(12, 16), {-1.0}},
132 BOOST_CHECK_EQUAL(
std::next(c.begin(), 4
u), c.end());
133 BOOST_CHECK(not c.empty());
134 BOOST_CHECK_EQUAL(c.size(), 4
u);
152 CHECK_ENTRY(c, makeId(12, 16, 20), makeId(12, 16));
155 BOOST_CHECK_EQUAL(c.find(makeId(3, 5, 7)), c.end());
157 BOOST_CHECK_EQUAL(c.find(makeId(3, 5)), c.end());
159 BOOST_CHECK_EQUAL(c.find(makeId(3)), c.end());
161 BOOST_CHECK_EQUAL(c.find(makeId(12)), c.end());
169 {makeId(2, 3), {2.0}},
175 BOOST_CHECK_EQUAL(
std::next(c.begin(), 3
u), c.end());
176 BOOST_CHECK(not c.empty());
177 BOOST_CHECK_EQUAL(c.size(), 3
u);
197 BOOST_AUTO_TEST_SUITE_END()