1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-04-20 14:11:52 +02:00

added test_hexagons

This commit is contained in:
Justin Lin 2017-05-29 18:40:38 +08:00
parent 5fa543fcab
commit d59cfe5b48
2 changed files with 67 additions and 0 deletions

View File

@ -3,6 +3,7 @@ include <test_rounded_square.scad>;
include <test_line2d.scad>;
include <test_polyline2d.scad>;
include <test_hull_polyline2d.scad>;
include <test_hexagons.scad>;
// 2D Shape
include <test_shape_arc.scad>;

66
test/test_hexagons.scad Normal file
View File

@ -0,0 +1,66 @@
include <unittest.scad>;
module test_hexagons_lv2() {
echo("==== test_hexagons_lv2 ====");
radius = 20;
spacing = 2;
levels = 2;
include <hexagons.scad>;
module test_each_hexagon(hex_r, pts_all_lines) {
assertEqual(19, hex_r);
expects = [
[[-34.641, 0], [0, 0], [34.641, 0]],
[[-17.3205, 30], [17.3205, 30]],
[[-17.3205, -30], [17.3205, -30]]
];
for(i = [0:len(pts_all_lines) - 1]) {
assertEqualPoints(
expects[i],
pts_all_lines[i]
);
}
}
hexagons(radius, spacing, levels);
}
module test_hexagons_lv3() {
echo("==== test_hexagons_lv3 ====");
radius = 20;
spacing = 2;
levels = 3;
include <hexagons.scad>;
module test_each_hexagon(hex_r, pts_all_lines) {
assertEqual(19, hex_r);
expects = [
[[-69.282, 0], [-34.641, 0], [0, 0], [34.641, 0], [69.282, 0]],
[[-51.9615, 30], [-17.3205, 30], [17.3205, 30], [51.9615, 30]],
[[-34.641, 60], [0, 60], [34.641, 60]],
[[-51.9615, -30], [-17.3205, -30], [17.3205, -30], [51.9615, -30]],
[[-34.641, -60], [0, -60], [34.641, -60]]
];
for(i = [0:len(pts_all_lines) - 1]) {
assertEqualPoints(
expects[i],
pts_all_lines[i]
);
}
}
hexagons(radius, spacing, levels);
}
test_hexagons_lv2();
test_hexagons_lv3();