From 35d4c4e8bd40ccc341730e4ea3a53b14358e6907 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 26 May 2017 10:20:32 +0800 Subject: [PATCH] updated testcase --- test/test_all.scad | 3 +- test/test_line2d.scad | 91 ++++++++++++++++++++++++++++++++ test/test_shape_path_extend.scad | 6 +-- 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 test/test_line2d.scad diff --git a/test/test_all.scad b/test/test_all.scad index 46242c9a..2095ec31 100644 --- a/test/test_all.scad +++ b/test/test_all.scad @@ -1,5 +1,6 @@ // 2D include ; +include ; // 2D Shape include ; @@ -9,4 +10,4 @@ include ; include ; include ; include ; -include ; +include ; \ No newline at end of file diff --git a/test/test_line2d.scad b/test/test_line2d.scad new file mode 100644 index 00000000..49a71efc --- /dev/null +++ b/test/test_line2d.scad @@ -0,0 +1,91 @@ +include ; + +module test_line2d_cap_square() { + echo("==== test_line2d_cap_square ===="); + + $fn = 24; + + p1 = [0, 0]; + p2 = [5, 0]; + width = 1; + + include ; + + module cap(point, style) { + assertTrue( + (point == p1 && style == "CAP_SQUARE") || + (point == p2 && style == "CAP_SQUARE") + ); + } + + module test_line2d_line(angle, length, width, frags) { + assertEqual(0, angle); + assertEqual(5, length); + assertEqual(1, width); + assertEqual(24, frags); + } + + line2d(p1 = p1, p2 = p2, width = width); +} + +module test_line2d_cap_round() { + echo("==== test_line2d_cap_round ===="); + + $fn = 24; + + p1 = [0, 0]; + p2 = [5, 0]; + width = 1; + + include ; + + module cap(point, style) { + assertTrue( + (point == p1 && style == "CAP_ROUND") || + (point == p2 && style == "CAP_ROUND") + ); + } + + module test_line2d_line(angle, length, width, frags) { + assertEqual(0, angle); + assertEqual(5, length); + assertEqual(1, width); + assertEqual(24, frags); + } + + line2d(p1 = p1, p2 = p2, width = width, + p1Style = "CAP_ROUND", p2Style = "CAP_ROUND"); +} + +module test_line2d_cap_butt() { + echo("==== test_line2d_cap_butt ===="); + + $fn = 24; + + p1 = [0, 0]; + p2 = [5, 0]; + width = 1; + + include ; + + module cap(point, style) { + assertTrue( + (point == p1 && style == "CAP_BUTT") || + (point == p2 && style == "CAP_BUTT") + ); + } + + module test_line2d_line(angle, length, width, frags) { + assertEqual(0, angle); + assertEqual(5, length); + assertEqual(1, width); + assertEqual(24, frags); + } + + line2d(p1 = p1, p2 = p2, width = width, + p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); +} + +test_line2d_cap_square(); +test_line2d_cap_round(); +test_line2d_cap_butt(); \ No newline at end of file diff --git a/test/test_shape_path_extend.scad b/test/test_shape_path_extend.scad index 26f31fce..6cd43257 100644 --- a/test/test_shape_path_extend.scad +++ b/test/test_shape_path_extend.scad @@ -5,11 +5,10 @@ include ; include ; include ; -$fn = 96; - module test_shape_path_extend_stroke1() { echo("==== test_shape_path_extend_stroke1 ===="); + $fn = 96; stroke1 = [[-5, 2.5], [-2.5, 0], [0, 2.5], [2.5, 0], [5, 2.5]]; path_pts1 = circle_path(50, 60); @@ -22,7 +21,8 @@ module test_shape_path_extend_stroke1() { module test_shape_path_extend_stroke2() { echo("==== test_shape_path_extend_stroke2 ===="); - + + $fn = 96; stroke2 = [[-4, 0], [0, 4], [4, 0]]; pts_angles = archimedean_spiral( arm_distance = 17,