2017-05-26 10:20:32 +08:00
|
|
|
include <unittest.scad>;
|
|
|
|
|
2017-05-26 10:22:23 +08:00
|
|
|
module test_line2d() {
|
2017-05-26 10:20:32 +08:00
|
|
|
$fn = 24;
|
|
|
|
p1 = [0, 0];
|
|
|
|
p2 = [5, 0];
|
|
|
|
width = 1;
|
2017-05-26 10:22:23 +08:00
|
|
|
|
|
|
|
module test_line2d_cap_square() {
|
|
|
|
echo("==== test_line2d_cap_square ====");
|
|
|
|
|
|
|
|
include <line2d.scad>;
|
|
|
|
|
2017-05-26 10:26:30 +08:00
|
|
|
module test_line2d_cap(point, style) {
|
2019-06-11 13:49:31 +08:00
|
|
|
assert(
|
2017-05-26 10:22:23 +08:00
|
|
|
(point == p1 && style == "CAP_SQUARE") ||
|
|
|
|
(point == p2 && style == "CAP_SQUARE")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module test_line2d_line(angle, length, width, frags) {
|
2019-06-11 14:32:21 +08:00
|
|
|
assertEqualNum(0, angle);
|
|
|
|
assertEqualNum(5, length);
|
|
|
|
assertEqualNum(1, width);
|
|
|
|
assertEqualNum(24, frags);
|
2017-05-26 10:22:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
line2d(p1 = p1, p2 = p2, width = width);
|
2017-05-26 10:20:32 +08:00
|
|
|
}
|
|
|
|
|
2017-05-26 10:22:23 +08:00
|
|
|
module test_line2d_cap_round() {
|
|
|
|
echo("==== test_line2d_cap_round ====");
|
2017-05-26 10:20:32 +08:00
|
|
|
|
2017-05-26 10:22:23 +08:00
|
|
|
include <line2d.scad>;
|
2017-05-26 10:20:32 +08:00
|
|
|
|
2017-05-26 10:26:30 +08:00
|
|
|
module test_line2d_cap(point, style) {
|
2019-06-11 13:49:31 +08:00
|
|
|
assert(
|
2017-05-26 10:22:23 +08:00
|
|
|
(point == p1 && style == "CAP_ROUND") ||
|
|
|
|
(point == p2 && style == "CAP_ROUND")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module test_line2d_line(angle, length, width, frags) {
|
2019-06-11 14:32:21 +08:00
|
|
|
assertEqualNum(0, angle);
|
|
|
|
assertEqualNum(5, length);
|
|
|
|
assertEqualNum(1, width);
|
|
|
|
assertEqualNum(24, frags);
|
2017-05-26 10:22:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
line2d(p1 = p1, p2 = p2, width = width,
|
|
|
|
p1Style = "CAP_ROUND", p2Style = "CAP_ROUND");
|
|
|
|
}
|
2017-05-26 10:20:32 +08:00
|
|
|
|
2017-05-26 10:22:23 +08:00
|
|
|
module test_line2d_cap_butt() {
|
|
|
|
echo("==== test_line2d_cap_butt ====");
|
|
|
|
|
|
|
|
include <line2d.scad>;
|
2017-05-26 10:20:32 +08:00
|
|
|
|
2017-05-26 10:26:30 +08:00
|
|
|
module test_line2d_cap(point, style) {
|
2019-06-11 13:49:31 +08:00
|
|
|
assert(
|
2017-05-26 10:22:23 +08:00
|
|
|
(point == p1 && style == "CAP_BUTT") ||
|
|
|
|
(point == p2 && style == "CAP_BUTT")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module test_line2d_line(angle, length, width, frags) {
|
2019-06-11 14:32:21 +08:00
|
|
|
assertEqualNum(0, angle);
|
|
|
|
assertEqualNum(5, length);
|
|
|
|
assertEqualNum(1, width);
|
|
|
|
assertEqualNum(24, frags);
|
2017-05-26 10:22:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2017-05-26 10:20:32 +08:00
|
|
|
}
|
|
|
|
|
2017-05-26 10:22:23 +08:00
|
|
|
test_line2d();
|
|
|
|
|