From 3ad03be311736618fdbc0cfe748e437d3adbd242 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 27 Jan 2020 15:10:29 +0800 Subject: [PATCH] refactor testcase --- test/test_line2d.scad | 88 +++++++++---------------------------------- 1 file changed, 18 insertions(+), 70 deletions(-) diff --git a/test/test_line2d.scad b/test/test_line2d.scad index a5e70b3b..3c6be6e7 100644 --- a/test/test_line2d.scad +++ b/test/test_line2d.scad @@ -1,4 +1,5 @@ include ; +include ; module test_line2d() { $fn = 24; @@ -6,77 +7,24 @@ module test_line2d() { p2 = [5, 0]; width = 1; - module test_line2d_cap_square() { - echo("==== test_line2d_cap_square ===="); - - include ; - - module test_line2d_cap(point, style) { - assert( - (point == p1 && style == "CAP_SQUARE") || - (point == p2 && style == "CAP_SQUARE") - ); - } - - module test_line2d_line(angle, length, width, frags) { - assertEqualNum(0, angle); - assertEqualNum(5, length); - assertEqualNum(1, width); - assertEqualNum(24, frags); - } - - line2d(p1 = p1, p2 = p2, width = width); + echo("==== test_line2d_cap_square ===="); + + + module test_line2d_cap(point, style) { + assert( + (point == p1 && style == "CAP_SQUARE") || + (point == p2 && style == "CAP_SQUARE") + ); } - - module test_line2d_cap_round() { - echo("==== test_line2d_cap_round ===="); - - include ; - - module test_line2d_cap(point, style) { - assert( - (point == p1 && style == "CAP_ROUND") || - (point == p2 && style == "CAP_ROUND") - ); - } - - module test_line2d_line(angle, length, width, frags) { - assertEqualNum(0, angle); - assertEqualNum(5, length); - assertEqualNum(1, width); - assertEqualNum(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 ===="); - - include ; - - module test_line2d_cap(point, style) { - assert( - (point == p1 && style == "CAP_BUTT") || - (point == p2 && style == "CAP_BUTT") - ); - } - - module test_line2d_line(angle, length, width, frags) { - assertEqualNum(0, angle); - assertEqualNum(5, length); - assertEqualNum(1, width); - assertEqualNum(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(); + + module test_line2d_line(angle, length, width, frags) { + assertEqualNum(0, angle); + assertEqualNum(5, length); + assertEqualNum(1, width); + assertEqualNum(24, frags); + } + + line2d(p1 = p1, p2 = p2, width = width); } test_line2d();