test/test_list.c

changeset 435
0fe204d50f54
parent 422
afd87df80b13
child 438
cd3069757010
equal deleted inserted replaced
434:38ee262e8b94 435:0fe204d50f54
38 void test_linked_list_create() { 38 void test_linked_list_create() {
39 cxTestingAllocatorReset(); 39 cxTestingAllocatorReset();
40 40
41 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); 41 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
42 42
43 CU_ASSERT_EQUAL(list->data.size, 0) 43 CU_ASSERT_EQUAL(list->size, 0)
44 CU_ASSERT_EQUAL(list->data.capacity, (size_t) -1) 44 CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
45 CU_ASSERT_PTR_EQUAL(list->data.allocator, cxTestingAllocator) 45 CU_ASSERT_PTR_EQUAL(list->allocator, cxTestingAllocator)
46 CU_ASSERT_EQUAL(list->data.itemsize, sizeof(int)) 46 CU_ASSERT_EQUAL(list->itemsize, sizeof(int))
47 CU_ASSERT_PTR_EQUAL(list->data.cmpfunc, cmp_int) 47 CU_ASSERT_PTR_EQUAL(list->cmpfunc, cmp_int)
48 48
49 struct node { 49 // assume this structure for a linked list
50 struct ll_check {
51 cx_list_s base;
50 void *begin; 52 void *begin;
51 void *end; 53 void *end;
52 ptrdiff_t ploc; 54 ptrdiff_t ploc;
53 ptrdiff_t nloc; 55 ptrdiff_t nloc;
54 }; 56 };
55 57
56 struct node *actual = (struct node *) list->data.listdata; 58 struct ll_check *actual = (struct ll_check *) list;
57 CU_ASSERT_PTR_NULL(actual->begin) 59 CU_ASSERT_PTR_NULL(actual->begin)
58 CU_ASSERT_PTR_NULL(actual->end) 60 CU_ASSERT_PTR_NULL(actual->end)
59 CU_ASSERT_EQUAL(0, actual->ploc) 61 CU_ASSERT_EQUAL(0, actual->ploc)
60 CU_ASSERT_EQUAL(sizeof(void *), actual->nloc) 62 CU_ASSERT_EQUAL(sizeof(void *), actual->nloc)
61 63

mercurial