aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/liballoc_tests.c18
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);