test/test_list.c

changeset 500
eb9e7bd40a8e
parent 499
3dc9075df822
child 503
a89857072ace
     1.1 --- a/test/test_list.c	Sat Jan 29 14:32:04 2022 +0100
     1.2 +++ b/test/test_list.c	Sun Jan 30 14:19:00 2022 +0100
     1.3 @@ -560,7 +560,7 @@
     1.4  void test_hl_linked_list_create(void) {
     1.5      cxTestingAllocatorReset();
     1.6  
     1.7 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
     1.8 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
     1.9  
    1.10      CU_ASSERT_EQUAL(list->size, 0)
    1.11      CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
    1.12 @@ -575,7 +575,7 @@
    1.13  void test_hl_ptr_linked_list_create(void) {
    1.14      cxTestingAllocatorReset();
    1.15  
    1.16 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    1.17 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    1.18  
    1.19      CU_ASSERT_EQUAL(list->size, 0)
    1.20      CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
    1.21 @@ -592,10 +592,10 @@
    1.22  
    1.23      int data[] = {2, 4, 5, 7, 10, 15};
    1.24  
    1.25 -    CxList expected = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    1.26 +    CxList *expected = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    1.27      for (int i = 0; i < 5; i++) cxListAdd(expected, &data[i]);
    1.28  
    1.29 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 5, data);
    1.30 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 5, data);
    1.31  
    1.32      CU_ASSERT_TRUE(0 == cxListCompare(list, expected))
    1.33  
    1.34 @@ -608,7 +608,7 @@
    1.35      cxTestingAllocatorReset();
    1.36  
    1.37      int data;
    1.38 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    1.39 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    1.40  
    1.41      data = 5;
    1.42      CU_ASSERT_EQUAL(cxListAdd(list, &data), 0)
    1.43 @@ -621,7 +621,7 @@
    1.44      CU_ASSERT_TRUE(list->capacity >= list->size)
    1.45  
    1.46      int exp[] = {5, 47, 13};
    1.47 -    CxList expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 3, exp);
    1.48 +    CxList *expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 3, exp);
    1.49      CU_ASSERT_TRUE(0 == cxListCompare(list, expected))
    1.50  
    1.51      cxLinkedListDestroy(list);
    1.52 @@ -632,7 +632,7 @@
    1.53  void test_hl_ptr_linked_list_add(void) {
    1.54      cxTestingAllocatorReset();
    1.55  
    1.56 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    1.57 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    1.58  
    1.59      int a = 5, b = 47, c = 13;
    1.60  
    1.61 @@ -663,7 +663,7 @@
    1.62      cxTestingAllocatorReset();
    1.63  
    1.64      int data;
    1.65 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    1.66 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
    1.67  
    1.68      data = 5;
    1.69      CU_ASSERT_NOT_EQUAL(cxListInsert(list, 1, &data), 0)
    1.70 @@ -683,7 +683,7 @@
    1.71      CU_ASSERT_TRUE(list->capacity >= list->size)
    1.72  
    1.73      int exp[] = {47, 13, 5, 42};
    1.74 -    CxList expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 4, exp);
    1.75 +    CxList *expected = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 4, exp);
    1.76      CU_ASSERT_TRUE(0 == cxListCompare(list, expected))
    1.77  
    1.78      cxLinkedListDestroy(list);
    1.79 @@ -694,7 +694,7 @@
    1.80  void test_hl_ptr_linked_list_insert(void) {
    1.81      cxTestingAllocatorReset();
    1.82  
    1.83 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    1.84 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
    1.85  
    1.86      int a = 5, b = 47, c = 13, d = 42;
    1.87  
    1.88 @@ -724,8 +724,8 @@
    1.89      cxTestingAllocatorReset();
    1.90  
    1.91      int data[] = {5, 47, 42, 13};
    1.92 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
    1.93 -                                        sizeof(int), 4, data);
    1.94 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
    1.95 +                                         sizeof(int), 4, data);
    1.96  
    1.97      CU_ASSERT_EQUAL(list->size, 4)
    1.98      CU_ASSERT_TRUE(list->capacity >= list->size)
    1.99 @@ -764,7 +764,7 @@
   1.100      cxTestingAllocatorReset();
   1.101  
   1.102      int a = 5, b = 47, c = 42, d = 13;
   1.103 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.104 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.105  
   1.106      cxListAdd(list, &a);
   1.107      cxListAdd(list, &b);
   1.108 @@ -808,8 +808,8 @@
   1.109      cxTestingAllocatorReset();
   1.110  
   1.111      int data[] = {5, 47, 13};
   1.112 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   1.113 -                                        sizeof(int), 3, data);
   1.114 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   1.115 +                                         sizeof(int), 3, data);
   1.116  
   1.117      CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5)
   1.118      CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47)
   1.119 @@ -823,7 +823,7 @@
   1.120  void test_hl_ptr_linked_list_at(void) {
   1.121      cxTestingAllocatorReset();
   1.122  
   1.123 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.124 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.125  
   1.126      int a = 5, b = 47, c = 13;
   1.127      cxListAdd(list, &a);
   1.128 @@ -843,8 +843,8 @@
   1.129      cxTestingAllocatorReset();
   1.130  
   1.131      int data[] = {5, 47, 13};
   1.132 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   1.133 -                                        sizeof(int), 3, data);
   1.134 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int,
   1.135 +                                         sizeof(int), 3, data);
   1.136      CU_ASSERT_EQUAL(list->size, 3)
   1.137      CU_ASSERT_TRUE(list->capacity >= list->size)
   1.138  
   1.139 @@ -869,7 +869,7 @@
   1.140      cxTestingAllocatorReset();
   1.141  
   1.142      int a = 5, b = 47, c = 13, criteria;
   1.143 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.144 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.145  
   1.146      cxListAdd(list, &a);
   1.147      cxListAdd(list, &b);
   1.148 @@ -915,8 +915,8 @@
   1.149  
   1.150      cxTestingAllocatorReset();
   1.151  
   1.152 -    CxList list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, scrambled);
   1.153 -    CxList exp = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, expected);
   1.154 +    CxList *list = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, scrambled);
   1.155 +    CxList *exp = cxLinkedListFromArray(cxTestingAllocator, cmp_int, sizeof(int), 100, expected);
   1.156  
   1.157      cxListSort(list);
   1.158      CU_ASSERT_TRUE(0 == cxListCompare(list, exp))
   1.159 @@ -946,7 +946,7 @@
   1.160  
   1.161      cxTestingAllocatorReset();
   1.162  
   1.163 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.164 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.165  
   1.166      for (int i = 0; i < 100; i++) {
   1.167          cxListAdd(list, &scrambled[i]);
   1.168 @@ -962,7 +962,7 @@
   1.169      CU_ASSERT_TRUE(cxTestingAllocatorVerify())
   1.170  }
   1.171  
   1.172 -void test_hl_linked_list_iterator_impl(CxList list) {
   1.173 +void test_hl_linked_list_iterator_impl(CxList *list) {
   1.174      int i = 0;
   1.175      CxIterator iter = cxListBegin(list);
   1.176      cx_foreach(int*, x, iter) {
   1.177 @@ -984,7 +984,7 @@
   1.178  
   1.179  void test_hl_linked_list_iterator(void) {
   1.180      cxTestingAllocatorReset();
   1.181 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   1.182 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   1.183      for (int i = 0; i < 10; i++) {
   1.184          cxListAdd(list, &i);
   1.185      }
   1.186 @@ -993,7 +993,7 @@
   1.187  
   1.188  void test_hl_ptr_linked_list_iterator(void) {
   1.189      cxTestingAllocatorReset();
   1.190 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.191 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.192      int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
   1.193      for (int i = 0; i < 10; i++) {
   1.194          cxListAdd(list, &data[i]);
   1.195 @@ -1003,7 +1003,7 @@
   1.196  
   1.197  void test_hl_linked_list_insert_via_iterator(void) {
   1.198      cxTestingAllocatorReset();
   1.199 -    CxList list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   1.200 +    CxList *list = cxLinkedListCreate(cxTestingAllocator, cmp_int, sizeof(int));
   1.201      for (int i = 0; i < 5; i++) {
   1.202          cxListAdd(list, &i);
   1.203      }
   1.204 @@ -1037,8 +1037,8 @@
   1.205      CU_ASSERT_FALSE(cxIteratorValid(&iter))
   1.206  
   1.207      int expdata[] = {30, 0, 1, 20, 2, 10, 3, 4, 40, 50};
   1.208 -    CxList expected = cxLinkedListFromArray(cxTestingAllocator,
   1.209 -                                            cmp_int, sizeof(int), 10, expdata);
   1.210 +    CxList *expected = cxLinkedListFromArray(cxTestingAllocator,
   1.211 +                                             cmp_int, sizeof(int), 10, expdata);
   1.212  
   1.213      CU_ASSERT_EQUAL(0, cxListCompare(list, expected))
   1.214      cxLinkedListDestroy(list);
   1.215 @@ -1049,7 +1049,7 @@
   1.216  void test_hl_ptr_linked_list_insert_via_iterator(void) {
   1.217      int testdata[] = {0, 1, 2, 3, 4, 10, 20, 30, 40, 50};
   1.218      cxTestingAllocatorReset();
   1.219 -    CxList list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.220 +    CxList *list = cxPointerLinkedListCreate(cxTestingAllocator, cmp_int);
   1.221      int i;
   1.222      for (i = 0; i < 5; i++) {
   1.223          cxListAdd(list, &testdata[i]);

mercurial