tests/test_list.c

Tue, 17 Sep 2024 23:32:27 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 17 Sep 2024 23:32:27 +0200
changeset 887
e5181fe13b9c
parent 886
5f5514bb104b
child 890
54565fd74e74
permissions
-rw-r--r--

fix documentation

relates to #424

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
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
39 CX_TEST(test_array_add) {
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
40 int stackspace[5] = {1,1,2,3,5};
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
41 int *stackarray = stackspace;
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
42 size_t stackarray_size = 3;
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
43 size_t stackarray_capacity = 5;
834
04c53b3c8378 capitalize cx_array_declare()
Mike Becker <universe@uap-core.de>
parents: 832
diff changeset
44 CX_ARRAY_DECLARE(int, heaparray);
831
7970eac1c598 add convenience macros for cx_array_*
Mike Becker <universe@uap-core.de>
parents: 819
diff changeset
45 heaparray = calloc(5, sizeof(int));
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
46 heaparray[0] = 2;
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
47 heaparray[1] = 3;
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
48 heaparray[2] = 5;
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
49 heaparray[3] = 7;
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
50 heaparray[4] = 11;
831
7970eac1c598 add convenience macros for cx_array_*
Mike Becker <universe@uap-core.de>
parents: 819
diff changeset
51 heaparray_size = 3;
7970eac1c598 add convenience macros for cx_array_*
Mike Becker <universe@uap-core.de>
parents: 819
diff changeset
52 heaparray_capacity = 5;
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
53 int elem = 8, elem2 = 47;
819
5da2ead43077 rename cx_array_copy_result to just cx_array_result
Mike Becker <universe@uap-core.de>
parents: 818
diff changeset
54 enum cx_array_result result;
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
55 CX_TEST_DO {
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
56 result = cx_array_add(&stackarray, &stackarray_size, &stackarray_capacity, sizeof(int), &elem, NULL);
819
5da2ead43077 rename cx_array_copy_result to just cx_array_result
Mike Becker <universe@uap-core.de>
parents: 818
diff changeset
57 CX_TEST_ASSERT(result == CX_ARRAY_SUCCESS);
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
58 CX_TEST_ASSERT(stackarray[0] == 1);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
59 CX_TEST_ASSERT(stackarray[1] == 1);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
60 CX_TEST_ASSERT(stackarray[2] == 2);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
61 CX_TEST_ASSERT(stackarray[3] == 8);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
62 CX_TEST_ASSERT(stackarray[4] == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
63 CX_TEST_ASSERT(stackarray_size == 4);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
64 CX_TEST_ASSERT(stackarray_capacity == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
65
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
66 stackarray_size = 5;
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
67 result = cx_array_add(&stackarray, &stackarray_size, &stackarray_capacity, sizeof(int), &elem2, NULL);
819
5da2ead43077 rename cx_array_copy_result to just cx_array_result
Mike Becker <universe@uap-core.de>
parents: 818
diff changeset
68 CX_TEST_ASSERT(result == CX_ARRAY_REALLOC_NOT_SUPPORTED);
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
69 CX_TEST_ASSERT(stackarray[0] == 1);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
70 CX_TEST_ASSERT(stackarray[1] == 1);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
71 CX_TEST_ASSERT(stackarray[2] == 2);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
72 CX_TEST_ASSERT(stackarray[3] == 8);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
73 CX_TEST_ASSERT(stackarray[4] == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
74 CX_TEST_ASSERT(stackarray_size == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
75 CX_TEST_ASSERT(stackarray_capacity == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
76
832
97df2e4c68fb make cx_array_simple_add() automatically take the address of the element
Mike Becker <universe@uap-core.de>
parents: 831
diff changeset
77 result = cx_array_simple_add(heaparray, elem);
819
5da2ead43077 rename cx_array_copy_result to just cx_array_result
Mike Becker <universe@uap-core.de>
parents: 818
diff changeset
78 CX_TEST_ASSERT(result == CX_ARRAY_SUCCESS);
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
79 CX_TEST_ASSERT(heaparray[0] == 2);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
80 CX_TEST_ASSERT(heaparray[1] == 3);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
81 CX_TEST_ASSERT(heaparray[2] == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
82 CX_TEST_ASSERT(heaparray[3] == 8);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
83 CX_TEST_ASSERT(heaparray[4] == 11);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
84 CX_TEST_ASSERT(heaparray_size == 4);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
85 CX_TEST_ASSERT(heaparray_capacity == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
86
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
87 heaparray_size = 5;
832
97df2e4c68fb make cx_array_simple_add() automatically take the address of the element
Mike Becker <universe@uap-core.de>
parents: 831
diff changeset
88 result = cx_array_simple_add(heaparray, elem2);
819
5da2ead43077 rename cx_array_copy_result to just cx_array_result
Mike Becker <universe@uap-core.de>
parents: 818
diff changeset
89 CX_TEST_ASSERT(result == CX_ARRAY_SUCCESS);
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
90 CX_TEST_ASSERT(heaparray[0] == 2);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
91 CX_TEST_ASSERT(heaparray[1] == 3);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
92 CX_TEST_ASSERT(heaparray[2] == 5);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
93 CX_TEST_ASSERT(heaparray[3] == 8);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
94 CX_TEST_ASSERT(heaparray[4] == 11);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
95 CX_TEST_ASSERT(heaparray[5] == 47);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
96 CX_TEST_ASSERT(heaparray_size == 6);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
97 CX_TEST_ASSERT(heaparray_capacity >= 6);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
98 }
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
99 free(heaparray);
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
100 }
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
101
883
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
102 CX_TEST(test_array_insert_sorted) {
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
103 int d1 = 50;
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
104 int d2 = 80;
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
105 int d3 = 60;
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
106 int d4 = 40;
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
107 int d5 = 70;
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
108 int d6a[6] = {52, 54, 56, 62, 64, 75};
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
109 int d7a[6] = {51, 57, 58, 65, 77, 78};
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
110 int d8 = 90;
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
111 int expected[18] = {
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
112 40, 50, 51, 52, 54, 56, 57, 58, 60,
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
113 62, 64, 65, 70, 75, 77, 78, 80, 90
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
114 };
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
115
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
116 CX_ARRAY_DECLARE(int, array);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
117 cx_array_initialize(array, 4);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
118
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
119 CX_TEST_DO {
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
120 CX_TEST_ASSERT(0 == cx_array_simple_add_sorted(array, d1, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
121 CX_TEST_ASSERT(array_size == 1);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
122 CX_TEST_ASSERT(array_capacity == 4);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
123 CX_TEST_ASSERT(0 == cx_array_simple_add_sorted(array, d2, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
124 CX_TEST_ASSERT(array_size == 2);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
125 CX_TEST_ASSERT(array_capacity == 4);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
126 CX_TEST_ASSERT(0 == cx_array_simple_add_sorted(array, d3, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
127 CX_TEST_ASSERT(array_size == 3);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
128 CX_TEST_ASSERT(array_capacity == 4);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
129 CX_TEST_ASSERT(0 == cx_array_simple_add_sorted(array, d4, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
130 CX_TEST_ASSERT(array_size == 4);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
131 CX_TEST_ASSERT(array_capacity == 4);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
132 CX_TEST_ASSERT(0 == cx_array_simple_add_sorted(array, d5, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
133 CX_TEST_ASSERT(array_size == 5);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
134 CX_TEST_ASSERT(array_capacity >= 5);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
135 CX_TEST_ASSERT(0 == cx_array_simple_insert_sorted(array, d6a, 6, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
136 CX_TEST_ASSERT(array_size == 11);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
137 CX_TEST_ASSERT(array_capacity >= 11);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
138 CX_TEST_ASSERT(0 == cx_array_simple_insert_sorted(array, d7a, 6, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
139 CX_TEST_ASSERT(array_size == 17);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
140 CX_TEST_ASSERT(array_capacity >= 17);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
141 CX_TEST_ASSERT(0 == cx_array_simple_add_sorted(array, d8, cx_cmp_int));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
142 CX_TEST_ASSERT(array_size == 18);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
143 CX_TEST_ASSERT(array_capacity >= 18);
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
144
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
145 CX_TEST_ASSERT(0 == memcmp(array, expected, 18 * sizeof(int)));
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
146 }
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
147 }
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
148
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
149 CX_TEST(test_array_binary_search) {
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
150 int array[18] = {
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
151 40, 50, 51, 52, 54, 56, 57, 58, 60,
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
152 62, 64, 65, 70, 75, 77, 78, 80, 90
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
153 };
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
154
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
155 CX_TEST_DO {
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
156 cx_for_n(i, 18) {
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
157 CX_TEST_ASSERT(i == cx_array_binary_search(array, 18, sizeof(int), &array[i], cx_cmp_int));
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
158 }
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
159
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
160 int s = 58;
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
161 CX_TEST_ASSERT(7 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
162 CX_TEST_ASSERT(7 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
163 s = 60;
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
164 CX_TEST_ASSERT(8 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
165 CX_TEST_ASSERT(8 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
166 s = 59;
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
167 CX_TEST_ASSERT(7 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
168 CX_TEST_ASSERT(8 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
169 CX_TEST_ASSERT(18 == cx_array_binary_search(array, 18, sizeof(int), &s, cx_cmp_int));
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
170 s = 79;
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
171 CX_TEST_ASSERT(15 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
172 CX_TEST_ASSERT(16 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
173 CX_TEST_ASSERT(18 == cx_array_binary_search(array, 18, sizeof(int), &s, cx_cmp_int));
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
174 s = 66;
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
175 CX_TEST_ASSERT(11 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
176 CX_TEST_ASSERT(12 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
177 CX_TEST_ASSERT(18 == cx_array_binary_search(array, 18, sizeof(int), &s, cx_cmp_int));
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
178 s = 69;
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
179 CX_TEST_ASSERT(11 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
180 CX_TEST_ASSERT(12 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
181 CX_TEST_ASSERT(18 == cx_array_binary_search(array, 18, sizeof(int), &s, cx_cmp_int));
885
878a450e79bd fixes incorrect result from cx_array_binary_search() when searched element is smaller than the entire array
Mike Becker <universe@uap-core.de>
parents: 884
diff changeset
182 s = 95;
878a450e79bd fixes incorrect result from cx_array_binary_search() when searched element is smaller than the entire array
Mike Becker <universe@uap-core.de>
parents: 884
diff changeset
183 CX_TEST_ASSERT(17 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
184 CX_TEST_ASSERT(18 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
885
878a450e79bd fixes incorrect result from cx_array_binary_search() when searched element is smaller than the entire array
Mike Becker <universe@uap-core.de>
parents: 884
diff changeset
185 CX_TEST_ASSERT(18 == cx_array_binary_search(array, 18, sizeof(int), &s, cx_cmp_int));
878a450e79bd fixes incorrect result from cx_array_binary_search() when searched element is smaller than the entire array
Mike Becker <universe@uap-core.de>
parents: 884
diff changeset
186 s = 30;
878a450e79bd fixes incorrect result from cx_array_binary_search() when searched element is smaller than the entire array
Mike Becker <universe@uap-core.de>
parents: 884
diff changeset
187 CX_TEST_ASSERT(18 == cx_array_binary_search_inf(array, 18, sizeof(int), &s, cx_cmp_int));
886
5f5514bb104b also add a binary search for the supremum
Mike Becker <universe@uap-core.de>
parents: 885
diff changeset
188 CX_TEST_ASSERT(0 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int));
885
878a450e79bd fixes incorrect result from cx_array_binary_search() when searched element is smaller than the entire array
Mike Becker <universe@uap-core.de>
parents: 884
diff changeset
189 CX_TEST_ASSERT(18 == cx_array_binary_search(array, 18, sizeof(int), &s, cx_cmp_int));
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
190 }
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
191 }
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
192
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
193 typedef struct node {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
194 struct node *next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
195 struct node *prev;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
196 int data;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
197 } node;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
198
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
199 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
200 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
201 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
202
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
203 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
204 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
205 void *prev = begin;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
206 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
207 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
208 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
209 prev = n;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
210 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
211 return begin;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
212 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
213
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
214 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
215 va_list ap;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
216 va_start(ap, n);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
217 while (n != NULL) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
218 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
219 n = n->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
220 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
221 va_end(ap);
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
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
224 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
225 while (n != NULL) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
226 void *next = n->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
227 free(n);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
228 n = next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
229 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
230 }
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 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
233 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
234 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
235 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
236 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
237 return data;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
238 }
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 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
241 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
242
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
243 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
244 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
245 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
246 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
247 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
248 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
249
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
250 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
251 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
252 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
253 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
254 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
255
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
266 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
267
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
268 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
269 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
270
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
271 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
272 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
273 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
274
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
275 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
289 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
290
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
291 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
292 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
293 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
294 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
295 int s;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
296 s = 2;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
297 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
298 s = 4;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
299 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
300 s = 6;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
301 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
302 s = 8;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
303 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
304 s = 10;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
305 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
306 s = -2;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
307 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
308 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
309 destroy_nodes_test_data(list);
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_compare) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
313 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
314 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
315 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
316 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
317 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
318 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
319 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
320 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
321 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
322 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
323 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
324 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
325 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
326 destroy_nodes_test_data(la);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
327 destroy_nodes_test_data(lb);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
328 destroy_nodes_test_data(lc);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
329 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
330
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
331 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
332 node nodes[4];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
333 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
334 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
335 // 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
336 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
337 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
338
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
339 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
340 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
341 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
342 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
343 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
344
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
345 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
346 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
347 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
348 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
349 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
350
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
351 // 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
352 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
353 end = begin = NULL;
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_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
356 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
357 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
358 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
359 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
360 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
361
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
362 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
363 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
364 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
365
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
366 // 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
367 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
368 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
369
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
370 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
371 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
372 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
373 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
374 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
375 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
376
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
377 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
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[2]);
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[1]);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
381
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
382 // test with begin, end / next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
383 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
384 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
385
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
386 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
387 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
388 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
389 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
390 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
391 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
392 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
393 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
394 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
395
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
396 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
397 node nodes[4];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
398 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
399 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
400 // 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
401 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
402 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
403
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
404 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
405 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
406 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
407 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
408 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
409
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
410 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
411 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
412 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
413 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
414 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
415
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
416 // 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
417 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
418 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
419
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
420 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
421 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
422 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
423 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
424 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
425 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
426
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
427 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
428 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
429 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
430 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
431
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
432 // 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
433 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
434 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
435
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
436 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
437 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
438 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
439 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
440 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
441 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
442
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
443 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
444 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
445 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
446 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
447
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
448 // test with begin, end / next
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
449 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
450 end = begin = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
451
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
452 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
453 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
454 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
455 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
456 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
457 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
458 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
459 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
460 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
461 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
462 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
463 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
464 }
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_TEST(test_linked_list_insert) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
467 node nodes[4];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
468 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
469 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
470 // insert mid list
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
471 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
472 begin = &nodes[0];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
473 end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
474
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
475 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
476 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
477
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
486 // insert end
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
487 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
488 begin = &nodes[0];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
489 end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
490
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
491 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
492 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
493
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
494 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
495 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
496 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
497 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
498 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
499 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
500
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
501 // insert begin
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
502 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
503 begin = &nodes[0];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
504 end = &nodes[2];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
505
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
506 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
507 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
508
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
509 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
510 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
511 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
512 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
513 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
514 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
515 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
516 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
517
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
518 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
519 node nodes[5];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
520 void *begin, *end;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
521 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
522 // insert mid list
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
523 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
524 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
525
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
526 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
527 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
528 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
529
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
530 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
531 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
532 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
533 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
534 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
535 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
536 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
537
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
538 // insert end
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
539 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
540 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
541
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
542 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
543 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
544 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
545
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
546 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
547 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
548 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
549 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
550 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
551 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
552
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
553 // insert begin
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
554 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
555 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
556
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
557 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
558 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
559 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
560
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
561 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
562 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
563 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
564 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
565 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
566 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
567 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
568 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
569
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
570 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
571 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
572 void *begin = testdata;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
573 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
574 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
575 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
576 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
577 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
578 destroy_nodes_test_data(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
579 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
580
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
581 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
582 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
583 void *end = testdata->next->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
584 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
585 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
586 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
587 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
588 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
589 destroy_nodes_test_data(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
590 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
591
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
592 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
593 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
594 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
595 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
596 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
597 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
598 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
599 destroy_nodes_test_data(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
600 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
601
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
602 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
603 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
604 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
605 node *first = testdata;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
606 node *second = first->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
607 node *third = second->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
608 void *begin = testdata;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
609 void *end = third;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
610
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
611 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
612 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
613 CX_TEST_ASSERT(begin == first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
614 CX_TEST_ASSERT(end == third);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
615 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
616 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
617 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
618 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
619
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
620 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
621 CX_TEST_ASSERT(begin == first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
622 CX_TEST_ASSERT(end == first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
623 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
624 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
625
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
626 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
627 CX_TEST_ASSERT(begin == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
628 CX_TEST_ASSERT(end == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
629 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
630 // 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
631 free(first);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
632 free(second);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
633 free(third);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
634 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
635
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
636 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
637 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
638 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
639 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
640 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
641 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
642 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
643 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
644 destroy_nodes_test_data(td5);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
645 destroy_nodes_test_data(td13);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
646 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
647
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
648 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
649 void *begin = NULL;
799
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
650 CX_TEST_DO {
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
651 // 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
652 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
653 CX_TEST_ASSERT(true);
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
654 }
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
655 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
656
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
657 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
658 const size_t len = 1500;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
659 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
660 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
661 node *n = scrambled;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
662 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
663 n->data = testdata[i];
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
664 n = n->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
665 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
666 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
667 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
668 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
669
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
670 void *begin = scrambled;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
671 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
672
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
673 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
674 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
675 node *check = begin;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
676 node *check_last = NULL;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
677 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
678 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
679 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
680 if (i < len - 1) {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
681 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
682 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
683 check_last = check;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
684 check = check->next;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
685 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
686 CX_TEST_ASSERT(check == NULL);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
687 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
688 }
799
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
689 destroy_nodes_test_data(begin);
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
690 free(sorted);
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
691 free(testdata);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
692 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
693
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
694 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
695 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
696 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
697 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
698 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
699 void *begin = testdata;
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
700 CX_TEST_DO {
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
701 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
702 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
703
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
704 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
705 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
706 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
707 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
708 }
799
a2a757d225b4 fix some broken cleanup
Mike Becker <universe@uap-core.de>
parents: 798
diff changeset
709 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
710 destroy_nodes_test_data(expected);
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
711 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
712
800
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
713
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
714 CX_TEST(test_empty_list_size) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
715 CX_TEST_DO {
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
716 CX_TEST_ASSERT(cxEmptyList->collection.size == 0);
800
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
717 CX_TEST_ASSERT(cxListSize(cxEmptyList) == 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
718 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
719 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
720
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
721 CX_TEST(test_empty_list_iterator) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
722 CxList *list = cxEmptyList;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
723
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
724 CxIterator it1 = cxListIterator(list);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
725 CxIterator it2 = cxListBackwardsIterator(list);
853
d4baf4dd55c3 simplify iterator structures
Mike Becker <universe@uap-core.de>
parents: 850
diff changeset
726 CxIterator it3 = cxListMutIterator(list);
d4baf4dd55c3 simplify iterator structures
Mike Becker <universe@uap-core.de>
parents: 850
diff changeset
727 CxIterator it4 = cxListMutBackwardsIterator(list);
800
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
728
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
729 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
730 CX_TEST_ASSERT(!cxIteratorValid(it1));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
731 CX_TEST_ASSERT(!cxIteratorValid(it2));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
732 CX_TEST_ASSERT(!cxIteratorValid(it3));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
733 CX_TEST_ASSERT(!cxIteratorValid(it4));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
734
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
735 int c = 0;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
736 cx_foreach(void*, data, it1) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
737 cx_foreach(void*, data, it2) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
738 cx_foreach(void*, data, it3) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
739 cx_foreach(void*, data, it4) c++;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
740 CX_TEST_ASSERT(c == 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
741 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
742 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
743
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
744 CX_TEST(test_empty_list_noops) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
745 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
746 CxList copy = *cxEmptyList;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
747 cxListSort(cxEmptyList);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
748 cxListClear(cxEmptyList);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
749 cxListDestroy(cxEmptyList);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
750 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
751 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
752 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
753
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
754 CX_TEST(test_empty_list_at) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
755 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
756 CX_TEST_ASSERT(cxListAt(cxEmptyList, 0) == NULL);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
757 CX_TEST_ASSERT(cxListAt(cxEmptyList, 1) == NULL);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
758 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
759 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
760
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
761 CX_TEST(test_empty_list_find) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
762 int x = 42, y = 1337;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
763 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
764 CX_TEST_ASSERT(cxListFind(cxEmptyList, &x) < 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
765 CX_TEST_ASSERT(cxListFind(cxEmptyList, &y) < 0);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
766 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
767 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
768
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
769 CX_TEST(test_empty_list_compare) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
770 CxList *empty = cxEmptyList;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
771 CxList *ll = cxLinkedListCreateSimple(sizeof(int));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
772 CxList *al = cxArrayListCreateSimple(sizeof(int), 8);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
773 int x = 5;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
774 CX_TEST_DO {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
775 CX_TEST_ASSERT(0 == cxListCompare(empty, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
776 CX_TEST_ASSERT(0 == cxListCompare(ll, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
777 CX_TEST_ASSERT(0 == cxListCompare(al, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
778 CX_TEST_ASSERT(0 == cxListCompare(cxEmptyList, ll));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
779 CX_TEST_ASSERT(0 == cxListCompare(cxEmptyList, al));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
780
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
781 cxListAdd(ll, &x);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
782 cxListAdd(al, &x);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
783
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
784 CX_TEST_ASSERT(0 < cxListCompare(ll, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
785 CX_TEST_ASSERT(0 < cxListCompare(al, cxEmptyList));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
786 CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, ll));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
787 CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, al));
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
788 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
789 cxListDestroy(ll);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
790 cxListDestroy(al);
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
791 }
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
792
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
793 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
794 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
795 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
796 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
797 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
798 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
799 CX_TEST_ASSERT(list != NULL);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
800 CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
801 CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
802 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
803 CX_TEST_ASSERT(list->collection.destructor_data == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
804 CX_TEST_ASSERT(cxListSize(list) == 0);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
805 CX_TEST_ASSERT(list->collection.allocator == alloc);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
806 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
807 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
808 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
809 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
810 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
811 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
812 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
813
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
814 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
815 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
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 CX_TEST_ASSERT(list != NULL);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
818 CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
819 CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
820 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
821 CX_TEST_ASSERT(list->collection.destructor_data == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
822 CX_TEST_ASSERT(cxListSize(list) == 0);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
823 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
824 CX_TEST_ASSERT(list->collection.cmpfunc == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
825 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
826 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
827 cxListDestroy(list);
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_ll_store_pointers) {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
831 CxList *list = cxLinkedListCreateSimple(47);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
832 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
833 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
834 cxListStorePointers(list);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
835 CX_TEST_ASSERT(list->collection.elem_size == sizeof(void *));
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
836 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
837 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
838 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
839 cxListStoreObjects(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
840 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
841 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
842 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
843 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
844 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
845 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
846
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
847 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
848 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
849 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
850 CX_TEST_ASSERT(list != NULL);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
851 CX_TEST_ASSERT(list->collection.elem_size == sizeof(void*));
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
852 CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
853 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
854 CX_TEST_ASSERT(list->collection.destructor_data == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
855 CX_TEST_ASSERT(cxListSize(list) == 0);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
856 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
857 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
858 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
859 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
860 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
861 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
862
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
863 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
864 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
865 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
866 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
867 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
868 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
869 CX_TEST_ASSERT(list != NULL);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
870 CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
871 CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
872 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
873 CX_TEST_ASSERT(list->collection.destructor_data == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
874 CX_TEST_ASSERT(cxListSize(list) == 0);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
875 CX_TEST_ASSERT(list->collection.allocator == alloc);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
876 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
877 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
878 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
879 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
880 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
881 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
882 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
883
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
884 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
885 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
886 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
887 CX_TEST_ASSERT(list != NULL);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
888 CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
889 CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
890 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
891 CX_TEST_ASSERT(list->collection.destructor_data == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
892 CX_TEST_ASSERT(cxListSize(list) == 0);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
893 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
894 CX_TEST_ASSERT(list->collection.cmpfunc == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
895 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
896 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
897 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
898 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
899
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
900 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
901 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
902 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
903 CX_TEST_ASSERT(list != NULL);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
904 CX_TEST_ASSERT(list->collection.elem_size == sizeof(void*));
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
905 CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
906 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
907 CX_TEST_ASSERT(list->collection.destructor_data == NULL);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
908 CX_TEST_ASSERT(cxListSize(list) == 0);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
909 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
910 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr);
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
911 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
912 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
913 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
914 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
915
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
916 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
917 *(int *) elem = 42;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
918 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
919
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
920 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
921 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
922 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
923 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
924 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
925 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
926 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
927 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
928 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
929 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
930 // 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
931 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
932 cxFree(alloc, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
933 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
934 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
935 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
936 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
937
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
938 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
939 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
940 int item = 0;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
941 CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
942 list->collection.simple_destructor = test_fake_simple_int_destr;
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
943 cxListAdd(list, &item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
944 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
945 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
946 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
947 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
948
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
949 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
950 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
951 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
952 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
953 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
954 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
955 CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
956 list->collection.destructor_data = alloc;
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
957 list->collection.advanced_destructor = (cx_destructor_func2) cxFree;
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
958 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
959 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
960 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
961 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
962 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
963 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
964 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
965
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
966 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
967 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
968 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
969 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
970 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
971 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
972 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
973 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
974 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
975 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
976 // 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
977 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
978 cxFree(alloc, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
979 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
980 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
981 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
982 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
983
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
984 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
985 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
986 int item = 0;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
987 CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
988 list->collection.simple_destructor = test_fake_simple_int_destr;
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
989 cxListAdd(list, &item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
990 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
991 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
992 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
993 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
994
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
995 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
996 CxTestingAllocator talloc;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
997 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
998 CxAllocator *alloc = &talloc.base;
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
999 CX_TEST_DO {
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1000 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
1001 CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
1002 list->collection.destructor_data = alloc;
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
1003 list->collection.advanced_destructor = (cx_destructor_func2) cxFree;
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1004 cxListAdd(list, item);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1005 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
1006 cxListDestroy(list);
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1007 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
1008 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1009 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
1010 }
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1011
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1012 #define set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1013 CxTestingAllocator talloc; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1014 cx_testing_allocator_init(&talloc); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1015 CxAllocator *alloc = &talloc.base; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1016 CX_TEST_DO {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1017 #define tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1018 cxListDestroy(list); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1019 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
1020 } \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1021 cx_testing_allocator_destroy(&talloc);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1022 #define roll_out_test_invokers(name) \
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1023 CX_TEST(test_list_ll_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1024 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1025 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int)); \
807
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1026 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1027 tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1028 } \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1029 CX_TEST(test_list_arl_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1030 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1031 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); \
807
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1032 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1033 tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1034 } \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1035 CX_TEST(test_list_pll_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1036 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1037 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
807
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1038 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1039 tear_down_combo \
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 CX_TEST(test_list_parl_##name) { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1042 set_up_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1043 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS, 8); \
807
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1044 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1045 tear_down_combo \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1046 }
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1047 #define roll_out_test_combos(name, body) \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1048 static CX_TEST_SUBROUTINE(test_list_verify_##name, CxList *list, \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1049 __attribute__((__unused__)) bool isptrlist) body \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1050 roll_out_test_invokers(name)
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1051
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1052 static void set_default_class_funcs(CxList *list, cx_list_class *defaulted_cl) {
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1053 cx_list_class const *cl = list->climpl == NULL ? list->cl : list->climpl;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1054 memcpy(defaulted_cl, cl, sizeof(cx_list_class));
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1055 defaulted_cl->insert_array = cx_list_default_insert_array;
876
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1056 defaulted_cl->insert_sorted = cx_list_default_insert_sorted;
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1057 defaulted_cl->sort = cx_list_default_sort;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1058 defaulted_cl->swap = cx_list_default_swap;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1059 defaulted_cl->compare = NULL;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1060 if (list->climpl == NULL) {
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1061 list->cl = defaulted_cl;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1062 } else {
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1063 list->climpl = defaulted_cl;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1064 }
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1065 }
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1066
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1067 #define do_set_default_class_funcs(list) \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1068 cx_list_class defaulted_cl; \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1069 set_default_class_funcs(list, &defaulted_cl)
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1070 #define roll_out_test_combos_with_defaulted_funcs(name, body) \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1071 static CX_TEST_SUBROUTINE(test_list_verify_##name, CxList *list, \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1072 __attribute__((__unused__)) bool isptrlist) body \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1073 roll_out_test_invokers(name) \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1074 CX_TEST(test_list_llm_##name) { \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1075 set_up_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1076 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int)); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1077 do_set_default_class_funcs(list); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1078 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1079 tear_down_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1080 } \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1081 CX_TEST(test_list_arlm_##name) { \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1082 set_up_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1083 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1084 do_set_default_class_funcs(list); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1085 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1086 tear_down_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1087 } \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1088 CX_TEST(test_list_pllm_##name) { \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1089 set_up_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1090 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1091 do_set_default_class_funcs(list); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1092 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1093 tear_down_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1094 } \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1095 CX_TEST(test_list_parlm_##name) { \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1096 set_up_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1097 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS, 8); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1098 do_set_default_class_funcs(list); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1099 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1100 tear_down_combo \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1101 }
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1102
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1103 #define array_init(...) {__VA_ARGS__}
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1104
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1105 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
1106 int *testdata = int_test_data(len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1107 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1108 cx_for_n(i, len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1109 cxListAdd(list, &testdata[i]);
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 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1112 cxListAddArray(list, testdata, len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1113 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1114 return testdata;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1115 }
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 roll_out_test_combos(add, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1118 const size_t len = 250;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1119 int *testdata = int_test_data(len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1120 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
1121 CX_TEST_ASSERT(cxListSize(list) == len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1122 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
1123 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
1124 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1125 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
1126 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1127 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
1128 }
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(insert, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1133 int a = 5;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1134 int b = 47;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1135 int c = 13;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1136 int d = 42;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1137 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
1138 CX_TEST_ASSERT(cxListSize(list) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1139 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
1140 CX_TEST_ASSERT(cxListSize(list) == 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1141 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
1142 CX_TEST_ASSERT(cxListSize(list) == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1143 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
1144 CX_TEST_ASSERT(cxListSize(list) == 3);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1145 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
1146 CX_TEST_ASSERT(cxListSize(list) == 4);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1147 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
1148 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
1149 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
1150 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
1151 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1152
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1153 roll_out_test_combos_with_defaulted_funcs(insert_array, {
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1154 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
1155 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
1156 int *aptr[5];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1157 int *bptr[5];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1158 cx_for_n(i, 5) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1159 aptr[i] = &a[i];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1160 bptr[i] = &b[i];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1161 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1162
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1163 size_t inserted;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1164
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1165 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1166 inserted = cxListInsertArray(list, 0, aptr, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1167 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1168 inserted = cxListInsertArray(list, 0, a, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1169 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1170 CX_TEST_ASSERT(inserted == 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1171 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
1172 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
1173 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
1174 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
1175 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
1176 if (isptrlist) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1177 inserted = cxListInsertArray(list, 3, bptr, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1178 } else {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1179 inserted = cxListInsertArray(list, 3, b, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1180 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1181 CX_TEST_ASSERT(inserted == 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1182 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
1183 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
1184 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
1185 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
1186 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
1187 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
1188 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
1189 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
1190 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
1191 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
1192 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1193
876
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1194 roll_out_test_combos_with_defaulted_funcs(insert_sorted, {
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1195 int d1 = 50;
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1196 int d2 = 80;
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1197 int d3 = 60;
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1198 int d4 = 40;
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1199 int d5 = 70;
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1200 int d6a[6] = array_init(52, 54, 56, 62, 64, 75);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1201 int d7a[6] = array_init(51, 57, 58, 65, 77, 78);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1202 int d8 = 90;
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1203 int *d6ptr[6];
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1204 int *d7ptr[6];
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1205 cx_for_n(i, 6)
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1206 {
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1207 d6ptr[i] = &d6a[i];
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1208 d7ptr[i] = &d7a[i];
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1209 }
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1210 size_t inserted;
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1211 int expected[18] = array_init(
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1212 40, 50, 51, 52, 54, 56, 57, 58, 60,
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1213 62, 64, 65, 70, 75, 77, 78, 80, 90
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1214 );
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1215
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1216 CX_TEST_ASSERT(0 == cxListInsertSorted(list, &d1));
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1217 CX_TEST_ASSERT(0 == cxListInsertSorted(list, &d2));
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1218 CX_TEST_ASSERT(0 == cxListInsertSorted(list, &d3));
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1219 CX_TEST_ASSERT(0 == cxListInsertSorted(list, &d4));
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1220 CX_TEST_ASSERT(0 == cxListInsertSorted(list, &d5));
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1221 if (isptrlist) {
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1222 inserted = cxListInsertSortedArray(list, d6ptr, 6);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1223 } else {
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1224 inserted = cxListInsertSortedArray(list, d6a, 6);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1225 }
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1226 CX_TEST_ASSERT(inserted == 6);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1227 if (isptrlist) {
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1228 inserted = cxListInsertSortedArray(list, d7ptr, 6);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1229 } else {
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1230 inserted = cxListInsertSortedArray(list, d7a, 6);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1231 }
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1232 CX_TEST_ASSERT(inserted == 6);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1233 CX_TEST_ASSERT(0 == cxListInsertSorted(list, &d8));
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1234
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1235 CX_TEST_ASSERT(cxListSize(list) == 18);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1236 cx_for_n(i, 18)
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1237 {
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1238 CX_TEST_ASSERT(*(int *) cxListAt(list, i) == expected[i]);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1239 }
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1240 })
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1241
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1242 roll_out_test_combos(remove, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1243 const size_t testdata_len = 32;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1244 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
1245
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1246 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
1247 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
1248 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
1249 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
1250 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
1251 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
1252 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
1253 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
1254 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
1255 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
1256 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
1257 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
1258 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
1259 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1260 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1261
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1262 roll_out_test_combos(find_remove, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1263 const size_t testdata_len = 250;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1264 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
1265
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1266 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
1267 int val = testdata[exp];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1268 // 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
1269 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
1270 if (testdata[i] == val) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1271 exp = i;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1272 break;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1273 }
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 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
1276 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
1277 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
1278 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
1279 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
1280
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1281 int notinlist = -1;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1282 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
1283 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
1284
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1285 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1286 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1287
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1288 roll_out_test_combos(clear, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1289 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
1290 CX_TEST_ASSERT(cxListSize(list) > 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1291 cxListClear(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1292 CX_TEST_ASSERT(cxListSize(list) == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1293 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1294 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1295
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1296 roll_out_test_combos(at, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1297 size_t len = 128;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1298 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
1299 CX_TEST_ASSERT(cxListSize(list) == len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1300 cx_for_n (i, len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1301 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
1302 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1303 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
1304 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1305 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1306
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1307 roll_out_test_combos_with_defaulted_funcs(swap, {
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1308 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
1309 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
1310
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1311 cx_for_n(i, 16) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1312 cxListAdd(list, &original[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1313 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1314
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1315 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
1316 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
1317 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
1318 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
1319 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
1320 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
1321 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
1322 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
1323
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1324 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
1325 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
1326 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
1327
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1328 CxIterator iter = cxListIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1329 cx_foreach(int*, e, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1330 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
1331 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1332 iter = cxListBackwardsIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1333 cx_foreach(int*, e, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1334 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
1335 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1336 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1337
807
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1338 CX_TEST(test_list_ll_swap_no_sbo) {
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1339 set_up_combo
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1340 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, 2*cx_linked_list_swap_sbo_size);
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1341 CX_TEST_CALL_SUBROUTINE(test_list_verify_swap, list, false);
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1342 tear_down_combo
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1343 }
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1344 CX_TEST(test_list_arl_swap_no_sbo) {
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1345 set_up_combo
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1346 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, 2*cx_array_swap_sbo_size, 8);
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1347 CX_TEST_CALL_SUBROUTINE(test_list_verify_swap, list, false);
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1348 tear_down_combo
c8d692131b1e remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents: 804
diff changeset
1349 }
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1350
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1351 roll_out_test_combos(find, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1352 const size_t testdata_len = 500;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1353 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
1354
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1355 cx_for_n (attempt, 25) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1356 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
1357 int val = testdata[exp];
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1358 // 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
1359 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
1360 if (testdata[i] == val) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1361 exp = i;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1362 break;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1363 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1364 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1365 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
1366 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1367
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1368 int notinlist = -1;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1369 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
1370
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1371 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1372 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1373
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1374 roll_out_test_combos_with_defaulted_funcs(sort, {
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1375 const size_t testdata_len = 250;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1376 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
1377 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
1378 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
1379 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
1380
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1381 cxListSort(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1382 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
1383
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1384 free(expected);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1385 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1386 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1387
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1388 roll_out_test_combos(reverse, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1389 const size_t testdata_len = 50;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1390 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
1391 cxListReverse(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1392 cx_for_n(i, testdata_len) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1393 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
1394 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1395 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1396 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1397
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1398 roll_out_test_combos(iterator, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1399 const size_t len = 50;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1400 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
1401
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1402 CxIterator iter = cxListIterator(list);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
1403 CX_TEST_ASSERT(iter.elem_size == list->collection.elem_size);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
1404 CX_TEST_ASSERT(iter.elem_count == list->collection.size);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1405 size_t i = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1406 cx_foreach(int*, x, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1407 CX_TEST_ASSERT(i == iter.index);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1408 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
1409 i++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1410 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1411 CX_TEST_ASSERT(i == cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1412 iter = cxListBackwardsIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1413 cx_foreach(int*, x, iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1414 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
1415 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
1416 i--;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1417 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1418 CX_TEST_ASSERT(i == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1419 i = len / 2;
853
d4baf4dd55c3 simplify iterator structures
Mike Becker <universe@uap-core.de>
parents: 850
diff changeset
1420 CxIterator mut_iter = cxListMutIteratorAt(list, i);
856
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
1421 CX_TEST_ASSERT(mut_iter.elem_size == list->collection.elem_size);
6bbbf219251d fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents: 855
diff changeset
1422 CX_TEST_ASSERT(mut_iter.elem_count == list->collection.size);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1423 size_t j = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1424 cx_foreach(int*, x, mut_iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1425 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
1426 CX_TEST_ASSERT(*x == testdata[i]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1427 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
1428 i++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1429 j++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1430 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1431 CX_TEST_ASSERT(i == len);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1432 i = len / 2;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1433 j = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1434 mut_iter = cxListMutBackwardsIteratorAt(list, i - 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1435 cx_foreach(int*, x, mut_iter) {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1436 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
1437 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
1438 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
1439 i--;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1440 j++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1441 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1442 CX_TEST_ASSERT(i == 0);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1443 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
1444 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
1445
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1446 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1447 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1448
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1449 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
1450 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
1451 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
1452 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
1453
853
d4baf4dd55c3 simplify iterator structures
Mike Becker <universe@uap-core.de>
parents: 850
diff changeset
1454 CxIterator iter = cxListMutIteratorAt(list, 2);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1455 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1456 CX_TEST_ASSERT(iter.index == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1457 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 2);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1458 CX_TEST_ASSERT(iter.elem_count == 5);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1459 cxListInsertAfter(&iter, &newdata[0]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1460 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1461 CX_TEST_ASSERT(iter.index == 2);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1462 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 2);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1463 CX_TEST_ASSERT(iter.elem_count == 6);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1464 cxListInsertBefore(&iter, &newdata[1]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1465 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1466 CX_TEST_ASSERT(iter.index == 3);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1467 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 2);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1468 CX_TEST_ASSERT(iter.elem_count == 7);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1469
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1470 iter = cxListMutIterator(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1471 cxListInsertBefore(&iter, &newdata[2]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1472 CX_TEST_ASSERT(cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1473 CX_TEST_ASSERT(iter.index == 1);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1474 CX_TEST_ASSERT(*(int *) cxIteratorCurrent(iter) == 0);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1475 CX_TEST_ASSERT(iter.elem_count == 8);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1476 iter = cxListMutIteratorAt(list, cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1477 cxListInsertBefore(&iter, &newdata[3]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1478 CX_TEST_ASSERT(!cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1479 CX_TEST_ASSERT(iter.index == 9);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1480 CX_TEST_ASSERT(iter.elem_count == 9);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1481 iter = cxListMutIteratorAt(list, cxListSize(list));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1482 cxListInsertAfter(&iter, &newdata[4]);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1483 CX_TEST_ASSERT(!cxIteratorValid(iter));
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1484 CX_TEST_ASSERT(iter.index == 10);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1485 CX_TEST_ASSERT(iter.elem_count == 10);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1486
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1487 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
1488 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
1489 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1490
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1491 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
1492 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
1493 int x = 42;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1494 cxListAdd(left, &x);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1495 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
1496 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
1497 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
1498 cxListAdd(right, &x);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1499 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
1500 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
1501 int a = 5, b = 10;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1502 cxListInsert(left, 15, &a);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1503 cxListInsert(right, 15, &b);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1504 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
1505 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
1506 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
1507 *(int *) cxListAt(left, 15) = 10;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1508 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
1509 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1510
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1511 #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
1512 roll_out_test_combos(compare_##suffix, { \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1513 const size_t len = 47; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1514 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
1515 CxList *other = otherctr; \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1516 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
1517 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
1518 cxListDestroy(other); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1519 free(testdata); \
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1520 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1521
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1522 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1523 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
1524 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1525
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1526 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1527 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
1528 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1529
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1530 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1531 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
1532 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1533
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1534 roll_out_compare_tests(
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1535 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
1536 )
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1537
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1538 roll_out_test_combos_with_defaulted_funcs(compare_unoptimized, {
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1539 \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1540 const size_t len = 33; \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1541 int *testdata = int_test_data_added_to_list(list, isptrlist, len); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1542 CxList *other = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 50); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1543 do_set_default_class_funcs(other); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1544 cx_for_n(i, len)
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1545 cxListAdd(other, &testdata[i]); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1546 CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1547 cxListDestroy(other); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1548 free(testdata); \
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1549
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1550 })
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1551
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1552 static unsigned destr_test_ctr;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1553 static int destr_last_value;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1554
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1555 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
1556 int *ptr = data;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1557 destr_last_value = *ptr;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1558 *ptr = destr_last_value + 1;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1559 destr_test_ctr++;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1560 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1561
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1562 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
1563 simple_destr_test_fun(data);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1564 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1565
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1566 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
1567 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
1568 destr_test_ctr = 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1569
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1570 int off = cxListIsStoringPointers(list) ? 1 : 0;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1571
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1572 cxListRemove(list, 15);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1573 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
1574 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
1575 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
1576 cxListRemove(list, 47);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1577 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
1578 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
1579 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
1580
853
d4baf4dd55c3 simplify iterator structures
Mike Becker <universe@uap-core.de>
parents: 850
diff changeset
1581 CxIterator iter = cxListMutIteratorAt(list, 7);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1582 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1583 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
1584 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
1585 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
1586 cxIteratorFlagRemoval(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1587 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1588 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
1589 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
1590 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
1591
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1592 iter = cxListMutBackwardsIteratorAt(list, 5);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1593 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1594 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
1595 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
1596 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
1597 cxIteratorFlagRemoval(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1598 cxIteratorNext(iter);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1599 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
1600 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
1601 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
1602
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1603 cxListClear(list);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1604 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
1605 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
1606 }
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1607
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1608 roll_out_test_combos(simple_destr, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1609 const size_t len = 60;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1610 int *testdata = int_test_data_added_to_list(list, isptrlist, len);
857
4d12e34bb130 add missing convenience functions
Mike Becker <universe@uap-core.de>
parents: 856
diff changeset
1611 cxDefineDestructor(list, simple_destr_test_fun);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1612 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
1613 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1614 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1615
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1616 roll_out_test_combos(advanced_destr, {
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1617 const size_t len = 75;
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1618 int *testdata = int_test_data_added_to_list(list, isptrlist, len);
857
4d12e34bb130 add missing convenience functions
Mike Becker <universe@uap-core.de>
parents: 856
diff changeset
1619 cxDefineAdvancedDestructor(list, advanced_destr_test_fun, NULL);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1620 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
1621 free(testdata);
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1622 })
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1623
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1624 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
1625 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
1626
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
1627 cx_test_register(suite, test_array_add);
883
3012e9b4214e add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents: 876
diff changeset
1628 cx_test_register(suite, test_array_insert_sorted);
884
d375d8056262 add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents: 883
diff changeset
1629 cx_test_register(suite, test_array_binary_search);
818
2be8fe3d5a2d add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents: 807
diff changeset
1630
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1631 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
1632 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
1633 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
1634 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
1635 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
1636 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
1637
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1638 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
1639 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
1640 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
1641 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
1642 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
1643 cx_test_register(suite, test_list_parl_insert_array);
876
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1644 cx_test_register(suite, test_list_arl_insert_sorted);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1645 cx_test_register(suite, test_list_parl_insert_sorted);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1646 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
1647 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
1648 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
1649 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
1650 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
1651 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
1652 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
1653 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
1654 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
1655 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
1656 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
1657 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
1658 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
1659 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
1660 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
1661 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
1662 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
1663 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
1664 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
1665 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
1666 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
1667 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
1668 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
1669 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
1670 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
1671 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
1672 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
1673 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
1674 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
1675 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
1676 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
1677 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
1678 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
1679
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1680 return suite;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1681 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1682
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1683 CxTestSuite *cx_test_suite_array_list_defaulted_funcs(void) {
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1684 CxTestSuite *suite = cx_test_suite_new(
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1685 "array_list with defaulted functions");
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1686
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1687 cx_test_register(suite, test_list_arlm_insert_array);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1688 cx_test_register(suite, test_list_parlm_insert_array);
876
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1689 cx_test_register(suite, test_list_arlm_insert_sorted);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1690 cx_test_register(suite, test_list_parlm_insert_sorted);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1691 cx_test_register(suite, test_list_arlm_swap);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1692 cx_test_register(suite, test_list_parlm_swap);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1693 cx_test_register(suite, test_list_arlm_sort);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1694 cx_test_register(suite, test_list_parlm_sort);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1695
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1696 cx_test_register(suite, test_list_arl_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1697 cx_test_register(suite, test_list_parl_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1698 cx_test_register(suite, test_list_arlm_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1699 cx_test_register(suite, test_list_parlm_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1700
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1701 return suite;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1702 }
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1703
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1704 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
1705 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
1706
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1707 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
1708 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
1709 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
1710 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
1711 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
1712 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
1713 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
1714 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
1715 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
1716 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
1717 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
1718 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
1719 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
1720 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
1721 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
1722 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
1723
801
04aa3913c0e3 migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 800
diff changeset
1724 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
1725 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
1726 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
1727 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
1728 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
1729 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
1730 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
1731
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1732 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
1733 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
1734 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
1735 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
1736 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
1737 cx_test_register(suite, test_list_pll_insert_array);
876
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1738 cx_test_register(suite, test_list_ll_insert_sorted);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1739 cx_test_register(suite, test_list_pll_insert_sorted);
803
0711d869ce4d complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents: 801
diff changeset
1740 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
1741 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
1742 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
1743 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
1744 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
1745 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
1746 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
1747 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
1748 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
1749 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
1750 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
1751 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
1752 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
1753 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
1754 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
1755 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
1756 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
1757 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
1758 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
1759 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
1760 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
1761 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
1762 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
1763 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
1764 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
1765 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
1766 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
1767 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
1768 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
1769 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
1770 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
1771 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
1772 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
1773
798
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1774 return suite;
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1775 }
7644da6e2d35 migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1776
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1777 CxTestSuite *cx_test_suite_linked_list_defaulted_funcs(void) {
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1778 CxTestSuite *suite = cx_test_suite_new(
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1779 "linked_list with defaulted functions");
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1780
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1781 cx_test_register(suite, test_list_llm_insert_array);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1782 cx_test_register(suite, test_list_pllm_insert_array);
876
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1783 cx_test_register(suite, test_list_llm_insert_sorted);
f4ce7df9cff0 add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents: 875
diff changeset
1784 cx_test_register(suite, test_list_pllm_insert_sorted);
875
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1785 cx_test_register(suite, test_list_llm_swap);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1786 cx_test_register(suite, test_list_pllm_swap);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1787 cx_test_register(suite, test_list_llm_sort);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1788 cx_test_register(suite, test_list_pllm_sort);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1789
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1790 cx_test_register(suite, test_list_ll_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1791 cx_test_register(suite, test_list_pll_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1792 cx_test_register(suite, test_list_llm_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1793 cx_test_register(suite, test_list_pllm_compare_unoptimized);
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1794
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1795 return suite;
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1796 }
ee84ac776cbc add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents: 857
diff changeset
1797
800
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1798 CxTestSuite *cx_test_suite_empty_list(void) {
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1799 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
1800
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1801 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
1802 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
1803 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
1804 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
1805 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
1806 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
1807
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1808 return suite;
1274e46b3013 migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 799
diff changeset
1809 }

mercurial