diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-11-05 15:22:02 -0500 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-11-05 15:22:02 -0500 |
| commit | 7b9204a8680539bc4795a14f3d9a34e47981d0c3 (patch) | |
| tree | 7aa69bba0c9cbee0cafb638fd49af64958dbb228 /test/string.c | |
| parent | faa937cb09cd01f4ea94f5d7722a20e9c1246df0 (diff) | |
more objects and special slab for gc
Diffstat (limited to 'test/string.c')
| -rw-r--r-- | test/string.c | 14 |
1 files changed, 14 insertions, 0 deletions
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); +} |
