temporarily remove pointer lists - see #234

Mon, 23 Jan 2023 20:34:18 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 23 Jan 2023 20:34:18 +0100
changeset 639
309e8b08c60e
parent 638
eafb45eefc51
child 640
55cc3b373c5e

temporarily remove pointer lists - see #234

src/cx/linked_list.h file | annotate | diff | comparison | revisions
src/linked_list.c file | annotate | diff | comparison | revisions
test/test_list.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/cx/linked_list.h	Mon Jan 23 20:22:11 2023 +0100
     1.2 +++ b/src/cx/linked_list.h	Mon Jan 23 20:34:18 2023 +0100
     1.3 @@ -63,23 +63,6 @@
     1.4  ) __attribute__((__nonnull__));
     1.5  
     1.6  /**
     1.7 - * Allocates a linked list for storing pointers.
     1.8 - *
     1.9 - * If you want to store the elements directly in this list, use cxLinkedListCreate().
    1.10 - *
    1.11 - * @remark Since only pointers are stored in this list, a possible destructor
    1.12 - * MAY free the memory pointed to by its argument in order to prevent memory leaks.
    1.13 - *
    1.14 - * @param allocator the allocator for allocating the list nodes
    1.15 - * @param comparator the comparator for the elements
    1.16 - * @return the created list
    1.17 - */
    1.18 -CxList *cxPointerLinkedListCreate(
    1.19 -        CxAllocator const *allocator,
    1.20 -        CxListComparator comparator
    1.21 -) __attribute__((__nonnull__));
    1.22 -
    1.23 -/**
    1.24   * Finds the node at a certain index.
    1.25   *
    1.26   * This function can be used to start at an arbitrary position within the list.
    1.27 @@ -109,8 +92,6 @@
    1.28   * @param start a pointer to the start node
    1.29   * @param loc_advance the location of the pointer to advance
    1.30   * @param loc_data the location of the \c data pointer within your node struct
    1.31 - * @param follow_ptr \c false if the pointer denoted by \p loc_data shall be passed to the \p cmp_func.
    1.32 - * If \c true, the data at \p loc_data is assumed to be a pointer, dereferenced, and then passed to \p cmp_func.
    1.33   * @param cmp_func a compare function to compare \p elem against the node data
    1.34   * @param elem a pointer to the element to find
    1.35   * @return the index of the element or a past-one index if the element could not be found
    1.36 @@ -119,7 +100,6 @@
    1.37          void const *start,
    1.38          ptrdiff_t loc_advance,
    1.39          ptrdiff_t loc_data,
    1.40 -        bool follow_ptr,
    1.41          CxListComparator cmp_func,
    1.42          void const *elem
    1.43  ) __attribute__((__nonnull__));
    1.44 @@ -339,20 +319,13 @@
    1.45  /**
    1.46   * Sorts a linked list based on a comparison function.
    1.47   *
    1.48 - * This function can work with linked lists of the following structures:
    1.49 + * This function can work with linked lists of the following structure:
    1.50   * \code
    1.51   * typedef struct node node;
    1.52   * struct node {
    1.53   *   node* prev;
    1.54   *   node* next;
    1.55 - *   my_payload data; // in this case set follow_ptr = 0
    1.56 - * }
    1.57 - *
    1.58 - * typedef struct ptr_node ptr_node;
    1.59 - * struct ptr_node {
    1.60 - *   ptr_node* prev;
    1.61 - *   ptr_node* next;
    1.62 - *   my_payload* data; // in this case set follow_ptr = 1
    1.63 + *   my_payload data;
    1.64   * }
    1.65   * \endcode
    1.66   *
    1.67 @@ -363,8 +336,6 @@
    1.68   * @param loc_prev the location of a \c prev pointer within your node struct (negative if not present)
    1.69   * @param loc_next the location of a \c next pointer within your node struct (required)
    1.70   * @param loc_data the location of the \c data pointer within your node struct
    1.71 - * @param follow_ptr \c false if the pointer denoted by \p loc_data shall be passed to the \p cmp_func.
    1.72 - * If \c true, the data at \p loc_data is assumed to be a pointer, dereferenced, and then passed to \p cmp_func.
    1.73   * @param cmp_func the compare function defining the sort order
    1.74   */
    1.75  void cx_linked_list_sort(
    1.76 @@ -373,26 +344,19 @@
    1.77          ptrdiff_t loc_prev,
    1.78          ptrdiff_t loc_next,
    1.79          ptrdiff_t loc_data,
    1.80 -        bool follow_ptr,
    1.81          CxListComparator cmp_func
    1.82 -) __attribute__((__nonnull__(1, 7)));
    1.83 +) __attribute__((__nonnull__(1, 6)));
    1.84  
    1.85  
    1.86  /**
    1.87   * Compares two lists element wise.
    1.88   *
    1.89 - * The \c follow_ptr flags have the following meaning: if \c false, the pointer denoted by \p loc_data shall
    1.90 - * directly be passed to the \p cmp_func.
    1.91 - * If \c true, the data at \p loc_data is assumed to be a pointer, dereferenced, and then passed to \p cmp_func.
    1.92 - *
    1.93   * \note Both list must have the same structure.
    1.94   *
    1.95   * @param begin_left the begin of the left list (\c NULL denotes an empty list)
    1.96   * @param begin_right the begin of the right list  (\c NULL denotes an empty list)
    1.97   * @param loc_advance the location of the pointer to advance
    1.98   * @param loc_data the location of the \c data pointer within your node struct
    1.99 - * @param follow_ptr_left indicates whether pointers in the left list shall be dereferenced
   1.100 - * @param follow_ptr_right indicates whether pointers in the right list shall be dereferenced
   1.101   * @param cmp_func the function to compare the elements
   1.102   * @return the first non-zero result of invoking \p cmp_func or: negative if the left list is smaller than the
   1.103   * right list, positive if the left list is larger than the right list, zero if both lists are equal.
   1.104 @@ -402,10 +366,8 @@
   1.105          void const *begin_right,
   1.106          ptrdiff_t loc_advance,
   1.107          ptrdiff_t loc_data,
   1.108 -        bool follow_ptr_left,
   1.109 -        bool follow_ptr_right,
   1.110          CxListComparator cmp_func
   1.111 -) __attribute__((__nonnull__(7)));
   1.112 +) __attribute__((__nonnull__(5)));
   1.113  
   1.114  /**
   1.115   * Reverses the order of the nodes in a linked list.
     2.1 --- a/src/linked_list.c	Mon Jan 23 20:22:11 2023 +0100
     2.2 +++ b/src/linked_list.c	Mon Jan 23 20:34:18 2023 +0100
     2.3 @@ -38,8 +38,7 @@
     2.4  #define ll_prev(node) CX_LL_PTR(node, loc_prev)
     2.5  #define ll_next(node) CX_LL_PTR(node, loc_next)
     2.6  #define ll_advance(node) CX_LL_PTR(node, loc_advance)
     2.7 -#define ll_data_f(node, follow_ptr) ((follow_ptr)?CX_LL_PTR(node, loc_data):(((char*)(node))+loc_data))
     2.8 -#define ll_data(node) ll_data_f(node,follow_ptr)
     2.9 +#define ll_data(node) (((char*)(node))+loc_data)
    2.10  
    2.11  void *cx_linked_list_at(
    2.12          void const *start,
    2.13 @@ -62,7 +61,6 @@
    2.14          void const *start,
    2.15          ptrdiff_t loc_advance,
    2.16          ptrdiff_t loc_data,
    2.17 -        bool follow_ptr,
    2.18          CxListComparator cmp_func,
    2.19          void const *elem
    2.20  ) {
    2.21 @@ -286,7 +284,6 @@
    2.22          ptrdiff_t loc_prev,
    2.23          ptrdiff_t loc_next,
    2.24          ptrdiff_t loc_data,
    2.25 -        bool follow_ptr,
    2.26          size_t length,
    2.27          void *ls,
    2.28          void *le,
    2.29 @@ -343,7 +340,6 @@
    2.30          ptrdiff_t loc_prev,
    2.31          ptrdiff_t loc_next,
    2.32          ptrdiff_t loc_data,
    2.33 -        bool follow_ptr,
    2.34          CxListComparator cmp_func
    2.35  ) {
    2.36      assert(begin != NULL);
    2.37 @@ -378,17 +374,17 @@
    2.38          re = ll_next(rc);
    2.39  
    2.40          // {ls,...,le->prev} and {rs,...,re->prev} are sorted - merge them
    2.41 -        void *sorted = cx_linked_list_sort_merge(loc_prev, loc_next, loc_data, follow_ptr,
    2.42 +        void *sorted = cx_linked_list_sort_merge(loc_prev, loc_next, loc_data,
    2.43                                                   ln + rn, ls, le, re, cmp_func);
    2.44  
    2.45          // Something left? Sort it!
    2.46          size_t remainder_length = cx_linked_list_size(re, loc_next);
    2.47          if (remainder_length > 0) {
    2.48              void *remainder = re;
    2.49 -            cx_linked_list_sort(&remainder, NULL, loc_prev, loc_next, loc_data, follow_ptr, cmp_func);
    2.50 +            cx_linked_list_sort(&remainder, NULL, loc_prev, loc_next, loc_data, cmp_func);
    2.51  
    2.52              // merge sorted list with (also sorted) remainder
    2.53 -            *begin = cx_linked_list_sort_merge(loc_prev, loc_next, loc_data, follow_ptr,
    2.54 +            *begin = cx_linked_list_sort_merge(loc_prev, loc_next, loc_data,
    2.55                                                 ln + rn + remainder_length,
    2.56                                                 sorted, remainder, NULL, cmp_func);
    2.57          } else {
    2.58 @@ -404,15 +400,13 @@
    2.59          void const *begin_right,
    2.60          ptrdiff_t loc_advance,
    2.61          ptrdiff_t loc_data,
    2.62 -        bool follow_ptr_left,
    2.63 -        bool follow_ptr_right,
    2.64          CxListComparator cmp_func
    2.65  ) {
    2.66      void const *left = begin_left, *right = begin_right;
    2.67  
    2.68      while (left != NULL && right != NULL) {
    2.69 -        void const *left_data = ll_data_f(left, follow_ptr_left);
    2.70 -        void const *right_data = ll_data_f(right, follow_ptr_right);
    2.71 +        void const *left_data = ll_data(left);
    2.72 +        void const *right_data = ll_data(right);
    2.73          int result = cmp_func(left_data, right_data);
    2.74          if (result != 0) return result;
    2.75          left = ll_advance(left);
    2.76 @@ -472,7 +466,6 @@
    2.77      struct cx_list_s base;
    2.78      cx_linked_list_node *begin;
    2.79      cx_linked_list_node *end;
    2.80 -    bool follow_ptr;
    2.81  } cx_linked_list;
    2.82  
    2.83  static cx_linked_list_node *cx_ll_node_at(
    2.84 @@ -576,21 +569,6 @@
    2.85      return cx_ll_insert_array(list, list->size, array, n);
    2.86  }
    2.87  
    2.88 -static int cx_pll_insert(
    2.89 -        struct cx_list_s *list,
    2.90 -        size_t index,
    2.91 -        void const *elem
    2.92 -) {
    2.93 -    return cx_ll_insert(list, index, &elem);
    2.94 -}
    2.95 -
    2.96 -static int cx_pll_add(
    2.97 -        struct cx_list_s *list,
    2.98 -        void const *elem
    2.99 -) {
   2.100 -    return cx_ll_insert(list, list->size, &elem);
   2.101 -}
   2.102 -
   2.103  static int cx_ll_remove(
   2.104          struct cx_list_s *list,
   2.105          size_t index
   2.106 @@ -623,30 +601,20 @@
   2.107      return node == NULL ? NULL : node->payload;
   2.108  }
   2.109  
   2.110 -static void *cx_pll_at(
   2.111 -        struct cx_list_s const *list,
   2.112 -        size_t index
   2.113 -) {
   2.114 -    cx_linked_list *ll = (cx_linked_list *) list;
   2.115 -    cx_linked_list_node *node = cx_ll_node_at(ll, index);
   2.116 -    return node == NULL ? NULL : *(void **) node->payload;
   2.117 -}
   2.118 -
   2.119  static size_t cx_ll_find(
   2.120          struct cx_list_s const *list,
   2.121          void const *elem
   2.122  ) {
   2.123 -    cx_linked_list *ll = (cx_linked_list *) list;
   2.124      return cx_linked_list_find(((cx_linked_list *) list)->begin,
   2.125                                 CX_LL_LOC_NEXT, CX_LL_LOC_DATA,
   2.126 -                               ll->follow_ptr, list->cmpfunc, elem);
   2.127 +                               list->cmpfunc, elem);
   2.128  }
   2.129  
   2.130  static void cx_ll_sort(struct cx_list_s *list) {
   2.131      cx_linked_list *ll = (cx_linked_list *) list;
   2.132      cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end,
   2.133                          CX_LL_LOC_PREV, CX_LL_LOC_NEXT, CX_LL_LOC_DATA,
   2.134 -                        ll->follow_ptr, list->cmpfunc);
   2.135 +                        list->cmpfunc);
   2.136  }
   2.137  
   2.138  static void cx_ll_reverse(struct cx_list_s *list) {
   2.139 @@ -662,7 +630,7 @@
   2.140      cx_linked_list *right = (cx_linked_list *) other;
   2.141      return cx_linked_list_compare(left->begin, right->begin,
   2.142                                    CX_LL_LOC_NEXT, CX_LL_LOC_DATA,
   2.143 -                                  left->follow_ptr, right->follow_ptr, list->cmpfunc);
   2.144 +                                  list->cmpfunc);
   2.145  }
   2.146  
   2.147  static bool cx_ll_iter_valid(void const *it) {
   2.148 @@ -696,12 +664,6 @@
   2.149      return node->payload;
   2.150  }
   2.151  
   2.152 -static void *cx_pll_iter_current(void const *it) {
   2.153 -    struct cx_iterator_s const *iter = it;
   2.154 -    cx_linked_list_node *node = iter->elem_handle;
   2.155 -    return *(void **) node->payload;
   2.156 -}
   2.157 -
   2.158  static bool cx_ll_iter_flag_rm(void *it) {
   2.159      struct cx_iterator_base_s *iter = it;
   2.160      if (iter->mutating) {
   2.161 @@ -729,15 +691,6 @@
   2.162      return iter;
   2.163  }
   2.164  
   2.165 -static CxIterator cx_pll_iterator(
   2.166 -        struct cx_list_s const *list,
   2.167 -        size_t index
   2.168 -) {
   2.169 -    CxIterator iter = cx_ll_iterator(list, index);
   2.170 -    iter.base.current = cx_pll_iter_current;
   2.171 -    return iter;
   2.172 -}
   2.173 -
   2.174  static CxMutIterator cx_ll_mut_iterator(
   2.175          struct cx_list_s *list,
   2.176          size_t index
   2.177 @@ -751,15 +704,6 @@
   2.178      return iter;
   2.179  }
   2.180  
   2.181 -static CxMutIterator cx_pll_mut_iterator(
   2.182 -        struct cx_list_s *list,
   2.183 -        size_t index
   2.184 -) {
   2.185 -    CxMutIterator iter = cx_ll_mut_iterator(list, index);
   2.186 -    iter.base.current = cx_pll_iter_current;
   2.187 -    return iter;
   2.188 -}
   2.189 -
   2.190  static int cx_ll_insert_iter(
   2.191          CxMutIterator *iter,
   2.192          void const *elem,
   2.193 @@ -780,14 +724,6 @@
   2.194      }
   2.195  }
   2.196  
   2.197 -static int cx_pll_insert_iter(
   2.198 -        CxMutIterator *iter,
   2.199 -        void const *elem,
   2.200 -        int prepend
   2.201 -) {
   2.202 -    return cx_ll_insert_iter(iter, &elem, prepend);
   2.203 -}
   2.204 -
   2.205  static void cx_ll_destructor(CxList *list) {
   2.206      cx_linked_list *ll = (cx_linked_list *) list;
   2.207  
   2.208 @@ -817,23 +753,6 @@
   2.209          cx_ll_mut_iterator,
   2.210  };
   2.211  
   2.212 -static cx_list_class cx_pointer_linked_list_class = {
   2.213 -        cx_ll_destructor,
   2.214 -        cx_pll_add,
   2.215 -        cx_ll_add_array,
   2.216 -        cx_pll_insert,
   2.217 -        cx_ll_insert_array,
   2.218 -        cx_pll_insert_iter,
   2.219 -        cx_ll_remove,
   2.220 -        cx_pll_at,
   2.221 -        cx_ll_find,
   2.222 -        cx_ll_sort,
   2.223 -        cx_ll_compare,
   2.224 -        cx_ll_reverse,
   2.225 -        cx_pll_iterator,
   2.226 -        cx_pll_mut_iterator,
   2.227 -};
   2.228 -
   2.229  CxList *cxLinkedListCreate(
   2.230          CxAllocator const *allocator,
   2.231          CxListComparator comparator,
   2.232 @@ -842,7 +761,6 @@
   2.233      cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list));
   2.234      if (list == NULL) return NULL;
   2.235  
   2.236 -    list->follow_ptr = false;
   2.237      list->base.cl = &cx_linked_list_class;
   2.238      list->base.allocator = allocator;
   2.239      list->base.cmpfunc = comparator;
   2.240 @@ -851,20 +769,3 @@
   2.241  
   2.242      return (CxList *) list;
   2.243  }
   2.244 -
   2.245 -CxList *cxPointerLinkedListCreate(
   2.246 -        CxAllocator const *allocator,
   2.247 -        CxListComparator comparator
   2.248 -) {
   2.249 -    cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list));
   2.250 -    if (list == NULL) return NULL;
   2.251 -
   2.252 -    list->follow_ptr = true;
   2.253 -    list->base.cl = &cx_pointer_linked_list_class;
   2.254 -    list->base.allocator = allocator;
   2.255 -    list->base.cmpfunc = comparator;
   2.256 -    list->base.itemsize = sizeof(void *);
   2.257 -    list->base.capacity = SIZE_MAX;
   2.258 -
   2.259 -    return (CxList *) list;
   2.260 -}
     3.1 --- a/test/test_list.cpp	Mon Jan 23 20:22:11 2023 +0100
     3.2 +++ b/test/test_list.cpp	Mon Jan 23 20:34:18 2023 +0100
     3.3 @@ -169,17 +169,17 @@
     3.4      int s;
     3.5  
     3.6      s = 2;
     3.7 -    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, false, cx_cmp_int, &s), 0);
     3.8 +    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s), 0);
     3.9      s = 4;
    3.10 -    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, false, cx_cmp_int, &s), 1);
    3.11 +    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s), 1);
    3.12      s = 6;
    3.13 -    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, false, cx_cmp_int, &s), 2);
    3.14 +    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s), 2);
    3.15      s = 8;
    3.16 -    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, false, cx_cmp_int, &s), 3);
    3.17 +    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s), 3);
    3.18      s = 10;
    3.19 -    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, false, cx_cmp_int, &s), 4);
    3.20 +    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s), 4);
    3.21      s = -2;
    3.22 -    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, false, cx_cmp_int, &s), 4);
    3.23 +    EXPECT_EQ(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s), 4);
    3.24  }
    3.25  
    3.26  TEST(LinkedList_LowLevel, cx_linked_list_compare) {
    3.27 @@ -188,11 +188,11 @@
    3.28      auto tc = create_nodes_test_data({2, 4, 6, 9});
    3.29      auto la = ta.begin, lb = tb.begin, lc = tc.begin;
    3.30  
    3.31 -    EXPECT_GT(cx_linked_list_compare(la, lb, loc_next, loc_data, false, false, cx_cmp_int), 0);
    3.32 -    EXPECT_LT(cx_linked_list_compare(lb, la, loc_next, loc_data, false, false, cx_cmp_int), 0);
    3.33 -    EXPECT_GT(cx_linked_list_compare(lc, la, loc_next, loc_data, false, false, cx_cmp_int), 0);
    3.34 -    EXPECT_LT(cx_linked_list_compare(la, lc, loc_next, loc_data, false, false, cx_cmp_int), 0);
    3.35 -    EXPECT_EQ(cx_linked_list_compare(la, la, loc_next, loc_data, false, false, cx_cmp_int), 0);
    3.36 +    EXPECT_GT(cx_linked_list_compare(la, lb, loc_next, loc_data, cx_cmp_int), 0);
    3.37 +    EXPECT_LT(cx_linked_list_compare(lb, la, loc_next, loc_data, cx_cmp_int), 0);
    3.38 +    EXPECT_GT(cx_linked_list_compare(lc, la, loc_next, loc_data, cx_cmp_int), 0);
    3.39 +    EXPECT_LT(cx_linked_list_compare(la, lc, loc_next, loc_data, cx_cmp_int), 0);
    3.40 +    EXPECT_EQ(cx_linked_list_compare(la, la, loc_next, loc_data, cx_cmp_int), 0);
    3.41  }
    3.42  
    3.43  TEST(LinkedList_LowLevel, cx_linked_list_add) {
    3.44 @@ -518,8 +518,7 @@
    3.45      void *begin = scrambled.begin;
    3.46      void *end = cx_linked_list_last(begin, loc_next);
    3.47  
    3.48 -    cx_linked_list_sort(&begin, &end, loc_prev, loc_next, loc_data,
    3.49 -                        false, cx_cmp_int);
    3.50 +    cx_linked_list_sort(&begin, &end, loc_prev, loc_next, loc_data, cx_cmp_int);
    3.51  
    3.52      node *check = reinterpret_cast<node *>(begin);
    3.53      node *check_last = nullptr;
    3.54 @@ -547,7 +546,7 @@
    3.55      cx_linked_list_reverse(&begin, &end, loc_prev, loc_next);
    3.56      EXPECT_EQ(end, orig_begin);
    3.57      EXPECT_EQ(begin, orig_end);
    3.58 -    EXPECT_EQ(cx_linked_list_compare(begin, expected.begin, loc_next, loc_data, false, false, cx_cmp_int), 0);
    3.59 +    EXPECT_EQ(cx_linked_list_compare(begin, expected.begin, loc_next, loc_data, cx_cmp_int), 0);
    3.60  }
    3.61  
    3.62  class HighLevelTest : public ::testing::Test {
    3.63 @@ -574,13 +573,6 @@
    3.64          return list;
    3.65      }
    3.66  
    3.67 -    auto pointerLinkedListFromTestData() const -> CxList * {
    3.68 -        auto list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int));
    3.69 -        // note: cannot use cxListAddArray() because we don't have a list of pointers
    3.70 -        cx_for_n(i, testdata_len) cxListAdd(list, &testdata.data[i]);
    3.71 -        return list;
    3.72 -    }
    3.73 -
    3.74      auto arrayListFromTestData() const -> CxList * {
    3.75          auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), testdata_len));
    3.76          cxListAddArray(list, testdata.data.data(), testdata_len);
    3.77 @@ -795,9 +787,6 @@
    3.78  class LinkedList : public HighLevelTest {
    3.79  };
    3.80  
    3.81 -class PointerLinkedList : public HighLevelTest {
    3.82 -};
    3.83 -
    3.84  class ArrayList : public HighLevelTest {
    3.85  };
    3.86  
    3.87 @@ -809,14 +798,6 @@
    3.88      verifyCreate(list);
    3.89  }
    3.90  
    3.91 -TEST_F(PointerLinkedList, cxPointerLinkedListCreate) {
    3.92 -    CxList *list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int));
    3.93 -    ASSERT_NE(list, nullptr);
    3.94 -    EXPECT_EQ(list->itemsize, sizeof(void *));
    3.95 -    EXPECT_EQ(list->capacity, (size_t) -1);
    3.96 -    verifyCreate(list);
    3.97 -}
    3.98 -
    3.99  TEST_F(ArrayList, cxArrayListCreate) {
   3.100      CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8));
   3.101      ASSERT_NE(list, nullptr);
   3.102 @@ -830,11 +811,6 @@
   3.103      verifyAdd(list, false);
   3.104  }
   3.105  
   3.106 -TEST_F(PointerLinkedList, cxListAdd) {
   3.107 -    CxList *list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int));
   3.108 -    verifyAdd(list, true);
   3.109 -}
   3.110 -
   3.111  TEST_F(ArrayList, cxListAdd) {
   3.112      CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8));
   3.113      verifyAdd(list, false);
   3.114 @@ -844,10 +820,6 @@
   3.115      verifyInsert(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))));
   3.116  }
   3.117  
   3.118 -TEST_F(PointerLinkedList, cxListInsert) {
   3.119 -    verifyInsert(autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int)));
   3.120 -}
   3.121 -
   3.122  TEST_F(ArrayList, cxListInsert) {
   3.123      verifyInsert(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 2)));
   3.124  }
   3.125 @@ -856,11 +828,6 @@
   3.126      verifyInsertArray(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))));
   3.127  }
   3.128  
   3.129 -TEST_F(PointerLinkedList, cxListInsertArray) {
   3.130 -    //TODO: this is unfixably broken - solve with issue #234
   3.131 -    //verifyInsertArray(autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int)));
   3.132 -}
   3.133 -
   3.134  TEST_F(ArrayList, cxListInsertArray) {
   3.135      verifyInsertArray(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4)));
   3.136  }
   3.137 @@ -869,10 +836,6 @@
   3.138      verifyRemove(linkedListFromTestData());
   3.139  }
   3.140  
   3.141 -TEST_F(PointerLinkedList, cxListRemove) {
   3.142 -    verifyRemove(pointerLinkedListFromTestData());
   3.143 -}
   3.144 -
   3.145  TEST_F(ArrayList, cxListRemove) {
   3.146      verifyRemove(arrayListFromTestData());
   3.147  }
   3.148 @@ -881,10 +844,6 @@
   3.149      verifyAt(linkedListFromTestData());
   3.150  }
   3.151  
   3.152 -TEST_F(PointerLinkedList, cxListAt) {
   3.153 -    verifyAt(pointerLinkedListFromTestData());
   3.154 -}
   3.155 -
   3.156  TEST_F(ArrayList, cxListAt) {
   3.157      verifyAt(arrayListFromTestData());
   3.158  }
   3.159 @@ -893,10 +852,6 @@
   3.160      verifyFind(linkedListFromTestData());
   3.161  }
   3.162  
   3.163 -TEST_F(PointerLinkedList, cxListFind) {
   3.164 -    verifyFind(pointerLinkedListFromTestData());
   3.165 -}
   3.166 -
   3.167  TEST_F(ArrayList, cxListFind) {
   3.168      verifyFind(arrayListFromTestData());
   3.169  }
   3.170 @@ -905,10 +860,6 @@
   3.171      verifySort(linkedListFromTestData());
   3.172  }
   3.173  
   3.174 -TEST_F(PointerLinkedList, cxListSort) {
   3.175 -    verifySort(pointerLinkedListFromTestData());
   3.176 -}
   3.177 -
   3.178  TEST_F(ArrayList, cxListSort) {
   3.179      verifySort(arrayListFromTestData());
   3.180  }
   3.181 @@ -917,10 +868,6 @@
   3.182      verifyIterator(linkedListFromTestData());
   3.183  }
   3.184  
   3.185 -TEST_F(PointerLinkedList, Iterator) {
   3.186 -    verifyIterator(pointerLinkedListFromTestData());
   3.187 -}
   3.188 -
   3.189  TEST_F(ArrayList, Iterator) {
   3.190      verifyIterator(arrayListFromTestData());
   3.191  }
   3.192 @@ -932,14 +879,6 @@
   3.193      verifyInsertViaIterator(list);
   3.194  }
   3.195  
   3.196 -TEST_F(PointerLinkedList, InsertViaIterator) {
   3.197 -    int fivenums[] = {0, 1, 2, 3, 4, 5};
   3.198 -    CxList *list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int));
   3.199 -    // note: don't use cxListAddArray() here, because we don't have a list of pointers
   3.200 -    cx_for_n (i, 5) cxListAdd(list, &fivenums[i]);
   3.201 -    verifyInsertViaIterator(list);
   3.202 -}
   3.203 -
   3.204  TEST_F(ArrayList, InsertViaIterator) {
   3.205      int fivenums[] = {0, 1, 2, 3, 4, 5};
   3.206      CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4));
   3.207 @@ -951,10 +890,6 @@
   3.208      verifyReverse(linkedListFromTestData());
   3.209  }
   3.210  
   3.211 -TEST_F(PointerLinkedList, cxListReverse) {
   3.212 -    verifyReverse(pointerLinkedListFromTestData());
   3.213 -}
   3.214 -
   3.215  TEST_F(ArrayList, cxListReverse) {
   3.216      verifyReverse(arrayListFromTestData());
   3.217  }
   3.218 @@ -965,83 +900,20 @@
   3.219      verifyCompare(left, right);
   3.220  }
   3.221  
   3.222 -TEST_F(LinkedList, cxListCompareWithPtrList) {
   3.223 -    auto left = linkedListFromTestData();
   3.224 -    auto right = pointerLinkedListFromTestData();
   3.225 -    verifyCompare(left, right);
   3.226 -}
   3.227 -
   3.228  TEST_F(LinkedList, cxListCompareWithArrayList) {
   3.229      auto left = linkedListFromTestData();
   3.230      auto right = arrayListFromTestData();
   3.231      verifyCompare(left, right);
   3.232  }
   3.233  
   3.234 -TEST_F(PointerLinkedList, cxListCompare) {
   3.235 -    auto left = pointerLinkedListFromTestData();
   3.236 -    auto right = pointerLinkedListFromTestData();
   3.237 -    verifyCompare(left, right);
   3.238 -}
   3.239 -
   3.240 -TEST_F(PointerLinkedList, cxListCompareWithNormalList) {
   3.241 -    auto left = pointerLinkedListFromTestData();
   3.242 -    auto right = linkedListFromTestData();
   3.243 -    verifyCompare(left, right);
   3.244 -}
   3.245 -
   3.246 -TEST_F(PointerLinkedList, cxListCompareWithArrayList) {
   3.247 -    auto left = pointerLinkedListFromTestData();
   3.248 -    auto right = arrayListFromTestData();
   3.249 -    verifyCompare(left, right);
   3.250 -}
   3.251 -
   3.252  TEST_F(ArrayList, cxListCompare) {
   3.253      auto left = arrayListFromTestData();
   3.254      auto right = arrayListFromTestData();
   3.255      verifyCompare(left, right);
   3.256  }
   3.257  
   3.258 -TEST_F(ArrayList, cxListCompareWithPtrList) {
   3.259 -    auto left = arrayListFromTestData();
   3.260 -    auto right = pointerLinkedListFromTestData();
   3.261 -    verifyCompare(left, right);
   3.262 -}
   3.263 -
   3.264 -TEST_F(ArrayList, cxListCompareWithNormalList) {
   3.265 +TEST_F(ArrayList, cxListCompareWithLinkedList) {
   3.266      auto left = arrayListFromTestData();
   3.267      auto right = linkedListFromTestData();
   3.268      verifyCompare(left, right);
   3.269  }
   3.270 -
   3.271 -TEST_F(PointerLinkedList, NoDestructor) {
   3.272 -    void *item = cxMalloc(&testingAllocator, sizeof(int));
   3.273 -    auto list = cxPointerLinkedListCreate(cxDefaultAllocator, cx_cmp_int);
   3.274 -    cxListAdd(list, item);
   3.275 -    ASSERT_FALSE(testingAllocator.verify());
   3.276 -    cxListDestroy(list);
   3.277 -    EXPECT_FALSE(testingAllocator.verify());
   3.278 -    cxFree(&testingAllocator, item);
   3.279 -    EXPECT_TRUE(testingAllocator.verify());
   3.280 -}
   3.281 -
   3.282 -TEST_F(PointerLinkedList, SimpleDestructor) {
   3.283 -    int item = 0;
   3.284 -    auto list = cxPointerLinkedListCreate(cxDefaultAllocator, cx_cmp_int);
   3.285 -    list->content_destructor_type = CX_DESTRUCTOR_SIMPLE;
   3.286 -    list->simple_destructor = [](void *elem) { *(int *) elem = 42; };
   3.287 -    cxListAdd(list, &item);
   3.288 -    cxListDestroy(list);
   3.289 -    EXPECT_EQ(item, 42);
   3.290 -}
   3.291 -
   3.292 -TEST_F(PointerLinkedList, AdvancedDestructor) {
   3.293 -    void *item = cxMalloc(&testingAllocator, sizeof(int));
   3.294 -    auto list = cxPointerLinkedListCreate(cxDefaultAllocator, cx_cmp_int);
   3.295 -    list->content_destructor_type = CX_DESTRUCTOR_ADVANCED;
   3.296 -    list->advanced_destructor.data = &testingAllocator;
   3.297 -    list->advanced_destructor.func = (cx_destructor_func2) cxFree;
   3.298 -    cxListAdd(list, item);
   3.299 -    ASSERT_FALSE(testingAllocator.verify());
   3.300 -    cxListDestroy(list);
   3.301 -    EXPECT_TRUE(testingAllocator.verify());
   3.302 -}

mercurial