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

add hashmap del get

This commit is contained in:
Justin Lin
2021-03-06 15:40:16 +08:00
parent e27759e8ed
commit 19a02d8f2b
3 changed files with 38 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ use <collection/hashmap.scad>;
use <collection/hashmap_list.scad>;
use <collection/hashmap_add.scad>;
use <collection/hashmap_len.scad>;
use <collection/hashmap_del.scad>;
use <collection/hashmap_get.scad>;
module test_hashmap() {
echo("==== test_hashmap ====");
@@ -23,6 +25,13 @@ module test_hashmap() {
s3 = hashmap_add(s2, "k5678", 200);
assert(hashmap_list(s3) == [["k9876", 3], ["k4444", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]);
s4 = hashmap_del(s3, "k4444");
assert(hashmap_list(s4) == [["k9876", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]);
assert(hashmap_list(hashmap_del(s4, "k4444")) == [["k9876", 3], ["k1234", 1], ["k5678", 200], ["k1357", 100]]);
assert(hashmap_get(s4, "k1234") == 1);
assert(hashmap_get(s4, "k0000") == undef);
}
test_hashmap();