Skip to content

Commit d468cb9

Browse files
author
Tim Ebbeke
committed
added two find all tests with const trees
1 parent 4d724c2 commit d468cb9

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/find_tests.hpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,43 @@ TEST_F(FindTests, CanFindAllElementsBackInStrictlyAscendingOverlappingIntervals)
137137
ASSERT_NE(tree.find(ival), std::end(tree));
138138
}
139139
}
140+
141+
TEST_F(FindTests, CanFindAllOnConstTree)
142+
{
143+
const auto targetInterval = lib_interval_tree::make_safe_interval(16, 21);
144+
tree.insert(targetInterval);
145+
tree.insert({8, 9});
146+
tree.insert({25, 30});
147+
std::vector <decltype(tree)::interval_type> intervals;
148+
auto findWithConstTree = [&intervals, &targetInterval](auto const& tree)
149+
{
150+
tree.find_all(targetInterval, [&intervals](auto const& iter) {
151+
intervals.emplace_back(*iter);
152+
return true;
153+
});
154+
};
155+
findWithConstTree(tree);
156+
157+
ASSERT_EQ(intervals.size(), 1);
158+
EXPECT_EQ(intervals[0], targetInterval);
159+
}
160+
161+
TEST_F(FindTests, CanOverlapFindAllOnConstTree)
162+
{
163+
const auto targetInterval = lib_interval_tree::make_safe_interval(16, 21);
164+
tree.insert(targetInterval);
165+
tree.insert({8, 9});
166+
tree.insert({25, 30});
167+
std::vector <decltype(tree)::interval_type> intervals;
168+
auto findWithConstTree = [&intervals, &targetInterval](auto const& tree)
169+
{
170+
tree.overlap_find_all(targetInterval, [&intervals](auto const& iter) {
171+
intervals.emplace_back(*iter);
172+
return true;
173+
});
174+
};
175+
findWithConstTree(tree);
176+
177+
ASSERT_EQ(intervals.size(), 1);
178+
EXPECT_EQ(intervals[0], targetInterval);
179+
}

0 commit comments

Comments
 (0)