From f9d609087d7057a10e28cfa56dd1171b2d47ec77 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 13 Jun 2019 20:19:09 +0800 Subject: [PATCH] add test case --- test/test_in_polyline.scad | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/test_in_polyline.scad diff --git a/test/test_in_polyline.scad b/test/test_in_polyline.scad new file mode 100644 index 00000000..6a247a9c --- /dev/null +++ b/test/test_in_polyline.scad @@ -0,0 +1,31 @@ +include ; + +module test_in_polyline() { + + + echo("==== test_in_polyline ===="); + + pts = [ + [0, 0], + [10, 0], + [10, 10] + ]; + + assert(!in_polyline(pts, [-2, -3])); + assert(in_polyline(pts, [5, 0])); + assert(in_polyline(pts, [10, 5])); + assert(!in_polyline(pts, [10, 15])); + + pts2 = [ + [10, 0, 10], + [20, 0, 10], + [20, 10, 10] + ]; + + assert(in_polyline(pts2, [10, 0, 10])); + assert(in_polyline(pts2, [15, 0, 10])); + assert(!in_polyline(pts2, [15, 1, 10])); + assert(!in_polyline(pts2, [20, 11, 10])); +} + +test_in_polyline(); \ No newline at end of file