tests/test_list.c

Sun, 14 Jan 2024 13:50:17 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 14 Jan 2024 13:50:17 +0100
changeset 806
e06249e09f99
parent 804
5136f2fc32ec
child 807
c8d692131b1e
permissions
-rw-r--r--

add constant for reading out strstr sbo size - relates to #343

also fixes the related test which was working with the old SBO size of 256 and was broken after increasing it to 512

798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved.
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 #include "cx/test.h"
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 #include "util_allocator.h"
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 #include "cx/compare.h"
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
32 #include "cx/utils.h"
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 #include "cx/array_list.h"
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 #include "cx/linked_list.h"
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 #include <stdarg.h>
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 typedef struct node {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 struct node *next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 struct node *prev;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 int data;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 } node;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 const ptrdiff_t loc_prev = offsetof(struct node, prev);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 const ptrdiff_t loc_next = offsetof(struct node, next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 const ptrdiff_t loc_data = offsetof(struct node, data);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 static node *create_nodes_test_data(size_t len) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 node *begin = calloc(1, sizeof(node));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 void *prev = begin;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 for (size_t i = 1; i < len; i++) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 node *n = calloc(1, sizeof(node));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 cx_linked_list_link(prev, n, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 prev = n;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 return begin;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 void assign_nodes_test_data(node *n, ...) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 va_list ap;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 va_start(ap, n);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 while (n != NULL) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 n->data = va_arg(ap, int);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 n = n->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 va_end(ap);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 static void destroy_nodes_test_data(node *n) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 while (n != NULL) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 void *next = n->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 free(n);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 n = next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 static int *int_test_data(size_t len) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 int *data = malloc(len*sizeof(int));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 for (size_t i = 0 ; i < len ; i++) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 data[i] = rand(); // NOLINT(*-msc50-cpp)
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 return data;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 CX_TEST(test_linked_list_link_unlink) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 node a = {0}, b = {0}, c = {0};
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 cx_linked_list_link(&a, &b, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 CX_TEST_ASSERT(a.prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 CX_TEST_ASSERT(a.next == &b);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 CX_TEST_ASSERT(b.prev == &a);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 CX_TEST_ASSERT(b.next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 cx_linked_list_unlink(&a, &b, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 CX_TEST_ASSERT(a.prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 CX_TEST_ASSERT(a.next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 CX_TEST_ASSERT(b.prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 CX_TEST_ASSERT(b.next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 cx_linked_list_link(&b, &c, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 cx_linked_list_link(&a, &b, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 cx_linked_list_unlink(&b, &c, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 CX_TEST_ASSERT(a.prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 CX_TEST_ASSERT(a.next == &b);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 CX_TEST_ASSERT(b.prev == &a);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 CX_TEST_ASSERT(b.next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 CX_TEST_ASSERT(c.prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 CX_TEST_ASSERT(c.next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 CX_TEST(test_linked_list_at) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 node a = {0}, b = {0}, c = {0}, d = {0};
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 cx_linked_list_link(&a, &b, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 cx_linked_list_link(&b, &c, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 cx_linked_list_link(&c, &d, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 CX_TEST_ASSERT(cx_linked_list_at(&a, 0, loc_next, 0) == &a);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 CX_TEST_ASSERT(cx_linked_list_at(&a, 0, loc_next, 1) == &b);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124 CX_TEST_ASSERT(cx_linked_list_at(&a, 0, loc_next, 2) == &c);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 CX_TEST_ASSERT(cx_linked_list_at(&a, 0, loc_next, 3) == &d);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 CX_TEST_ASSERT(cx_linked_list_at(&a, 0, loc_next, 4) == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 CX_TEST_ASSERT(cx_linked_list_at(&b, 1, loc_prev, 0) == &a);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 CX_TEST_ASSERT(cx_linked_list_at(&b, 1, loc_next, 1) == &b);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 CX_TEST_ASSERT(cx_linked_list_at(&b, 1, loc_next, 2) == &c);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 CX_TEST_ASSERT(cx_linked_list_at(&b, 1, loc_next, 3) == &d);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 CX_TEST_ASSERT(cx_linked_list_at(&b, 1, loc_next, 4) == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132 CX_TEST_ASSERT(cx_linked_list_at(&d, 3, loc_prev, 0) == &a);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 CX_TEST_ASSERT(cx_linked_list_at(&d, 3, loc_prev, 1) == &b);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 CX_TEST(test_linked_list_find) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 void *list = create_nodes_test_data(4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 assign_nodes_test_data(list, 2, 4, 6, 8);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141 int s;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 s = 2;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s) == 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144 s = 4;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
145 CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s) == 1);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146 s = 6;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s) == 2);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148 s = 8;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s) == 3);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 s = 10;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
151 CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s) < 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 s = -2;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153 CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s) < 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 destroy_nodes_test_data(list);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 CX_TEST(test_linked_list_compare) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159 void *la = create_nodes_test_data(4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
160 void *lb = create_nodes_test_data(3);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
161 void *lc = create_nodes_test_data(4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
162 assign_nodes_test_data(la, 2, 4, 6, 8);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
163 assign_nodes_test_data(lb, 2, 4, 6);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 assign_nodes_test_data(lc, 2, 4, 6, 9);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 CX_TEST_ASSERT(cx_linked_list_compare(la, lb, loc_next, loc_data, cx_cmp_int) > 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 CX_TEST_ASSERT(cx_linked_list_compare(lb, la, loc_next, loc_data, cx_cmp_int) < 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 CX_TEST_ASSERT(cx_linked_list_compare(lc, la, loc_next, loc_data, cx_cmp_int) > 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 CX_TEST_ASSERT(cx_linked_list_compare(la, lc, loc_next, loc_data, cx_cmp_int) < 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 CX_TEST_ASSERT(cx_linked_list_compare(la, la, loc_next, loc_data, cx_cmp_int) == 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 destroy_nodes_test_data(la);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173 destroy_nodes_test_data(lb);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 destroy_nodes_test_data(lc);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
177 CX_TEST(test_linked_list_add) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
178 node nodes[4];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
180 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181 // test with begin, end / prev, next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 memset(nodes, 0, sizeof(node)*4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
184
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
185 cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
186 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
187 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188 CX_TEST_ASSERT(nodes[0].prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189 CX_TEST_ASSERT(nodes[0].next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
193 CX_TEST_ASSERT(end == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
194 CX_TEST_ASSERT(nodes[0].next == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
195 CX_TEST_ASSERT(nodes[1].prev == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
196
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
197 // test with begin only / prev, next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
198 memset(nodes, 0, sizeof(node)*4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
199 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
200
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
201 cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
202 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
203 cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
204 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
205 CX_TEST_ASSERT(nodes[0].next == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
206 CX_TEST_ASSERT(nodes[1].prev == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
207
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
208 cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
209 CX_TEST_ASSERT(nodes[1].next == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
210 CX_TEST_ASSERT(nodes[2].prev == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
211
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
212 // test with end only / prev, next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
213 memset(nodes, 0, sizeof(node)*4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
214 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
215
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
216 cx_linked_list_add(NULL, &end, loc_prev, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
217 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
218 cx_linked_list_add(NULL, &end, loc_prev, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
219 CX_TEST_ASSERT(end == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
220 CX_TEST_ASSERT(nodes[0].next == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
221 CX_TEST_ASSERT(nodes[1].prev == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
222
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
223 cx_linked_list_add(NULL, &end, loc_prev, loc_next, &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
224 CX_TEST_ASSERT(end == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
225 CX_TEST_ASSERT(nodes[1].next == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
226 CX_TEST_ASSERT(nodes[2].prev == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
227
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
228 // test with begin, end / next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
229 memset(nodes, 0, sizeof(node)*4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
230 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
231
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
232 cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
233 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
234 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
235 cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
236 CX_TEST_ASSERT(end == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
237 CX_TEST_ASSERT(nodes[0].next == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
238 CX_TEST_ASSERT(nodes[1].prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
239 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
240 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
241
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
242 CX_TEST(test_linked_list_prepend) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
243 node nodes[4];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
244 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
245 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
246 // test with begin, end / prev, next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
247 memset(nodes, 0, sizeof(node) * 4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
248 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
249
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
250 cx_linked_list_prepend(&begin, &end, loc_prev, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
251 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
252 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
253 CX_TEST_ASSERT(nodes[0].prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
254 CX_TEST_ASSERT(nodes[0].next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
255
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
256 cx_linked_list_prepend(&begin, &end, loc_prev, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
257 CX_TEST_ASSERT(begin == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
258 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
259 CX_TEST_ASSERT(nodes[1].next == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
260 CX_TEST_ASSERT(nodes[0].prev == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
261
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
262 // test with begin only / prev, next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
263 memset(nodes, 0, sizeof(node) * 4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
264 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
265
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
266 cx_linked_list_prepend(&begin, NULL, loc_prev, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
267 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
268 cx_linked_list_prepend(&begin, NULL, loc_prev, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
269 CX_TEST_ASSERT(begin == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
270 CX_TEST_ASSERT(nodes[1].next == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
271 CX_TEST_ASSERT(nodes[0].prev == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
272
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
273 cx_linked_list_prepend(&begin, NULL, loc_prev, loc_next, &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
274 CX_TEST_ASSERT(begin == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
275 CX_TEST_ASSERT(nodes[2].next == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
276 CX_TEST_ASSERT(nodes[1].prev == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
277
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
278 // test with end only / prev, next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
279 memset(nodes, 0, sizeof(node) * 4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
280 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
281
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
282 cx_linked_list_prepend(NULL, &end, loc_prev, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
283 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
284 cx_linked_list_prepend(NULL, &end, loc_prev, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
285 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
286 CX_TEST_ASSERT(nodes[1].next == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
287 CX_TEST_ASSERT(nodes[0].prev == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
288
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
289 cx_linked_list_prepend(NULL, &end, loc_prev, loc_next, &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
290 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
291 CX_TEST_ASSERT(nodes[2].next == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
292 CX_TEST_ASSERT(nodes[1].prev == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
293
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
294 // test with begin, end / next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
295 memset(nodes, 0, sizeof(node) * 4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
296 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
297
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
298 cx_linked_list_prepend(&begin, &end, -1, loc_next, &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
299 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
300 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
301 cx_linked_list_prepend(&begin, &end, -1, loc_next, &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
302 cx_linked_list_prepend(&begin, &end, -1, loc_next, &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
303 CX_TEST_ASSERT(begin == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
304 CX_TEST_ASSERT(end == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
305 CX_TEST_ASSERT(nodes[1].next == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
306 CX_TEST_ASSERT(nodes[2].next == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
307 CX_TEST_ASSERT(nodes[1].prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
308 CX_TEST_ASSERT(nodes[0].prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
309 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
310 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
311
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
312 CX_TEST(test_linked_list_insert) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
313 node nodes[4];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
314 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
315 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
316 // insert mid list
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
317 memset(nodes, 0, sizeof(node) * 4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
318 begin = &nodes[0];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
319 end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
320
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
321 cx_linked_list_link(&nodes[0], &nodes[1], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
322 cx_linked_list_link(&nodes[1], &nodes[2], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
323
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
324 cx_linked_list_insert(&begin, &end, loc_prev, loc_next, &nodes[1], &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
325 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
326 CX_TEST_ASSERT(end == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
327 CX_TEST_ASSERT(nodes[1].next == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
328 CX_TEST_ASSERT(nodes[2].prev == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
329 CX_TEST_ASSERT(nodes[3].prev == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
330 CX_TEST_ASSERT(nodes[3].next == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
331
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
332 // insert end
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
333 memset(nodes, 0, sizeof(node) * 4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
334 begin = &nodes[0];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
335 end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
336
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
337 cx_linked_list_link(&nodes[0], &nodes[1], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
338 cx_linked_list_link(&nodes[1], &nodes[2], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
339
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
340 cx_linked_list_insert(&begin, &end, loc_prev, loc_next, &nodes[2], &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
341 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
342 CX_TEST_ASSERT(end == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
343 CX_TEST_ASSERT(nodes[2].next == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
344 CX_TEST_ASSERT(nodes[3].prev == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
345 CX_TEST_ASSERT(nodes[3].next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
346
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
347 // insert begin
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
348 memset(nodes, 0, sizeof(node) * 4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
349 begin = &nodes[0];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
350 end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
351
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
352 cx_linked_list_link(&nodes[0], &nodes[1], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
353 cx_linked_list_link(&nodes[1], &nodes[2], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
354
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
355 cx_linked_list_insert(&begin, &end, loc_prev, loc_next, NULL, &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
356 CX_TEST_ASSERT(begin == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
357 CX_TEST_ASSERT(end == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
358 CX_TEST_ASSERT(nodes[0].prev == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
359 CX_TEST_ASSERT(nodes[3].prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
360 CX_TEST_ASSERT(nodes[3].next == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
361 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
362 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
363
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
364 CX_TEST(test_linked_list_insert_chain) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
365 node nodes[5];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
366 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
367 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
368 // insert mid list
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
369 memset(nodes, 0, sizeof(node) * 5);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
370 begin = &nodes[0]; end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
371
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
372 cx_linked_list_link(&nodes[0], &nodes[1], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
373 cx_linked_list_link(&nodes[1], &nodes[2], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
374 cx_linked_list_link(&nodes[3], &nodes[4], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
375
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
376 cx_linked_list_insert_chain(&begin, &end, loc_prev, loc_next, &nodes[1], &nodes[3], NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
377 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
378 CX_TEST_ASSERT(end == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
379 CX_TEST_ASSERT(nodes[1].next == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
380 CX_TEST_ASSERT(nodes[2].prev == &nodes[4]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
381 CX_TEST_ASSERT(nodes[3].prev == &nodes[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
382 CX_TEST_ASSERT(nodes[4].next == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
383
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
384 // insert end
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
385 memset(nodes, 0, sizeof(node) * 5);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
386 begin = &nodes[0]; end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
387
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
388 cx_linked_list_link(&nodes[0], &nodes[1], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
389 cx_linked_list_link(&nodes[1], &nodes[2], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
390 cx_linked_list_link(&nodes[3], &nodes[4], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
391
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
392 cx_linked_list_insert_chain(&begin, &end, loc_prev, loc_next, &nodes[2], &nodes[3], NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
393 CX_TEST_ASSERT(begin == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
394 CX_TEST_ASSERT(end == &nodes[4]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
395 CX_TEST_ASSERT(nodes[2].next == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
396 CX_TEST_ASSERT(nodes[3].prev == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
397 CX_TEST_ASSERT(nodes[4].next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
398
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
399 // insert begin
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
400 memset(nodes, 0, sizeof(node) * 5);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
401 begin = &nodes[0]; end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
402
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
403 cx_linked_list_link(&nodes[0], &nodes[1], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
404 cx_linked_list_link(&nodes[1], &nodes[2], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
405 cx_linked_list_link(&nodes[3], &nodes[4], loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
406
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
407 cx_linked_list_insert_chain(&begin, &end, loc_prev, loc_next, NULL, &nodes[3], NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
408 CX_TEST_ASSERT(begin == &nodes[3]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
409 CX_TEST_ASSERT(end == &nodes[2]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
410 CX_TEST_ASSERT(nodes[0].prev == &nodes[4]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
411 CX_TEST_ASSERT(nodes[3].prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
412 CX_TEST_ASSERT(nodes[4].next == &nodes[0]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
413 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
414 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
415
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
416 CX_TEST(test_linked_list_first) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
417 node *testdata = create_nodes_test_data(3);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
418 void *begin = testdata;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
419 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
420 CX_TEST_ASSERT(begin == cx_linked_list_first(testdata, loc_prev));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
421 CX_TEST_ASSERT(begin == cx_linked_list_first(testdata->next, loc_prev));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
422 CX_TEST_ASSERT(begin == cx_linked_list_first(testdata->next->next, loc_prev));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
423 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
424 destroy_nodes_test_data(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
425 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
426
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
427 CX_TEST(test_linked_list_last) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
428 node *testdata = create_nodes_test_data(3);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
429 void *end = testdata->next->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
430 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
431 CX_TEST_ASSERT(end == cx_linked_list_last(testdata, loc_next));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
432 CX_TEST_ASSERT(end == cx_linked_list_last(testdata->next, loc_next));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
433 CX_TEST_ASSERT(end == cx_linked_list_last(testdata->next->next, loc_next));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
434 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
435 destroy_nodes_test_data(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
436 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
437
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
438 CX_TEST(test_linked_list_prev) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
439 node *testdata = create_nodes_test_data(3);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
440 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
441 CX_TEST_ASSERT(cx_linked_list_prev(testdata, loc_next, testdata) == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
442 CX_TEST_ASSERT(cx_linked_list_prev(testdata, loc_next, testdata->next) == testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
443 CX_TEST_ASSERT(cx_linked_list_prev(testdata, loc_next, testdata->next->next) == testdata->next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
444 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
445 destroy_nodes_test_data(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
446 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
447
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
448 CX_TEST(test_linked_list_remove) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
449 node *testdata = create_nodes_test_data(3);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
450 assign_nodes_test_data(testdata, 2, 4, 6);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
451 node *first = testdata;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
452 node *second = first->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
453 node *third = second->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
454 void *begin = testdata;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
455 void *end = third;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
456
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
457 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
458 cx_linked_list_remove(&begin, &end, loc_prev, loc_next, second);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
459 CX_TEST_ASSERT(begin == first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
460 CX_TEST_ASSERT(end == third);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
461 CX_TEST_ASSERT(first->prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
462 CX_TEST_ASSERT(first->next == third);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
463 CX_TEST_ASSERT(third->prev == first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
464 CX_TEST_ASSERT(third->next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
465
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
466 cx_linked_list_remove(&begin, &end, loc_prev, loc_next, third);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
467 CX_TEST_ASSERT(begin == first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
468 CX_TEST_ASSERT(end == first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
469 CX_TEST_ASSERT(first->prev == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
470 CX_TEST_ASSERT(first->next == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
471
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
472 cx_linked_list_remove(&begin, &end, loc_prev, loc_next, first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
473 CX_TEST_ASSERT(begin == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
474 CX_TEST_ASSERT(end == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
475 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
476 // list is not intact anymore, we have to free nodes individually
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
477 free(first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
478 free(second);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
479 free(third);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
480 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
481
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
482 CX_TEST(test_linked_list_size) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
483 node *td5 = create_nodes_test_data(5);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
484 node *td13 = create_nodes_test_data(13);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
485 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
486 CX_TEST_ASSERT(cx_linked_list_size(NULL, loc_next) == 0);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
487 CX_TEST_ASSERT(cx_linked_list_size(td5, loc_next) == 5);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
488 CX_TEST_ASSERT(cx_linked_list_size(td13, loc_next) == 13);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
489 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
490 destroy_nodes_test_data(td5);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
491 destroy_nodes_test_data(td13);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
492 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
493
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
494 CX_TEST(test_linked_list_sort_empty) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
495 void *begin = NULL;
799
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
496 CX_TEST_DO {
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
497 // cannot assert something, we can just test that it does not crash
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
498 cx_linked_list_sort(&begin, NULL, loc_prev, loc_next, loc_data, cx_cmp_int);
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
499 CX_TEST_ASSERT(true);
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
500 }
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
501 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
502
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
503 CX_TEST(test_linked_list_sort) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
504 const size_t len = 1500;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
505 int *testdata = int_test_data(len);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
506 void *scrambled = create_nodes_test_data(len);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
507 node *n = scrambled;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
508 for (size_t i = 0; i < len; i++) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
509 n->data = testdata[i];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
510 n = n->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
511 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
512 int *sorted = malloc(len*sizeof(int));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
513 memcpy(sorted, testdata, len*sizeof(int));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
514 qsort(sorted, len, sizeof(int), cx_cmp_int);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
515
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
516 void *begin = scrambled;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
517 void *end = cx_linked_list_last(begin, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
518
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
519 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
520 cx_linked_list_sort(&begin, &end, loc_prev, loc_next, loc_data, cx_cmp_int);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
521 node *check = begin;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
522 node *check_last = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
523 for (size_t i = 0; i < len; i++) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
524 CX_TEST_ASSERT(check->data == sorted[i]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
525 CX_TEST_ASSERT(check->prev == check_last);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
526 if (i < len - 1) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
527 CX_TEST_ASSERT(check->next != NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
528 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
529 check_last = check;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
530 check = check->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
531 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
532 CX_TEST_ASSERT(check == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
533 CX_TEST_ASSERT(end == check_last);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
534 }
799
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
535 destroy_nodes_test_data(begin);
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
536 free(sorted);
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
537 free(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
538 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
539
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
540 CX_TEST(test_linked_list_reverse) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
541 void *testdata = create_nodes_test_data(4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
542 void *expected = create_nodes_test_data(4);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
543 assign_nodes_test_data(testdata, 2, 4, 6, 8);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
544 assign_nodes_test_data(expected, 8, 6, 4, 2);
799
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
545 void *begin = testdata;
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
546 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
547 void *end = cx_linked_list_last(begin, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
548 void *orig_begin = begin, *orig_end = end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
549
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
550 cx_linked_list_reverse(&begin, &end, loc_prev, loc_next);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
551 CX_TEST_ASSERT(end == orig_begin);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
552 CX_TEST_ASSERT(begin == orig_end);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
553 CX_TEST_ASSERT(0 == cx_linked_list_compare(begin, expected, loc_next, loc_data, cx_cmp_int));
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
554 }
799
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
555 destroy_nodes_test_data(begin);
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
556 destroy_nodes_test_data(expected);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
557 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
558
800
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
559
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
560 CX_TEST(test_empty_list_size) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
561 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
562 CX_TEST_ASSERT(cxEmptyList->size == 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
563 CX_TEST_ASSERT(cxListSize(cxEmptyList) == 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
564 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
565 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
566
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
567 CX_TEST(test_empty_list_iterator) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
568 CxList *list = cxEmptyList;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
569
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
570 CxIterator it1 = cxListIterator(list);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
571 CxIterator it2 = cxListBackwardsIterator(list);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
572 CxMutIterator it3 = cxListMutIterator(list);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
573 CxMutIterator it4 = cxListMutBackwardsIterator(list);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
574
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
575 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
576 CX_TEST_ASSERT(!cxIteratorValid(it1));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
577 CX_TEST_ASSERT(!cxIteratorValid(it2));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
578 CX_TEST_ASSERT(!cxIteratorValid(it3));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
579 CX_TEST_ASSERT(!cxIteratorValid(it4));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
580
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
581 int c = 0;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
582 cx_foreach(void*, data, it1) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
583 cx_foreach(void*, data, it2) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
584 cx_foreach(void*, data, it3) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
585 cx_foreach(void*, data, it4) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
586 CX_TEST_ASSERT(c == 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
587 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
588 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
589
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
590 CX_TEST(test_empty_list_noops) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
591 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
592 CxList copy = *cxEmptyList;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
593 cxListSort(cxEmptyList);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
594 cxListClear(cxEmptyList);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
595 cxListDestroy(cxEmptyList);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
596 CX_TEST_ASSERT(0 == memcmp(&copy, cxEmptyList, sizeof(CxList))); // NOLINT(*-suspicious-memory-comparison)
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
597 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
598 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
599
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
600 CX_TEST(test_empty_list_at) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
601 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
602 CX_TEST_ASSERT(cxListAt(cxEmptyList, 0) == NULL);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
603 CX_TEST_ASSERT(cxListAt(cxEmptyList, 1) == NULL);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
604 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
605 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
606
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
607 CX_TEST(test_empty_list_find) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
608 int x = 42, y = 1337;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
609 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
610 CX_TEST_ASSERT(cxListFind(cxEmptyList, &x) < 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
611 CX_TEST_ASSERT(cxListFind(cxEmptyList, &y) < 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
612 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
613 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
614
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
615 CX_TEST(test_empty_list_compare) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
616 CxList *empty = cxEmptyList;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
617 CxList *ll = cxLinkedListCreateSimple(sizeof(int));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
618 CxList *al = cxArrayListCreateSimple(sizeof(int), 8);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
619 int x = 5;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
620 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
621 CX_TEST_ASSERT(0 == cxListCompare(empty, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
622 CX_TEST_ASSERT(0 == cxListCompare(ll, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
623 CX_TEST_ASSERT(0 == cxListCompare(al, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
624 CX_TEST_ASSERT(0 == cxListCompare(cxEmptyList, ll));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
625 CX_TEST_ASSERT(0 == cxListCompare(cxEmptyList, al));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
626
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
627 cxListAdd(ll, &x);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
628 cxListAdd(al, &x);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
629
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
630 CX_TEST_ASSERT(0 < cxListCompare(ll, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
631 CX_TEST_ASSERT(0 < cxListCompare(al, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
632 CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, ll));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
633 CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, al));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
634 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
635 cxListDestroy(ll);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
636 cxListDestroy(al);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
637 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
638
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
639 CX_TEST(test_list_ll_create) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
640 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
641 cx_testing_allocator_init(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
642 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
643 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
644 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
645 CX_TEST_ASSERT(list != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
646 CX_TEST_ASSERT(list->item_size == sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
647 CX_TEST_ASSERT(list->simple_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
648 CX_TEST_ASSERT(list->advanced_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
649 CX_TEST_ASSERT(list->destructor_data == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
650 CX_TEST_ASSERT(cxListSize(list) == 0);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
651 CX_TEST_ASSERT(list->allocator == alloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
652 CX_TEST_ASSERT(list->cmpfunc == cx_cmp_int);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
653 CX_TEST_ASSERT(!cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
654 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
655 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
656 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
657 cx_testing_allocator_destroy(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
658 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
659
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
660 CX_TEST(test_list_ll_create_simple) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
661 CxList *list = cxLinkedListCreateSimple(sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
662 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
663 CX_TEST_ASSERT(list != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
664 CX_TEST_ASSERT(list->item_size == sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
665 CX_TEST_ASSERT(list->simple_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
666 CX_TEST_ASSERT(list->advanced_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
667 CX_TEST_ASSERT(list->destructor_data == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
668 CX_TEST_ASSERT(cxListSize(list) == 0);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
669 CX_TEST_ASSERT(list->allocator == cxDefaultAllocator);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
670 CX_TEST_ASSERT(list->cmpfunc == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
671 CX_TEST_ASSERT(!cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
672 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
673 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
674 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
675
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
676 CX_TEST(test_list_ll_store_pointers) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
677 CxList *list = cxLinkedListCreateSimple(47);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
678 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
679 CX_TEST_ASSERT(!cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
680 cxListStorePointers(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
681 CX_TEST_ASSERT(list->item_size == sizeof(void *));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
682 CX_TEST_ASSERT(list->cl != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
683 CX_TEST_ASSERT(list->climpl != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
684 CX_TEST_ASSERT(cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
685 cxListStoreObjects(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
686 CX_TEST_ASSERT(list->cl != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
687 CX_TEST_ASSERT(list->climpl == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
688 CX_TEST_ASSERT(!cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
689 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
690 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
691 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
692
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
693 CX_TEST(test_list_ll_create_simple_for_pointers) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
694 CxList *list = cxLinkedListCreateSimple(CX_STORE_POINTERS);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
695 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
696 CX_TEST_ASSERT(list != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
697 CX_TEST_ASSERT(list->item_size == sizeof(void*));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
698 CX_TEST_ASSERT(list->simple_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
699 CX_TEST_ASSERT(list->advanced_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
700 CX_TEST_ASSERT(list->destructor_data == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
701 CX_TEST_ASSERT(cxListSize(list) == 0);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
702 CX_TEST_ASSERT(list->allocator == cxDefaultAllocator);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
703 CX_TEST_ASSERT(list->cmpfunc == cx_cmp_ptr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
704 CX_TEST_ASSERT(cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
705 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
706 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
707 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
708
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
709 CX_TEST(test_list_arl_create) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
710 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
711 cx_testing_allocator_init(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
712 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
713 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
714 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
715 CX_TEST_ASSERT(list != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
716 CX_TEST_ASSERT(list->item_size == sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
717 CX_TEST_ASSERT(list->simple_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
718 CX_TEST_ASSERT(list->advanced_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
719 CX_TEST_ASSERT(list->destructor_data == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
720 CX_TEST_ASSERT(cxListSize(list) == 0);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
721 CX_TEST_ASSERT(list->allocator == alloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
722 CX_TEST_ASSERT(list->cmpfunc == cx_cmp_int);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
723 CX_TEST_ASSERT(!cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
724 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
725 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
726 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
727 cx_testing_allocator_destroy(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
728 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
729
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
730 CX_TEST(test_list_arl_create_simple) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
731 CxList *list = cxArrayListCreateSimple(sizeof(int), 8);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
732 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
733 CX_TEST_ASSERT(list != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
734 CX_TEST_ASSERT(list->item_size == sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
735 CX_TEST_ASSERT(list->simple_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
736 CX_TEST_ASSERT(list->advanced_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
737 CX_TEST_ASSERT(list->destructor_data == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
738 CX_TEST_ASSERT(cxListSize(list) == 0);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
739 CX_TEST_ASSERT(list->allocator == cxDefaultAllocator);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
740 CX_TEST_ASSERT(list->cmpfunc == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
741 CX_TEST_ASSERT(!cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
742 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
743 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
744 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
745
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
746 CX_TEST(test_list_arl_create_simple_for_pointers) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
747 CxList *list = cxArrayListCreateSimple(CX_STORE_POINTERS, 8);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
748 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
749 CX_TEST_ASSERT(list != NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
750 CX_TEST_ASSERT(list->item_size == sizeof(void*));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
751 CX_TEST_ASSERT(list->simple_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
752 CX_TEST_ASSERT(list->advanced_destructor == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
753 CX_TEST_ASSERT(list->destructor_data == NULL);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
754 CX_TEST_ASSERT(cxListSize(list) == 0);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
755 CX_TEST_ASSERT(list->allocator == cxDefaultAllocator);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
756 CX_TEST_ASSERT(list->cmpfunc == cx_cmp_ptr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
757 CX_TEST_ASSERT(cxListIsStoringPointers(list));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
758 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
759 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
760 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
761
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
762 static void test_fake_simple_int_destr(void *elem) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
763 *(int *) elem = 42;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
764 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
765
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
766 CX_TEST(test_list_pll_destroy_no_destr) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
767 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
768 cx_testing_allocator_init(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
769 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
770 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
771 void *item = cxMalloc(alloc, sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
772 CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
773 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
774 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
775 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
776 // item is not yet freed
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
777 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
778 cxFree(alloc, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
779 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
780 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
781 cx_testing_allocator_destroy(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
782 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
783
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
784 CX_TEST(test_list_pll_destroy_simple_destr) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
785 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
786 int item = 0;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
787 CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
788 list->simple_destructor = test_fake_simple_int_destr;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
789 cxListAdd(list, &item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
790 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
791 CX_TEST_ASSERT(item == 42);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
792 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
793 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
794
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
795 CX_TEST(test_list_pll_destroy_adv_destr) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
796 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
797 cx_testing_allocator_init(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
798 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
799 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
800 void *item = cxMalloc(alloc, sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
801 CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
802 list->destructor_data = alloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
803 list->advanced_destructor = (cx_destructor_func2) cxFree;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
804 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
805 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
806 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
807 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
808 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
809 cx_testing_allocator_destroy(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
810 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
811
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
812 CX_TEST(test_list_parl_destroy_no_destr) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
813 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
814 cx_testing_allocator_init(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
815 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
816 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
817 void *item = cxMalloc(alloc, sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
818 CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
819 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
820 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
821 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
822 // item is not yet freed
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
823 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
824 cxFree(alloc, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
825 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
826 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
827 cx_testing_allocator_destroy(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
828 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
829
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
830 CX_TEST(test_list_parl_destroy_simple_destr) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
831 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
832 int item = 0;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
833 CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
834 list->simple_destructor = test_fake_simple_int_destr;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
835 cxListAdd(list, &item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
836 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
837 CX_TEST_ASSERT(item == 42);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
838 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
839 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
840
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
841 CX_TEST(test_list_parl_destroy_adv_destr) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
842 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
843 cx_testing_allocator_init(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
844 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
845 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
846 void *item = cxMalloc(alloc, sizeof(int));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
847 CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
848 list->destructor_data = alloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
849 list->advanced_destructor = (cx_destructor_func2) cxFree;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
850 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
851 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
852 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
853 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
854 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
855 cx_testing_allocator_destroy(&talloc);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
856 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
857
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
858 #define set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
859 CxTestingAllocator talloc; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
860 cx_testing_allocator_init(&talloc); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
861 CxAllocator *alloc = &talloc.base; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
862 CX_TEST_DO {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
863 #define tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
864 cxListDestroy(list); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
865 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));\
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
866 } \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
867 cx_testing_allocator_destroy(&talloc);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
868 #define roll_out_test_combos(name, body) \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
869 static CX_TEST_SUBROUTINE(test_list_verify_##name, CxList *list, \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
870 __attribute__((__unused__)) bool isptrlist, \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
871 __attribute__((__unused__)) bool islinkedlist) body \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
872 CX_TEST(test_list_ll_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
873 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
874 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int)); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
875 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false, true); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
876 tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
877 } \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
878 CX_TEST(test_list_arl_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
879 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
880 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
881 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false, false); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
882 tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
883 } \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
884 CX_TEST(test_list_pll_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
885 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
886 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
887 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true, true); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
888 tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
889 } \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
890 CX_TEST(test_list_parl_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
891 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
892 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS, 8); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
893 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true, false); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
894 tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
895 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
896 #define array_init(...) {__VA_ARGS__}
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
897
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
898 static inline int *int_test_data_added_to_list(CxList *list, bool isptrlist, size_t len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
899 int *testdata = int_test_data(len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
900 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
901 cx_for_n(i, len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
902 cxListAdd(list, &testdata[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
903 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
904 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
905 cxListAddArray(list, testdata, len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
906 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
907 return testdata;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
908 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
909
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
910 roll_out_test_combos(add, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
911 const size_t len = 250;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
912 int *testdata = int_test_data(len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
913 cx_for_n (i, len) CX_TEST_ASSERT(cxListAdd(list, &testdata[i]) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
914 CX_TEST_ASSERT(cxListSize(list) == len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
915 cx_for_n (i, len) CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
916 cx_for_n (i, len) ++testdata[i];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
917 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
918 cx_for_n (i, len) CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
919 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
920 cx_for_n (i, len) CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[i] - 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
921 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
922 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
923 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
924
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
925 roll_out_test_combos(insert, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
926 int a = 5;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
927 int b = 47;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
928 int c = 13;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
929 int d = 42;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
930 CX_TEST_ASSERT(cxListInsert(list, 1, &a) != 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
931 CX_TEST_ASSERT(cxListSize(list) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
932 CX_TEST_ASSERT(cxListInsert(list, 0, &a) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
933 CX_TEST_ASSERT(cxListSize(list) == 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
934 CX_TEST_ASSERT(cxListInsert(list, 0, &b) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
935 CX_TEST_ASSERT(cxListSize(list) == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
936 CX_TEST_ASSERT(cxListInsert(list, 1, &c) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
937 CX_TEST_ASSERT(cxListSize(list) == 3);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
938 CX_TEST_ASSERT(cxListInsert(list, 3, &d) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
939 CX_TEST_ASSERT(cxListSize(list) == 4);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
940 CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == 47);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
941 CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == 13);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
942 CX_TEST_ASSERT(*(int *) cxListAt(list, 2) == 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
943 CX_TEST_ASSERT(*(int *) cxListAt(list, 3) == 42);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
944 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
945
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
946 roll_out_test_combos(insert_array, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
947 int a[5] = array_init(5, 47, 11, 13, 42);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
948 int b[5] = array_init(9, 18, 72, 50, 7);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
949 int *aptr[5];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
950 int *bptr[5];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
951 cx_for_n(i, 5) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
952 aptr[i] = &a[i];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
953 bptr[i] = &b[i];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
954 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
955
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
956 size_t inserted;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
957
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
958 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
959 inserted = cxListInsertArray(list, 0, aptr, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
960 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
961 inserted = cxListInsertArray(list, 0, a, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
962 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
963 CX_TEST_ASSERT(inserted == 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
964 CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
965 CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == 47);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
966 CX_TEST_ASSERT(*(int *) cxListAt(list, 2) == 11);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
967 CX_TEST_ASSERT(*(int *) cxListAt(list, 3) == 13);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
968 CX_TEST_ASSERT(*(int *) cxListAt(list, 4) == 42);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
969 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
970 inserted = cxListInsertArray(list, 3, bptr, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
971 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
972 inserted = cxListInsertArray(list, 3, b, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
973 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
974 CX_TEST_ASSERT(inserted == 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
975 CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
976 CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == 47);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
977 CX_TEST_ASSERT(*(int *) cxListAt(list, 2) == 11);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
978 CX_TEST_ASSERT(*(int *) cxListAt(list, 3) == 9);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
979 CX_TEST_ASSERT(*(int *) cxListAt(list, 4) == 18);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
980 CX_TEST_ASSERT(*(int *) cxListAt(list, 5) == 72);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
981 CX_TEST_ASSERT(*(int *) cxListAt(list, 6) == 50);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
982 CX_TEST_ASSERT(*(int *) cxListAt(list, 7) == 7);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
983 CX_TEST_ASSERT(*(int *) cxListAt(list, 8) == 13);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
984 CX_TEST_ASSERT(*(int *) cxListAt(list, 9) == 42);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
985 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
986
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
987 roll_out_test_combos(remove, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
988 const size_t testdata_len = 32;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
989 int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
990
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
991 CX_TEST_ASSERT(cxListRemove(list, 2) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
992 CX_TEST_ASSERT(cxListRemove(list, 4) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
993 CX_TEST_ASSERT(cxListSize(list) == testdata_len - 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
994 CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == testdata[0]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
995 CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == testdata[1]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
996 CX_TEST_ASSERT(*(int *) cxListAt(list, 2) == testdata[3]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
997 CX_TEST_ASSERT(*(int *) cxListAt(list, 3) == testdata[4]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
998 CX_TEST_ASSERT(*(int *) cxListAt(list, 4) == testdata[6]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
999 CX_TEST_ASSERT(cxListRemove(list, 0) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1000 CX_TEST_ASSERT(cxListSize(list) == testdata_len - 3);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1001 CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == testdata[1]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1002 CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == testdata[3]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1003 CX_TEST_ASSERT(cxListRemove(list, testdata_len) != 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1004 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1005 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1006
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1007 roll_out_test_combos(find_remove, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1008 const size_t testdata_len = 250;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1009 int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1010
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1011 int exp = rand() % testdata_len; // NOLINT(cert-msc50-cpp)
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1012 int val = testdata[exp];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1013 // randomly picked number could occur earlier in list - find first position
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1014 for (int i = 0 ; i < exp ; i++) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1015 if (testdata[i] == val) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1016 exp = i;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1017 break;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1018 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1019 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1020 CX_TEST_ASSERT(cxListSize(list) == testdata_len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1021 CX_TEST_ASSERT(cxListFind(list, &val) == exp);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1022 CX_TEST_ASSERT(cxListFindRemove(list, &val) == exp);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1023 CX_TEST_ASSERT(cxListSize(list) == testdata_len - 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1024 CX_TEST_ASSERT(cxListFind(list, &val) != exp);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1025
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1026 int notinlist = -1;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1027 CX_TEST_ASSERT(cxListFindRemove(list, &notinlist) < 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1028 CX_TEST_ASSERT(cxListSize(list) == testdata_len - 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1029
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1030 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1031 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1032
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1033 roll_out_test_combos(clear, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1034 int *testdata = int_test_data_added_to_list(list, isptrlist, 8);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1035 CX_TEST_ASSERT(cxListSize(list) > 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1036 cxListClear(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1037 CX_TEST_ASSERT(cxListSize(list) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1038 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1039 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1040
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1041 roll_out_test_combos(at, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1042 size_t len = 128;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1043 int *testdata = int_test_data_added_to_list(list, isptrlist, 128);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1044 CX_TEST_ASSERT(cxListSize(list) == len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1045 cx_for_n (i, len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1046 CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1047 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1048 CX_TEST_ASSERT(cxListAt(list, cxListSize(list)) == NULL);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1049 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1050 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1051
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1052 roll_out_test_combos(swap, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1053 int original[16] = array_init(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1054 int swapped[16] = array_init(8, 4, 14, 3, 1, 5, 9, 12, 0, 6, 11, 10, 7, 15, 2, 13);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1055
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1056 cx_for_n(i, 16) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1057 cxListAdd(list, &original[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1058 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1059
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1060 CX_TEST_ASSERT(0 == cxListSwap(list, 1, 4));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1061 CX_TEST_ASSERT(0 == cxListSwap(list, 2, 14));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1062 CX_TEST_ASSERT(0 == cxListSwap(list, 9, 6));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1063 CX_TEST_ASSERT(0 == cxListSwap(list, 3, 3));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1064 CX_TEST_ASSERT(0 == cxListSwap(list, 10, 11));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1065 CX_TEST_ASSERT(0 == cxListSwap(list, 8, 0));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1066 CX_TEST_ASSERT(0 == cxListSwap(list, 7, 12));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1067 CX_TEST_ASSERT(0 == cxListSwap(list, 13, 15));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1068
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1069 CX_TEST_ASSERT(0 != cxListSwap(list, 5, 16));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1070 CX_TEST_ASSERT(0 != cxListSwap(list, 16, 6));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1071 CX_TEST_ASSERT(0 != cxListSwap(list, 16, 17));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1072
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1073 CxIterator iter = cxListIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1074 cx_foreach(int*, e, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1075 CX_TEST_ASSERT(*e == swapped[iter.index]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1076 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1077 iter = cxListBackwardsIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1078 cx_foreach(int*, e, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1079 CX_TEST_ASSERT(*e == swapped[iter.index]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1080 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1081 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1082
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1083 roll_out_test_combos(swap_no_sbo, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1084 if (islinkedlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1085 CX_DISABLE_LINKED_LIST_SWAP_SBO = true;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1086 CX_TEST_CALL_SUBROUTINE(test_list_verify_swap, list, isptrlist, true);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1087 CX_DISABLE_LINKED_LIST_SWAP_SBO = false;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1088 } else {
804
5136f2fc32ec add CX_DISABLE_ARRAY_LIST_SWAP_SBO flag
Mike Becker <universe@uap-core.de>
parents: 803
diff changeset
1089 CX_DISABLE_ARRAY_LIST_SWAP_SBO = true;
5136f2fc32ec add CX_DISABLE_ARRAY_LIST_SWAP_SBO flag
Mike Becker <universe@uap-core.de>
parents: 803
diff changeset
1090 CX_TEST_CALL_SUBROUTINE(test_list_verify_swap, list, isptrlist, false);
5136f2fc32ec add CX_DISABLE_ARRAY_LIST_SWAP_SBO flag
Mike Becker <universe@uap-core.de>
parents: 803
diff changeset
1091 CX_DISABLE_ARRAY_LIST_SWAP_SBO = false;
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1092 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1093 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1094
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1095 roll_out_test_combos(find, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1096 const size_t testdata_len = 500;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1097 int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1098
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1099 cx_for_n (attempt, 25) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1100 int exp = rand() % testdata_len; // NOLINT(cert-msc50-cpp)
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1101 int val = testdata[exp];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1102 // randomly picked number could occur earlier in list - find first position
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1103 for (int i = 0 ; i < exp ; i++) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1104 if (testdata[i] == val) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1105 exp = i;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1106 break;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1107 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1108 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1109 CX_TEST_ASSERT(cxListFind(list, &val) == exp);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1110 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1111
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1112 int notinlist = -1;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1113 CX_TEST_ASSERT(cxListFind(list, &notinlist) < 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1114
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1115 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1116 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1117
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1118 roll_out_test_combos(sort, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1119 const size_t testdata_len = 250;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1120 int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1121 int *expected = malloc(testdata_len*sizeof(int));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1122 memcpy(expected, testdata, testdata_len*sizeof(int));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1123 qsort(expected, testdata_len, sizeof(int), cx_cmp_int);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1124
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1125 cxListSort(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1126 cx_for_n (i, testdata_len) CX_TEST_ASSERT(*(int *) cxListAt(list, i) == expected[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1127
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1128 free(expected);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1129 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1130 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1131
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1132 roll_out_test_combos(reverse, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1133 const size_t testdata_len = 50;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1134 int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1135 cxListReverse(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1136 cx_for_n(i, testdata_len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1137 CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[testdata_len - 1 - i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1138 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1139 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1140 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1141
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1142 roll_out_test_combos(iterator, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1143 const size_t len = 50;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1144 int *testdata = int_test_data_added_to_list(list, isptrlist, len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1145
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1146 CxIterator iter = cxListIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1147 size_t i = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1148 cx_foreach(int*, x, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1149 CX_TEST_ASSERT(i == iter.index);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1150 CX_TEST_ASSERT(*x == testdata[iter.index]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1151 i++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1152 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1153 CX_TEST_ASSERT(i == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1154 iter = cxListBackwardsIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1155 cx_foreach(int*, x, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1156 CX_TEST_ASSERT(i - 1 == iter.index);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1157 CX_TEST_ASSERT(*x == testdata[iter.index]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1158 i--;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1159 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1160 CX_TEST_ASSERT(i == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1161 i = len / 2;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1162 CxMutIterator mut_iter = cxListMutIteratorAt(list, i);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1163 size_t j = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1164 cx_foreach(int*, x, mut_iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1165 CX_TEST_ASSERT(mut_iter.index == len / 2 + j / 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1166 CX_TEST_ASSERT(*x == testdata[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1167 if (i % 2 == 1) cxIteratorFlagRemoval(mut_iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1168 i++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1169 j++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1170 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1171 CX_TEST_ASSERT(i == len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1172 i = len / 2;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1173 j = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1174 mut_iter = cxListMutBackwardsIteratorAt(list, i - 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1175 cx_foreach(int*, x, mut_iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1176 CX_TEST_ASSERT(mut_iter.index == len / 2 - 1 - j);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1177 CX_TEST_ASSERT(*x == testdata[i - 1]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1178 if (i % 2 == 0) cxIteratorFlagRemoval(mut_iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1179 i--;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1180 j++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1181 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1182 CX_TEST_ASSERT(i == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1183 CX_TEST_ASSERT(cxListSize(list) == len / 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1184 cx_for_n(k, len / 2) CX_TEST_ASSERT(*(int *) cxListAt(list, k) == testdata[k * 2]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1185
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1186 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1187 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1188
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1189 roll_out_test_combos(insert_with_iterator, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1190 int fivenums[] = array_init(0, 1, 2, 3, 4);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1191 cx_for_n(i, 5) cxListAdd(list, &fivenums[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1192 int newdata[] = array_init(10, 20, 30, 40, 50);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1193
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1194 CxMutIterator iter = cxListMutIteratorAt(list, 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1195 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1196 CX_TEST_ASSERT(iter.index == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1197 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1198 cxListInsertAfter(&iter, &newdata[0]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1199 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1200 CX_TEST_ASSERT(iter.index == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1201 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1202 cxListInsertBefore(&iter, &newdata[1]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1203 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1204 CX_TEST_ASSERT(iter.index == 3);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1205 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1206
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1207 iter = cxListMutIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1208 cxListInsertBefore(&iter, &newdata[2]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1209 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1210 CX_TEST_ASSERT(iter.index == 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1211 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1212 iter = cxListMutIteratorAt(list, cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1213 cxListInsertBefore(&iter, &newdata[3]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1214 CX_TEST_ASSERT(!cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1215 CX_TEST_ASSERT(iter.index == 9);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1216 iter = cxListMutIteratorAt(list, cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1217 cxListInsertAfter(&iter, &newdata[4]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1218 CX_TEST_ASSERT(!cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1219 CX_TEST_ASSERT(iter.index == 10);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1220
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1221 int expdata[] = array_init(30, 0, 1, 20, 2, 10, 3, 4, 40, 50);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1222 cx_for_n (j, 10) CX_TEST_ASSERT(*(int *) cxListAt(list, j) == expdata[j]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1223 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1224
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1225 static CX_TEST_SUBROUTINE(test_list_verify_compare, CxList *left, CxList *right) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1226 CX_TEST_ASSERTM(cxListCompare(left, right) == 0, "lists don't start identical");
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1227 int x = 42;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1228 cxListAdd(left, &x);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1229 CX_TEST_ASSERT(cxListSize(left) > cxListSize(right));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1230 CX_TEST_ASSERT(cxListCompare(left, right) > 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1231 CX_TEST_ASSERT(cxListCompare(right, left) < 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1232 cxListAdd(right, &x);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1233 CX_TEST_ASSERT(cxListSize(left) == cxListSize(right));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1234 CX_TEST_ASSERT(cxListCompare(left, right) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1235 int a = 5, b = 10;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1236 cxListInsert(left, 15, &a);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1237 cxListInsert(right, 15, &b);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1238 CX_TEST_ASSERT(cxListSize(left) == cxListSize(right));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1239 CX_TEST_ASSERT(cxListCompare(left, right) < 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1240 CX_TEST_ASSERT(cxListCompare(right, left) > 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1241 *(int *) cxListAt(left, 15) = 10;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1242 CX_TEST_ASSERT(cxListCompare(left, right) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1243 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1244
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1245 #define roll_out_compare_tests(suffix, otherctr) \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1246 roll_out_test_combos(compare_##suffix, { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1247 const size_t len = 47; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1248 int *testdata = int_test_data_added_to_list(list, isptrlist, len); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1249 CxList *other = otherctr; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1250 cx_for_n(i, len) cxListAdd(other, &testdata[i]); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1251 CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1252 cxListDestroy(other); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1253 free(testdata); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1254 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1255
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1256 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1257 ll, cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int))
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1258 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1259
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1260 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1261 pll, cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS)
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1262 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1263
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1264 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1265 arl, cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 50)
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1266 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1267
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1268 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1269 parl, cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 50)
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1270 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1271
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1272 static unsigned destr_test_ctr;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1273 static int destr_last_value;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1274
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1275 static void simple_destr_test_fun(void *data) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1276 int *ptr = data;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1277 destr_last_value = *ptr;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1278 *ptr = destr_last_value + 1;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1279 destr_test_ctr++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1280 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1281
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1282 static void advanced_destr_test_fun(__attribute__((__unused__)) void *u, void *data) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1283 simple_destr_test_fun(data);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1284 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1285
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1286 static CX_TEST_SUBROUTINE(test_list_verify_destructor, CxList *list,
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1287 int const *testdata, size_t testdata_len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1288 destr_test_ctr = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1289
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1290 int off = cxListIsStoringPointers(list) ? 1 : 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1291
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1292 cxListRemove(list, 15);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1293 CX_TEST_ASSERT(1 == destr_test_ctr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1294 CX_TEST_ASSERT(testdata[15] == destr_last_value + off);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1295 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1296 cxListRemove(list, 47);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1297 CX_TEST_ASSERT(2 == destr_test_ctr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1298 CX_TEST_ASSERT(testdata[48] == destr_last_value + off);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1299 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1300
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1301 CxMutIterator iter = cxListMutIteratorAt(list, 7);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1302 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1303 CX_TEST_ASSERT(2 == destr_test_ctr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1304 CX_TEST_ASSERT(testdata[48] == destr_last_value + off);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1305 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1306 cxIteratorFlagRemoval(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1307 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1308 CX_TEST_ASSERT(3 == destr_test_ctr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1309 CX_TEST_ASSERT(testdata[8] == destr_last_value + off);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1310 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1311
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1312 iter = cxListMutBackwardsIteratorAt(list, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1313 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1314 CX_TEST_ASSERT(3 == destr_test_ctr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1315 CX_TEST_ASSERT(testdata[8] == destr_last_value + off);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1316 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1317 cxIteratorFlagRemoval(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1318 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1319 CX_TEST_ASSERT(4 == destr_test_ctr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1320 CX_TEST_ASSERT(testdata[4] == destr_last_value + off);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1321 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1322
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1323 cxListClear(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1324 CX_TEST_ASSERT(testdata_len == destr_test_ctr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1325 CX_TEST_ASSERT(testdata[testdata_len - 1] == destr_last_value + off);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1326 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1327
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1328 roll_out_test_combos(simple_destr, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1329 const size_t len = 60;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1330 int *testdata = int_test_data_added_to_list(list, isptrlist, len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1331 list->simple_destructor = simple_destr_test_fun;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1332 CX_TEST_CALL_SUBROUTINE(test_list_verify_destructor, list, testdata, len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1333 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1334 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1335
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1336 roll_out_test_combos(advanced_destr, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1337 const size_t len = 75;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1338 int *testdata = int_test_data_added_to_list(list, isptrlist, len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1339 list->advanced_destructor = advanced_destr_test_fun;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1340 CX_TEST_CALL_SUBROUTINE(test_list_verify_destructor, list, testdata, len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1341 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1342 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1343
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1344 CxTestSuite *cx_test_suite_array_list(void) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1345 CxTestSuite *suite = cx_test_suite_new("array_list");
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1346
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1347 cx_test_register(suite, test_list_arl_create);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1348 cx_test_register(suite, test_list_arl_create_simple);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1349 cx_test_register(suite, test_list_arl_create_simple_for_pointers);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1350 cx_test_register(suite, test_list_parl_destroy_no_destr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1351 cx_test_register(suite, test_list_parl_destroy_simple_destr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1352 cx_test_register(suite, test_list_parl_destroy_adv_destr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1353
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1354 cx_test_register(suite, test_list_arl_add);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1355 cx_test_register(suite, test_list_parl_add);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1356 cx_test_register(suite, test_list_arl_insert);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1357 cx_test_register(suite, test_list_parl_insert);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1358 cx_test_register(suite, test_list_arl_insert_array);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1359 cx_test_register(suite, test_list_parl_insert_array);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1360 cx_test_register(suite, test_list_arl_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1361 cx_test_register(suite, test_list_parl_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1362 cx_test_register(suite, test_list_arl_find_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1363 cx_test_register(suite, test_list_parl_find_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1364 cx_test_register(suite, test_list_arl_clear);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1365 cx_test_register(suite, test_list_parl_clear);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1366 cx_test_register(suite, test_list_arl_at);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1367 cx_test_register(suite, test_list_parl_at);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1368 cx_test_register(suite, test_list_arl_swap);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1369 cx_test_register(suite, test_list_parl_swap);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1370 cx_test_register(suite, test_list_arl_swap_no_sbo);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1371 cx_test_register(suite, test_list_parl_swap_no_sbo);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1372 cx_test_register(suite, test_list_arl_find);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1373 cx_test_register(suite, test_list_parl_find);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1374 cx_test_register(suite, test_list_arl_sort);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1375 cx_test_register(suite, test_list_parl_sort);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1376 cx_test_register(suite, test_list_arl_reverse);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1377 cx_test_register(suite, test_list_parl_reverse);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1378 cx_test_register(suite, test_list_arl_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1379 cx_test_register(suite, test_list_parl_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1380 cx_test_register(suite, test_list_arl_insert_with_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1381 cx_test_register(suite, test_list_parl_insert_with_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1382 cx_test_register(suite, test_list_arl_compare_ll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1383 cx_test_register(suite, test_list_arl_compare_arl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1384 cx_test_register(suite, test_list_arl_compare_pll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1385 cx_test_register(suite, test_list_arl_compare_parl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1386 cx_test_register(suite, test_list_parl_compare_ll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1387 cx_test_register(suite, test_list_parl_compare_arl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1388 cx_test_register(suite, test_list_parl_compare_pll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1389 cx_test_register(suite, test_list_parl_compare_parl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1390 cx_test_register(suite, test_list_arl_simple_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1391 cx_test_register(suite, test_list_parl_simple_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1392 cx_test_register(suite, test_list_arl_advanced_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1393 cx_test_register(suite, test_list_parl_advanced_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1394
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1395 return suite;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1396 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1397
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1398 CxTestSuite *cx_test_suite_linked_list(void) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1399 CxTestSuite *suite = cx_test_suite_new("linked_list");
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1400
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1401 cx_test_register(suite, test_linked_list_link_unlink);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1402 cx_test_register(suite, test_linked_list_at);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1403 cx_test_register(suite, test_linked_list_find);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1404 cx_test_register(suite, test_linked_list_compare);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1405 cx_test_register(suite, test_linked_list_add);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1406 cx_test_register(suite, test_linked_list_prepend);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1407 cx_test_register(suite, test_linked_list_insert);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1408 cx_test_register(suite, test_linked_list_insert_chain);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1409 cx_test_register(suite, test_linked_list_first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1410 cx_test_register(suite, test_linked_list_last);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1411 cx_test_register(suite, test_linked_list_prev);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1412 cx_test_register(suite, test_linked_list_remove);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1413 cx_test_register(suite, test_linked_list_size);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1414 cx_test_register(suite, test_linked_list_sort_empty);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1415 cx_test_register(suite, test_linked_list_sort);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1416 cx_test_register(suite, test_linked_list_reverse);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1417
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1418 cx_test_register(suite, test_list_ll_create);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1419 cx_test_register(suite, test_list_ll_create_simple);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1420 cx_test_register(suite, test_list_ll_store_pointers);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1421 cx_test_register(suite, test_list_ll_create_simple_for_pointers);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1422 cx_test_register(suite, test_list_pll_destroy_no_destr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1423 cx_test_register(suite, test_list_pll_destroy_simple_destr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1424 cx_test_register(suite, test_list_pll_destroy_adv_destr);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1425
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1426 cx_test_register(suite, test_list_ll_add);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1427 cx_test_register(suite, test_list_pll_add);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1428 cx_test_register(suite, test_list_ll_insert);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1429 cx_test_register(suite, test_list_pll_insert);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1430 cx_test_register(suite, test_list_ll_insert_array);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1431 cx_test_register(suite, test_list_pll_insert_array);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1432 cx_test_register(suite, test_list_ll_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1433 cx_test_register(suite, test_list_pll_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1434 cx_test_register(suite, test_list_ll_find_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1435 cx_test_register(suite, test_list_pll_find_remove);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1436 cx_test_register(suite, test_list_ll_clear);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1437 cx_test_register(suite, test_list_pll_clear);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1438 cx_test_register(suite, test_list_ll_at);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1439 cx_test_register(suite, test_list_pll_at);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1440 cx_test_register(suite, test_list_ll_swap);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1441 cx_test_register(suite, test_list_pll_swap);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1442 cx_test_register(suite, test_list_ll_swap_no_sbo);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1443 cx_test_register(suite, test_list_pll_swap_no_sbo);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1444 cx_test_register(suite, test_list_ll_find);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1445 cx_test_register(suite, test_list_pll_find);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1446 cx_test_register(suite, test_list_ll_sort);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1447 cx_test_register(suite, test_list_pll_sort);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1448 cx_test_register(suite, test_list_ll_reverse);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1449 cx_test_register(suite, test_list_pll_reverse);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1450 cx_test_register(suite, test_list_ll_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1451 cx_test_register(suite, test_list_pll_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1452 cx_test_register(suite, test_list_ll_insert_with_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1453 cx_test_register(suite, test_list_pll_insert_with_iterator);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1454 cx_test_register(suite, test_list_ll_compare_ll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1455 cx_test_register(suite, test_list_ll_compare_arl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1456 cx_test_register(suite, test_list_ll_compare_pll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1457 cx_test_register(suite, test_list_ll_compare_parl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1458 cx_test_register(suite, test_list_pll_compare_ll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1459 cx_test_register(suite, test_list_pll_compare_arl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1460 cx_test_register(suite, test_list_pll_compare_pll);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1461 cx_test_register(suite, test_list_pll_compare_parl);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1462 cx_test_register(suite, test_list_ll_simple_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1463 cx_test_register(suite, test_list_pll_simple_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1464 cx_test_register(suite, test_list_ll_advanced_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1465 cx_test_register(suite, test_list_pll_advanced_destr);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1466
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1467 return suite;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1468 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1469
800
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1470 CxTestSuite *cx_test_suite_empty_list(void) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1471 CxTestSuite *suite = cx_test_suite_new("empty list dummy");
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1472
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1473 cx_test_register(suite, test_empty_list_size);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1474 cx_test_register(suite, test_empty_list_iterator);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1475 cx_test_register(suite, test_empty_list_noops);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1476 cx_test_register(suite, test_empty_list_at);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1477 cx_test_register(suite, test_empty_list_find);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1478 cx_test_register(suite, test_empty_list_compare);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1479
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1480 return suite;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1481 }

mercurial