1.1 --- a/test/test_list.c Sun Sep 26 14:34:49 2021 +0200 1.2 +++ b/test/test_list.c Sun Sep 26 14:41:16 2021 +0200 1.3 @@ -28,6 +28,7 @@ 1.4 1.5 #include "cx/linked_list.h" 1.6 #include "test_config.h" 1.7 +#include "util_allocator.h" 1.8 1.9 int cmp_int(int const *l, int const *r) { 1.10 int left = *l, right = *r; 1.11 @@ -35,27 +36,32 @@ 1.12 } 1.13 1.14 void test_linked_list_create() { 1.15 - CxList list = cxLinkedListCreate(cxDefaultAllocator, (CxListComparator) cmp_int, sizeof(int)); 1.16 + cxTestingAllocatorReset(); 1.17 + 1.18 + CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); 1.19 1.20 CU_ASSERT_EQUAL(list->data.size, 0) 1.21 CU_ASSERT_EQUAL(list->data.capacity, (size_t) -1) 1.22 - CU_ASSERT_PTR_EQUAL(list->data.allocator, cxDefaultAllocator) 1.23 + CU_ASSERT_PTR_EQUAL(list->data.allocator, cxTestingAllocator) 1.24 CU_ASSERT_EQUAL(list->data.itemsize, sizeof(int)) 1.25 CU_ASSERT_PTR_EQUAL(list->data.cmpfunc, cmp_int) 1.26 1.27 struct node { 1.28 - void* begin; void* end; ptrdiff_t ploc; ptrdiff_t nloc; 1.29 + void *begin; 1.30 + void *end; 1.31 + ptrdiff_t ploc; 1.32 + ptrdiff_t nloc; 1.33 }; 1.34 1.35 - struct node* actual = (struct node*) list->data.listdata; 1.36 + struct node *actual = (struct node *) list->data.listdata; 1.37 CU_ASSERT_PTR_NULL(actual->begin) 1.38 CU_ASSERT_PTR_NULL(actual->end) 1.39 CU_ASSERT_EQUAL(0, actual->ploc) 1.40 - CU_ASSERT_EQUAL(sizeof(void*), actual->nloc) 1.41 + CU_ASSERT_EQUAL(sizeof(void *), actual->nloc) 1.42 1.43 cxLinkedListDestroy(list); 1.44 1.45 - // TODO: use allocator that keeps track of the freed memory 1.46 + CU_ASSERT_TRUE(cxTestingAllocatorVerify()) 1.47 } 1.48 1.49 int main() {