mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-30 01:03:30 +01:00
Add very simple unit test
This commit is contained in:
parent
1271d6b848
commit
a9d2cf8636
@ -8,3 +8,11 @@ lib = static_library('poly2tri', sources : [
|
|||||||
'poly2tri/sweep/sweep.cc',
|
'poly2tri/sweep/sweep.cc',
|
||||||
'poly2tri/sweep/sweep_context.cc',
|
'poly2tri/sweep/sweep_context.cc',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
thread_dep = dependency('threads')
|
||||||
|
boost_test_dep = dependency('boost', modules : [ 'unit_test_framework' ], required : false)
|
||||||
|
if boost_test_dep.found()
|
||||||
|
test('Unit Test', executable('unittest', [
|
||||||
|
'unittest/main.cpp',
|
||||||
|
], dependencies : [boost_test_dep, thread_dep], link_with : lib))
|
||||||
|
endif
|
||||||
|
19
unittest/main.cpp
Normal file
19
unittest/main.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#define BOOST_TEST_DYN_LINK
|
||||||
|
#define BOOST_TEST_MODULE Poly2triTest
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
#include <poly2tri/poly2tri.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(BasicTest) {
|
||||||
|
std::vector<p2t::Point*> polyline{
|
||||||
|
new p2t::Point(0, 0), new p2t::Point(1, 0), new p2t::Point(1, 1),
|
||||||
|
};
|
||||||
|
p2t::CDT cdt{polyline};
|
||||||
|
cdt.Triangulate();
|
||||||
|
const auto result = cdt.GetTriangles();
|
||||||
|
assert(result.size() == 1);
|
||||||
|
BOOST_CHECK_EQUAL(*result[0]->GetPoint(0), *polyline[0]);
|
||||||
|
BOOST_CHECK_EQUAL(*result[0]->GetPoint(1), *polyline[1]);
|
||||||
|
BOOST_CHECK_EQUAL(*result[0]->GetPoint(2), *polyline[2]);
|
||||||
|
result[0]->DebugPrint();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user