| @@ -0,0 +1,3 @@ | |||
| [submodule "test/snow"] | |||
| path = test/snow | |||
| url = git@github.com:mortie/snow.git | |||
| @@ -0,0 +1,3 @@ | |||
| /.cache | |||
| /bx-out | |||
| /compile_commands.json | |||
| @@ -0,0 +1,5 @@ | |||
| files := src ../lib | |||
| includes := snow ../include/lang2 | |||
| defines := SNOW_ENABLED | |||
| sanitizers := address | |||
| cflags := -g -O3 | |||
| @@ -0,0 +1 @@ | |||
| Subproject commit 54362df837dee70cd6e22c7cd1ef3c6dfea47122 | |||
| @@ -0,0 +1,3 @@ | |||
| #include <snow/snow.h> | |||
| snow_main(); | |||
| @@ -0,0 +1,38 @@ | |||
| #include "vm/vm.h" | |||
| #include <snow/snow.h> | |||
| describe(l2_vm_namespace) { | |||
| struct l2_vm_value val = {0}; | |||
| after_each() { | |||
| free(val.data); | |||
| val.data = NULL; | |||
| } | |||
| test("basic functionality") { | |||
| l2_vm_namespace_set(&val, 100, 50); | |||
| l2_vm_namespace_set(&val, 30, 600); | |||
| asserteq(l2_vm_namespace_get(&val, 100), 50); | |||
| asserteq(l2_vm_namespace_get(&val, 30), 600); | |||
| } | |||
| it("handles duplicates") { | |||
| l2_vm_namespace_set(&val, 536, 600); | |||
| l2_vm_namespace_set(&val, 100, 400); | |||
| l2_vm_namespace_set(&val, 536, 45); | |||
| asserteq(l2_vm_namespace_get(&val, 100), 400); | |||
| asserteq(l2_vm_namespace_get(&val, 536), 45); | |||
| } | |||
| it("handles a whole bunch of values") { | |||
| for (int i = 1; i < 500; ++i) { | |||
| l2_vm_namespace_set(&val, i, i + 50); | |||
| asserteq(l2_vm_namespace_get(&val, i), i + 50); | |||
| } | |||
| for (int i = 1; i < 500; ++i) { | |||
| asserteq(l2_vm_namespace_get(&val, i), i + 50); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,42 @@ | |||
| #include "strset.h" | |||
| #include <stdio.h> | |||
| #include <snow/snow.h> | |||
| describe(l2_strset) { | |||
| struct l2_strset set; | |||
| before_each() { | |||
| l2_strset_init(&set); | |||
| } | |||
| after_each() { | |||
| l2_strset_free(&set); | |||
| } | |||
| test("basic functionality") { | |||
| asserteq(l2_strset_put_copy(&set, "hello"), 1); | |||
| asserteq(l2_strset_put_copy(&set, "world"), 2); | |||
| asserteq(l2_strset_get(&set, "hello"), 1); | |||
| asserteq(l2_strset_get(&set, "world"), 2); | |||
| } | |||
| it("handles duplicates") { | |||
| asserteq(l2_strset_put_copy(&set, "hello"), 1); | |||
| asserteq(l2_strset_put_copy(&set, "hello"), 1); | |||
| asserteq(l2_strset_put_copy(&set, "world"), 2); | |||
| } | |||
| it("handles a whole bunch of values") { | |||
| char buf[128]; | |||
| for (int i = 0; i < 1000; ++i) { | |||
| sprintf(buf, "test-%d", i); | |||
| asserteq(l2_strset_put_copy(&set, buf), i + 1); | |||
| } | |||
| for (int i = 0; i < 1000; ++i) { | |||
| sprintf(buf, "test-%d", i); | |||
| asserteq(l2_strset_get(&set, buf), i + 1); | |||
| } | |||
| } | |||
| } | |||