Skip to content

Commit ee7d8e1

Browse files
author
Marc Kramer
committed
Add TouchingHolestest
1 parent 141ade3 commit ee7d8e1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

unittest/main.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,46 @@ BOOST_AUTO_TEST_CASE(PolygonTest04)
223223
}
224224
}
225225

226+
BOOST_AUTO_TEST_CASE(TouchingHolestest)
227+
{
228+
std::vector<p2t::Point*> polyline{
229+
new p2t::Point(0, 0),
230+
new p2t::Point(1, 0),
231+
new p2t::Point(0.5, 1),
232+
};
233+
auto p2t_Point_02_02 = p2t::Point(0.2, 0.2);
234+
std::vector<p2t::Point*> hole0 {
235+
new p2t::Point(0.1, 0.1),
236+
new p2t::Point(0.2, 0.1),
237+
&p2t_Point_02_02,
238+
};
239+
std::vector<p2t::Point*> hole1 {
240+
&p2t_Point_02_02,
241+
new p2t::Point(0.3, 0.2),
242+
new p2t::Point(0.3, 0.3),
243+
};
244+
p2t::CDT cdt{ polyline };
245+
cdt.AddHole(hole0);
246+
cdt.AddHole(hole1);
247+
BOOST_CHECK_NO_THROW(cdt.Triangulate());
248+
const auto result = cdt.GetTriangles();
249+
BOOST_REQUIRE_EQUAL(result.size(), 9);
250+
BOOST_CHECK(p2t::IsDelaunay(result));
251+
for (const auto p : polyline) {
252+
delete p;
253+
}
254+
for (const auto p : hole0) {
255+
if (p != &p2t_Point_02_02) {
256+
delete p;
257+
}
258+
}
259+
for (const auto p : hole1) {
260+
if (p != &p2t_Point_02_02) {
261+
delete p;
262+
}
263+
}
264+
}
265+
226266
BOOST_AUTO_TEST_CASE(TestbedFilesTest)
227267
{
228268
for (const auto& filename : { "custom.dat", "diamond.dat", "star.dat", "test.dat" }) {

0 commit comments

Comments
 (0)