diff options
| author | nodist <kevin.comas.git@gmail.com> | 2026-11-13 16:28:13 -0500 |
|---|---|---|
| committer | nodist <kevin.comas.git@gmail.com> | 2026-11-13 16:28:13 -0500 |
| commit | c3d23d3091c23978b12c140e6cfd964eff1d3986 (patch) | |
| tree | 3342a73aea427fa19d2b0936a98e37fbe479c85d /test/gc.c | |
| parent | 75c8828d804f45cf8f44af73bfe87e0f3eaf9a9e (diff) | |
Diffstat (limited to 'test/gc.c')
| -rw-r--r-- | test/gc.c | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/test/gc.c b/test/gc.c deleted file mode 100644 index 6834ad2..0000000 --- a/test/gc.c +++ /dev/null @@ -1,34 +0,0 @@ - -#include "kpl_test.h" - -#define TEST_OBJECT_COUNT 10 - -KPL_TEST(basic_mark_and_sweep) { - kpl_thread thread = {}; - kpl_memory_allocator_init(&thread.memory_allocator); - kpl_gc_init(&thread.gc); - kpl_object *objs[TEST_OBJECT_COUNT] = {}; - for (int32_t obj_index = 1; obj_index <= TEST_OBJECT_COUNT; obj_index++) { - objs[obj_index - 1] = kpl_gc_new(&thread, NULL, sizeof(kpl_object_error)); - if (obj_index % 2 == 0) - kpl_gc_mark(objs[obj_index - 1]->object_gc_parent); - } - int32_t counter = 0; - kpl_object_gc *gc_head = thread.gc.gc_head; - while (gc_head) { - counter++; - gc_head = gc_head->gc_next; - } - KPL_ASSERT(counter == TEST_OBJECT_COUNT, "should have TEST_OBJECT_COUNT Objects in gc list"); - kpl_gc_prepare_sweep(&thread.gc); - kpl_gc_sweep(&thread); - gc_head = thread.gc.gc_head; - counter = 0; - while (gc_head) { - counter++; - gc_head = gc_head->gc_next; - } - KPL_ASSERT(counter == TEST_OBJECT_COUNT / 2, "should have removed half of the objects"); - kpl_gc_free(&thread); - kpl_memory_allocator_free(&thread.memory_allocator); -} |
