aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gc.c5
-rw-r--r--test/string.c14
2 files changed, 15 insertions, 4 deletions
diff --git a/test/gc.c b/test/gc.c
index 2af29d3..6834ad2 100644
--- a/test/gc.c
+++ b/test/gc.c
@@ -4,10 +4,7 @@
#define TEST_OBJECT_COUNT 10
KPL_TEST(basic_mark_and_sweep) {
- kpl_env env = {};
- kpl_thread thread = { .env = &env };
- kpl_thread *threads = { &thread };
- env.threads = threads;
+ kpl_thread thread = {};
kpl_memory_allocator_init(&thread.memory_allocator);
kpl_gc_init(&thread.gc);
kpl_object *objs[TEST_OBJECT_COUNT] = {};
diff --git a/test/string.c b/test/string.c
new file mode 100644
index 0000000..8a6742c
--- /dev/null
+++ b/test/string.c
@@ -0,0 +1,14 @@
+
+#include "kpl_test.h"
+
+KPL_TEST(string_init) {
+ kpl_thread thread = {};
+ const char *c_string = "test string\n";
+ kpl_memory_allocator_init(&thread.memory_allocator);
+ kpl_gc_init(&thread.gc);
+ kpl_object_string *string = kpl_object_string_from_c_string(&thread, c_string);
+ KPL_ASSERT(string->bytes_length == (int32_t) strlen(c_string), "string should have same length as c string");
+ KPL_ASSERT(strcmp(c_string, (char*) string->bytes) == 0, "new string should equal c string");
+ kpl_gc_free(&thread);
+ kpl_memory_allocator_free(&thread.memory_allocator);
+}