diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 17:52:13 -0500 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 17:52:13 -0500 |
| commit | d22ffffb379ebda21bf792bf18ed9e1324e8902b (patch) | |
| tree | 66bcf18b5ef63dd6bae4b5b40c2a4c44063cc8c1 | |
| parent | e2ed079d559a65ca868f5b400c4eb1cd1077a301 (diff) | |
| download | liballoc-d22ffffb379ebda21bf792bf18ed9e1324e8902b.tar.gz | |
tests: added test to validate the emptying of the free list
| -rw-r--r-- | tests/liballoc_tests.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/liballoc_tests.c b/tests/liballoc_tests.c index ad45636..6e6b537 100644 --- a/tests/liballoc_tests.c +++ b/tests/liballoc_tests.c @@ -68,6 +68,23 @@ START_TEST(basic_release) { } END_TEST +START_TEST(free_list_emptying) { + void *memory = allocate(ALIGNMENT * 3); + ck_assert_ptr_nonnull(memory); + + release(memory); + + free_nd *list_head = free_list_head(); + ck_assert_ptr_nonnull(list_head); + ck_assert_ptr_eq(list_head, memory); + ck_assert_int_eq(list_head->size, ALIGNMENT*3); + ck_assert_ptr_null(list_head->next); + + void *memory2 = allocate(ALIGNMENT *3); + ck_assert_ptr_eq(memory, memory2); + ck_assert_ptr_null(free_list_head()); +} + START_TEST(release_null) { /* releasing NULL should take no action */ release(NULL); @@ -186,6 +203,7 @@ Suite *liballoc_suite(void) { tcase_add_test(unit, unaligned_allocation); tcase_add_test(unit, basic_release); tcase_add_test(unit, release_null); + tcase_add_test(unit, free_list_emptying); tcase_add_test(unit, free_list_reuse); tcase_add_test(unit, free_list_coalesce_forward); tcase_add_test(unit, free_list_coalesce_backward); |