mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-07-30 19:40:24 +02:00
add tests
This commit is contained in:
@@ -62,6 +62,7 @@ include <test_sphere_spiral_extrude.scad>;
|
||||
include <test_path_extrude.scad>;
|
||||
|
||||
// Utilities
|
||||
|
||||
include <util/test_lerp.scad>;
|
||||
include <util/test_sub_str.scad>;
|
||||
include <util/test_split_str.scad>;
|
||||
@@ -82,6 +83,10 @@ include <util/set/test_hashset.scad>;
|
||||
include <util/map/test_hashmap.scad>;
|
||||
include <util/test_sorted.scad>;
|
||||
include <util/test_binary_search.scad>;
|
||||
include <util/test_contains.scad>;
|
||||
include <util/test_flat.scad>;
|
||||
include <util/test_sum.scad>;
|
||||
include <util/test_swap.scad>;
|
||||
|
||||
// Voxel
|
||||
include <voxel/test_vx_bezier.scad>;
|
||||
|
12
test/util/test_contains.scad
Normal file
12
test/util/test_contains.scad
Normal file
@@ -0,0 +1,12 @@
|
||||
use <voxel/vx_circle.scad>;
|
||||
use <util/contains.scad>;
|
||||
|
||||
module test_contains() {
|
||||
echo("==== test_contains ====");
|
||||
|
||||
pts = vx_circle(10);
|
||||
assert(contains(pts, [2, -10]));
|
||||
assert(!contains(pts, [0, 0]));
|
||||
}
|
||||
|
||||
test_contains();
|
28
test/util/test_flat.scad
Normal file
28
test/util/test_flat.scad
Normal file
@@ -0,0 +1,28 @@
|
||||
use <util/flat.scad>;
|
||||
|
||||
module test_flat() {
|
||||
echo("==== test_flat ====");
|
||||
vt = [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]];
|
||||
|
||||
assert(
|
||||
flat([1, 2, [3, 4]]) == [1, 2, 3, 4]
|
||||
);
|
||||
|
||||
assert(
|
||||
flat([[1, 2], [3, 4]]) == [1, 2, 3, 4]
|
||||
);
|
||||
|
||||
assert(
|
||||
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]) == [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
|
||||
);
|
||||
|
||||
assert(
|
||||
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]], 2) == [[1, 2], [3, 4], [5, 6], [7, 8]]
|
||||
);
|
||||
|
||||
assert(
|
||||
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]], 3) == [1, 2, 3, 4, 5, 6, 7, 8]
|
||||
);
|
||||
}
|
||||
|
||||
test_flat();
|
10
test/util/test_sum.scad
Normal file
10
test/util/test_sum.scad
Normal file
@@ -0,0 +1,10 @@
|
||||
use <util/sum.scad>;
|
||||
|
||||
module test_sum() {
|
||||
echo("==== test_sum ====");
|
||||
|
||||
assert(sum([1, 2, 3, 4, 5]) == 15);
|
||||
assert(sum([[1, 2, 3], [4, 5, 6]]) == [5, 7, 9]);
|
||||
}
|
||||
|
||||
test_sum();
|
9
test/util/test_swap.scad
Normal file
9
test/util/test_swap.scad
Normal file
@@ -0,0 +1,9 @@
|
||||
use <util/swap.scad>;
|
||||
|
||||
module test_swap() {
|
||||
echo("==== test_swap ====");
|
||||
|
||||
assert(swap([10, 20, 30, 40], 1, 3) == [10, 40, 30, 20]);
|
||||
}
|
||||
|
||||
test_swap();
|
Reference in New Issue
Block a user