1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-27 08:25:45 +02:00

add hashmap add len list

This commit is contained in:
Justin Lin
2021-03-06 10:00:11 +08:00
parent 65c7ba3ae2
commit 1cd2af5760
7 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
use <unittest.scad>;
use <collection/hashmap.scad>;
use <collection/hashmap_list.scad>;
use <collection/hashmap_add.scad>;
use <collection/hashmap_len.scad>;
module test_hashmap() {
echo("==== test_hashmap ====");
s = hashmap([
["k1234", 1],
["k5678", 2],
["k9876", 3],
["k4444", 3],
]);
assert(hashmap_len(s) == 4);
assert(hashmap_list(s) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 2]]);
s2 = hashmap_add(s, "k1357", 100);
assert(hashmap_list(s2) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 2], ["k1357", 100]]);
s3 = hashmap_add(s2, "k5678", 200);
assert(hashmap_list(s3) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]);
}
test_hashmap();