Mon, 18 Nov 2024 22:05:42 +0100
make ucx C++ compatible again (and add tests for it) - fixes #486
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" |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | #include "cx/array_list.h" |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | #include "cx/linked_list.h" |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
35 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
36 | #include <stdarg.h> |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | |
818
2be8fe3d5a2d
add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents:
807
diff
changeset
|
38 | CX_TEST(test_array_add) { |
986
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
39 | CX_ARRAY_DECLARE(int, arr); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
40 | arr = calloc(5, sizeof(int)); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
41 | arr[0] = 2; |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
42 | arr[1] = 3; |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
43 | arr[2] = 5; |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
44 | arr[3] = 7; |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
45 | arr[4] = 11; |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
46 | arr_size = 3; |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
47 | arr_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
|
48 | int elem = 8, elem2 = 47; |
986
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
49 | int result; |
818
2be8fe3d5a2d
add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents:
807
diff
changeset
|
50 | CX_TEST_DO { |
986
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
51 | result = cx_array_simple_add(arr, elem); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
52 | CX_TEST_ASSERT(result == 0); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
53 | CX_TEST_ASSERT(arr[0] == 2); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
54 | CX_TEST_ASSERT(arr[1] == 3); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
55 | CX_TEST_ASSERT(arr[2] == 5); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
56 | CX_TEST_ASSERT(arr[3] == 8); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
57 | CX_TEST_ASSERT(arr[4] == 11); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
58 | CX_TEST_ASSERT(arr_size == 4); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
59 | CX_TEST_ASSERT(arr_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
|
60 | |
986
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
61 | arr_size = 5; |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
62 | result = cx_array_simple_add(arr, elem2); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
63 | CX_TEST_ASSERT(result == 0); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
64 | CX_TEST_ASSERT(arr[0] == 2); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
65 | CX_TEST_ASSERT(arr[1] == 3); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
66 | CX_TEST_ASSERT(arr[2] == 5); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
67 | CX_TEST_ASSERT(arr[3] == 8); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
68 | CX_TEST_ASSERT(arr[4] == 11); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
69 | CX_TEST_ASSERT(arr[5] == 47); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
70 | CX_TEST_ASSERT(arr_size == 6); |
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
71 | CX_TEST_ASSERT(arr_capacity >= 6); |
818
2be8fe3d5a2d
add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents:
807
diff
changeset
|
72 | } |
986
38fa7e41194c
simplify cx_array_copy() - fixes #474
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
73 | free(arr); |
818
2be8fe3d5a2d
add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents:
807
diff
changeset
|
74 | } |
2be8fe3d5a2d
add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents:
807
diff
changeset
|
75 | |
883
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
76 | 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
|
77 | int d1 = 50; |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
78 | int d2 = 80; |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
79 | int d3 = 60; |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
80 | int d4 = 40; |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
81 | int d5 = 70; |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
82 | 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
|
83 | 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
|
84 | int d8 = 90; |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
85 | int expected[18] = { |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
86 | 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
|
87 | 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
|
88 | }; |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
89 | |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
90 | 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
|
91 | 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
|
92 | |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
93 | CX_TEST_DO { |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | 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
|
98 | 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
|
99 | 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
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | 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
|
112 | 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
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | 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
|
117 | 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
|
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_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
|
120 | } |
912
9533fc293aea
fix missing free() in test_array_insert_sorted
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
121 | free(array); |
883
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
122 | } |
3012e9b4214e
add low level cx_array_insert_sorted() and convenience macros
Mike Becker <universe@uap-core.de>
parents:
876
diff
changeset
|
123 | |
884
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
124 | CX_TEST(test_array_binary_search) { |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
125 | int array[18] = { |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
126 | 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
|
127 | 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
|
128 | }; |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
129 | |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
130 | CX_TEST_DO { |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
131 | for (size_t i = 0; i < 18; i++) { |
884
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
132 | 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
|
133 | } |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
134 | |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
135 | int s = 58; |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
136 | 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
|
137 | 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
|
138 | s = 60; |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
139 | 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
|
140 | 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
|
141 | s = 59; |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
142 | 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
|
143 | 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
|
144 | 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
|
145 | s = 79; |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
146 | 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
|
147 | 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
|
148 | 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
|
149 | s = 66; |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
150 | 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
|
151 | 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
|
152 | 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
|
153 | s = 69; |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
154 | 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
|
155 | 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
|
156 | 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
|
157 | 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
|
158 | 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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | 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
|
165 | } |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
166 | } |
d375d8056262
add cx_array_binary_search() - fixes #424
Mike Becker <universe@uap-core.de>
parents:
883
diff
changeset
|
167 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
168 | typedef struct node { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
169 | struct node *next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
170 | struct node *prev; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
171 | int data; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
172 | } node; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
173 | |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
174 | static int test_cmp_node(const void *l, const void *r) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
175 | const node *left = l; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
176 | const node *right = r; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
177 | return left->data - right->data; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
178 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
179 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
180 | 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
|
181 | 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
|
182 | 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
|
183 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
184 | 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
|
185 | 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
|
186 | void *prev = begin; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
187 | 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
|
188 | 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
|
189 | 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
|
190 | prev = n; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
191 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
192 | return begin; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
193 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
194 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
195 | 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
|
196 | va_list ap; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
197 | va_start(ap, n); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
198 | while (n != NULL) { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
199 | 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
|
200 | n = n->next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
201 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
202 | va_end(ap); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
203 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
204 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
205 | 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
|
206 | while (n != NULL) { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
207 | void *next = n->next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
208 | free(n); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
209 | n = next; |
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 | } |
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 | 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
|
214 | 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
|
215 | 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
|
216 | 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
|
217 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
218 | return data; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
219 | } |
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 | 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
|
222 | 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
|
223 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
224 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
225 | 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
|
226 | 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
|
227 | 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
|
228 | 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
|
229 | 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
|
230 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
231 | 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
|
232 | 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
|
233 | 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
|
234 | 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
|
235 | 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
|
236 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
237 | 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
|
238 | 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
|
239 | 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
|
240 | 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
|
241 | 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
|
242 | 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
|
243 | 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
|
244 | 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
|
245 | 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
|
246 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
247 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
248 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
249 | 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
|
250 | 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
|
251 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
252 | 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
|
253 | 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
|
254 | 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
|
255 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
256 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
257 | 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
|
258 | 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
|
259 | 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
|
260 | 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
|
261 | 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
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | 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
|
267 | 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
|
268 | 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
|
269 | } |
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 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
272 | 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
|
273 | 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
|
274 | 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
|
275 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
276 | int s; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
277 | s = 2; |
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_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
|
279 | s = 4; |
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_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
|
281 | s = 6; |
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_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
|
283 | s = 8; |
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_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
|
285 | s = 10; |
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_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
|
287 | s = -2; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
288 | 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
|
289 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
290 | destroy_nodes_test_data(list); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
291 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
292 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | 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
|
297 | 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
|
298 | 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
|
299 | 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
|
300 | CX_TEST_DO { |
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_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
|
302 | 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
|
303 | 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
|
304 | 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
|
305 | 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
|
306 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
307 | destroy_nodes_test_data(la); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
308 | destroy_nodes_test_data(lb); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
309 | destroy_nodes_test_data(lc); |
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_add) { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
313 | node nodes[4]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
314 | void *begin, *end; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
315 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
316 | // 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
|
317 | memset(nodes, 0, sizeof(node)*4); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
318 | end = begin = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
319 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
320 | 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
|
321 | 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
|
322 | 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
|
323 | 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
|
324 | 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
|
325 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
326 | 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
|
327 | 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
|
328 | 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
|
329 | 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
|
330 | 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
|
331 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
332 | // 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
|
333 | memset(nodes, 0, sizeof(node)*4); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
334 | end = begin = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
335 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
336 | 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
|
337 | 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
|
338 | 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
|
339 | 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
|
340 | 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
|
341 | 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
|
342 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
347 | // 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
|
348 | memset(nodes, 0, sizeof(node)*4); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
349 | end = begin = NULL; |
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 | 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
|
352 | 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
|
353 | 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
|
354 | 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
|
355 | 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
|
356 | 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
|
357 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
358 | 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
|
359 | 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
|
360 | 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
|
361 | 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
|
362 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
363 | // test with begin, end / next |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
364 | 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
|
365 | end = begin = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
366 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
367 | 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
|
368 | 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
|
369 | 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
|
370 | 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
|
371 | 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
|
372 | 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
|
373 | 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
|
374 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
375 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
376 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
377 | 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
|
378 | node nodes[4]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
379 | void *begin, *end; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
380 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
381 | // 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
|
382 | 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
|
383 | end = begin = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
384 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
385 | 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
|
386 | 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
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | 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
|
395 | 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
|
396 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
397 | // 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
|
398 | 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
|
399 | end = begin = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
400 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
401 | 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
|
402 | 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
|
403 | 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
|
404 | 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
|
405 | 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
|
406 | 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
|
407 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
408 | 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
|
409 | 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
|
410 | 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
|
411 | 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
|
412 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
413 | // 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
|
414 | 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
|
415 | end = begin = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
416 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
417 | 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
|
418 | 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
|
419 | 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
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
424 | 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
|
425 | 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
|
426 | 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
|
427 | 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
|
428 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
429 | // test with begin, end / next |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
430 | 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
|
431 | end = begin = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
432 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
433 | 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
|
434 | 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
|
435 | 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
|
436 | 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
|
437 | 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
|
438 | 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
|
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[2].next == &nodes[1]); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
442 | 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
|
443 | 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
|
444 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
445 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
446 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
447 | 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
|
448 | node nodes[4]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
449 | void *begin, *end; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
450 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
451 | // insert mid list |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
452 | 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
|
453 | begin = &nodes[0]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
454 | end = &nodes[2]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
455 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
456 | 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
|
457 | 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
|
458 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
459 | 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
|
460 | 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
|
461 | 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
|
462 | 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
|
463 | 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
|
464 | 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
|
465 | 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
|
466 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
467 | // insert end |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
468 | 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
|
469 | begin = &nodes[0]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
470 | end = &nodes[2]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
471 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
472 | cx_linked_list_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
|
473 | 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
|
474 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
475 | 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
|
476 | 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
|
477 | 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
|
478 | 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
|
479 | 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
|
480 | 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
|
481 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
482 | // insert begin |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
483 | 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
|
484 | begin = &nodes[0]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
485 | end = &nodes[2]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
486 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
487 | 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
|
488 | 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
|
489 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
490 | 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
|
491 | 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
|
492 | 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
|
493 | 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
|
494 | 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
|
495 | 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
|
496 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
497 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
498 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
499 | 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
|
500 | node nodes[5]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
501 | void *begin, *end; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
502 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
503 | // insert mid list |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
504 | 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
|
505 | 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
|
506 | |
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[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
|
508 | 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
|
509 | 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
|
510 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
511 | 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
|
512 | 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
|
513 | 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
|
514 | 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
|
515 | 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
|
516 | 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
|
517 | 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
|
518 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
519 | // insert end |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
520 | 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
|
521 | 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
|
522 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
523 | 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
|
524 | 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
|
525 | 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
|
526 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
527 | 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
|
528 | 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
|
529 | 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
|
530 | 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
|
531 | 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
|
532 | 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
|
533 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
534 | // insert begin |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
535 | 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
|
536 | 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
|
537 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
538 | 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
|
539 | 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
|
540 | 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
|
541 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
542 | 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
|
543 | 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
|
544 | 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
|
545 | 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
|
546 | 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
|
547 | 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
|
548 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
549 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
550 | |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
551 | CX_TEST(test_linked_list_insert_sorted) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
552 | node nodes[5] = {0}; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
553 | void *begin, *end; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
554 | nodes[0].data = 3; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
555 | nodes[1].data = 6; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
556 | nodes[2].data = 10; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
557 | nodes[3].data = 11; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
558 | nodes[4].data = 15; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
559 | for (unsigned i = 0 ; i < 4 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
560 | cx_linked_list_link(&nodes[i], &nodes[i+1], loc_prev, loc_next); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
561 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
562 | begin = &nodes[0]; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
563 | end = &nodes[4]; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
564 | CX_TEST_DO { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
565 | // insert a single node |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
566 | node new_node = {0}; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
567 | new_node.data = 5; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
568 | cx_linked_list_insert_sorted( |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
569 | &begin, &end, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
570 | loc_prev, loc_next, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
571 | &new_node, test_cmp_node |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
572 | ); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
573 | CX_TEST_ASSERT(new_node.prev == &nodes[0]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
574 | CX_TEST_ASSERT(new_node.next == &nodes[1]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
575 | CX_TEST_ASSERT(nodes[0].next == &new_node); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
576 | CX_TEST_ASSERT(nodes[1].prev == &new_node); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
577 | CX_TEST_ASSERT(begin == &nodes[0]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
578 | CX_TEST_ASSERT(end == &nodes[4]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
579 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
580 | // insert a new beginning node |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
581 | node new_begin = {0}; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
582 | new_begin.data = 1; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
583 | cx_linked_list_insert_sorted( |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
584 | &begin, &end, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
585 | loc_prev, loc_next, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
586 | &new_begin, test_cmp_node |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
587 | ); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
588 | CX_TEST_ASSERT(new_begin.prev == NULL); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
589 | CX_TEST_ASSERT(new_begin.next == &nodes[0]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
590 | CX_TEST_ASSERT(nodes[0].prev == &new_begin); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
591 | CX_TEST_ASSERT(begin == &new_begin); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
592 | CX_TEST_ASSERT(end == &nodes[4]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
593 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
594 | // now insert a chain |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
595 | node chain_start = {NULL, NULL, 8}; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
596 | node chain_mid = {NULL, NULL, 14}; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
597 | node chain_end = {NULL, NULL, 17}; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
598 | cx_linked_list_link(&chain_start, &chain_mid, loc_prev, loc_next); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
599 | cx_linked_list_link(&chain_mid, &chain_end, loc_prev, loc_next); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
600 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
601 | cx_linked_list_insert_sorted_chain( |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
602 | &begin, &end, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
603 | loc_prev, loc_next, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
604 | &chain_start, test_cmp_node |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
605 | ); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
606 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
607 | CX_TEST_ASSERT(chain_start.prev == &nodes[1]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
608 | CX_TEST_ASSERT(chain_start.next == &nodes[2]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
609 | CX_TEST_ASSERT(chain_mid.prev == &nodes[3]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
610 | CX_TEST_ASSERT(chain_mid.next == &nodes[4]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
611 | CX_TEST_ASSERT(chain_end.prev == &nodes[4]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
612 | CX_TEST_ASSERT(chain_end.next == NULL); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
613 | CX_TEST_ASSERT(begin == &new_begin); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
614 | CX_TEST_ASSERT(end == &chain_end); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
615 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
616 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
617 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
618 | 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
|
619 | 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
|
620 | void *begin = testdata; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
621 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
622 | 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
|
623 | 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
|
624 | 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
|
625 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
626 | destroy_nodes_test_data(testdata); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
627 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
628 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
629 | 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
|
630 | 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
|
631 | void *end = testdata->next->next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
632 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
633 | 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
|
634 | 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
|
635 | 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
|
636 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
637 | destroy_nodes_test_data(testdata); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
638 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
639 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
640 | 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
|
641 | 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
|
642 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
643 | 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
|
644 | 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
|
645 | 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
|
646 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
647 | destroy_nodes_test_data(testdata); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
648 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
649 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
650 | 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
|
651 | 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
|
652 | 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
|
653 | node *first = testdata; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
654 | node *second = first->next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
655 | node *third = second->next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
656 | void *begin = testdata; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
657 | void *end = third; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
658 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
659 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
660 | 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
|
661 | CX_TEST_ASSERT(begin == first); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
662 | CX_TEST_ASSERT(end == third); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
663 | 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
|
664 | 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
|
665 | 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
|
666 | 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
|
667 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
668 | 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
|
669 | CX_TEST_ASSERT(begin == first); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
670 | CX_TEST_ASSERT(end == first); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
671 | 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
|
672 | 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
|
673 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
674 | 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
|
675 | CX_TEST_ASSERT(begin == NULL); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
676 | CX_TEST_ASSERT(end == NULL); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
677 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
678 | // 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
|
679 | free(first); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
680 | free(second); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
681 | free(third); |
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 | |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
684 | CX_TEST(test_linked_list_remove_chain) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
685 | node *testdata = create_nodes_test_data(5); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
686 | assign_nodes_test_data(testdata, 2, 4, 6, 8, 10); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
687 | void *begin = testdata; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
688 | void *end = cx_linked_list_last(testdata, loc_next); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
689 | void *orig_end = end; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
690 | // remember what we need to free |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
691 | node *kill_list[5]; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
692 | kill_list[0] = testdata; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
693 | for (unsigned i = 1 ; i < 5 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
694 | kill_list[i] = kill_list[i-1]->next; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
695 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
696 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
697 | CX_TEST_DO { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
698 | // remove chain, but pretend that we don't have a prev pointer! |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
699 | size_t result = cx_linked_list_remove_chain( |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
700 | &begin, &end, -1, loc_next, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
701 | cx_linked_list_at(begin, 0, loc_next, 2), |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
702 | 2 |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
703 | ); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
704 | CX_TEST_ASSERT(result == 2); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
705 | CX_TEST_ASSERT(begin == testdata); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
706 | CX_TEST_ASSERT(end == orig_end); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
707 | node *new_idx2 = cx_linked_list_at(begin, 0, loc_next, 2); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
708 | CX_TEST_ASSERT(new_idx2->data == 10); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
709 | CX_TEST_ASSERT(new_idx2->next == NULL); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
710 | // we pretended we don't have prev, so it still points to 8! |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
711 | CX_TEST_ASSERT(new_idx2->prev->data == 8); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
712 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
713 | // remove last elements and try to remove more than we have |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
714 | result = cx_linked_list_remove_chain( |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
715 | &begin, &end, -1, loc_next, |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
716 | cx_linked_list_at(begin, 0, loc_next, 2), |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
717 | 2 |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
718 | ); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
719 | CX_TEST_ASSERT(result == 1); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
720 | CX_TEST_ASSERT(begin == testdata); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
721 | CX_TEST_ASSERT(end == testdata->next); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
722 | CX_TEST_ASSERT(NULL == testdata->next->next); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
723 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
724 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
725 | for (unsigned i = 0 ; i < 5 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
726 | free(kill_list[i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
727 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
728 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
729 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
730 | 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
|
731 | 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
|
732 | 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
|
733 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
734 | 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
|
735 | 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
|
736 | 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
|
737 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
738 | destroy_nodes_test_data(td5); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
739 | destroy_nodes_test_data(td13); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
740 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
741 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
742 | 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
|
743 | void *begin = NULL; |
799 | 744 | CX_TEST_DO { |
745 | // cannot assert something, we can just test that it does not crash | |
746 | cx_linked_list_sort(&begin, NULL, loc_prev, loc_next, loc_data, cx_cmp_int); | |
747 | CX_TEST_ASSERT(true); | |
748 | } | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
749 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
750 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
751 | 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
|
752 | const size_t len = 1500; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
753 | 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
|
754 | 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
|
755 | node *n = scrambled; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
756 | 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
|
757 | n->data = testdata[i]; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
758 | n = n->next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
759 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
760 | 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
|
761 | 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
|
762 | 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
|
763 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
764 | void *begin = scrambled; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
765 | 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
|
766 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
767 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
768 | 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
|
769 | node *check = begin; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
770 | node *check_last = NULL; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
771 | 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
|
772 | 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
|
773 | 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
|
774 | if (i < len - 1) { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
775 | 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
|
776 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
777 | check_last = check; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
778 | check = check->next; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
779 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
780 | CX_TEST_ASSERT(check == NULL); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
781 | 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
|
782 | } |
799 | 783 | destroy_nodes_test_data(begin); |
784 | free(sorted); | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
785 | free(testdata); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
786 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
787 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
788 | 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
|
789 | 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
|
790 | 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
|
791 | 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
|
792 | assign_nodes_test_data(expected, 8, 6, 4, 2); |
799 | 793 | void *begin = testdata; |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
794 | CX_TEST_DO { |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
795 | 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
|
796 | 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
|
797 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
798 | 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
|
799 | 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
|
800 | 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
|
801 | 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
|
802 | } |
799 | 803 | 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
|
804 | destroy_nodes_test_data(expected); |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
805 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
806 | |
800
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
807 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
808 | CX_TEST(test_empty_list_size) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
809 | 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
|
810 | 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
|
811 | CX_TEST_ASSERT(cxListSize(cxEmptyList) == 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
812 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
813 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
814 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
815 | CX_TEST(test_empty_list_iterator) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
816 | CxList *list = cxEmptyList; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
817 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
818 | CxIterator it1 = cxListIterator(list); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
819 | CxIterator it2 = cxListBackwardsIterator(list); |
853
d4baf4dd55c3
simplify iterator structures
Mike Becker <universe@uap-core.de>
parents:
850
diff
changeset
|
820 | CxIterator it3 = cxListMutIterator(list); |
d4baf4dd55c3
simplify iterator structures
Mike Becker <universe@uap-core.de>
parents:
850
diff
changeset
|
821 | CxIterator it4 = cxListMutBackwardsIterator(list); |
800
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
822 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
823 | CX_TEST_DO { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
824 | CX_TEST_ASSERT(!cxIteratorValid(it1)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
825 | CX_TEST_ASSERT(!cxIteratorValid(it2)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
826 | CX_TEST_ASSERT(!cxIteratorValid(it3)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
827 | CX_TEST_ASSERT(!cxIteratorValid(it4)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
828 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
829 | int c = 0; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
830 | cx_foreach(void*, data, it1) c++; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
831 | cx_foreach(void*, data, it2) c++; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
832 | cx_foreach(void*, data, it3) c++; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
833 | cx_foreach(void*, data, it4) c++; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
834 | CX_TEST_ASSERT(c == 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
835 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
836 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
837 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
838 | CX_TEST(test_empty_list_noops) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
839 | CX_TEST_DO { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
840 | CxList copy = *cxEmptyList; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
841 | cxListSort(cxEmptyList); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
842 | cxListClear(cxEmptyList); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
843 | cxListDestroy(cxEmptyList); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
844 | CX_TEST_ASSERT(0 == memcmp(©, cxEmptyList, sizeof(CxList))); // NOLINT(*-suspicious-memory-comparison) |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
845 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
846 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
847 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
848 | CX_TEST(test_empty_list_at) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
849 | CX_TEST_DO { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
850 | CX_TEST_ASSERT(cxListAt(cxEmptyList, 0) == NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
851 | CX_TEST_ASSERT(cxListAt(cxEmptyList, 1) == NULL); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
852 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
853 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
854 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
855 | CX_TEST(test_empty_list_find) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
856 | int x = 42, y = 1337; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
857 | CX_TEST_DO { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
858 | CX_TEST_ASSERT(cxListFind(cxEmptyList, &x) < 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
859 | CX_TEST_ASSERT(cxListFind(cxEmptyList, &y) < 0); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
860 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
861 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
862 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
863 | CX_TEST(test_empty_list_compare) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
864 | CxList *empty = cxEmptyList; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
865 | CxList *ll = cxLinkedListCreateSimple(sizeof(int)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
866 | CxList *al = cxArrayListCreateSimple(sizeof(int), 8); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
867 | int x = 5; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
868 | CX_TEST_DO { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
869 | CX_TEST_ASSERT(0 == cxListCompare(empty, cxEmptyList)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
870 | CX_TEST_ASSERT(0 == cxListCompare(ll, cxEmptyList)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
871 | CX_TEST_ASSERT(0 == cxListCompare(al, cxEmptyList)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
872 | CX_TEST_ASSERT(0 == cxListCompare(cxEmptyList, ll)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
873 | CX_TEST_ASSERT(0 == cxListCompare(cxEmptyList, al)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
874 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
875 | cxListAdd(ll, &x); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
876 | cxListAdd(al, &x); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
877 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
878 | CX_TEST_ASSERT(0 < cxListCompare(ll, cxEmptyList)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
879 | CX_TEST_ASSERT(0 < cxListCompare(al, cxEmptyList)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
880 | CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, ll)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
881 | CX_TEST_ASSERT(0 > cxListCompare(cxEmptyList, al)); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
882 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
883 | cxListDestroy(ll); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
884 | cxListDestroy(al); |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
885 | } |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
886 | |
801
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
887 | 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
|
888 | CxTestingAllocator talloc; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
889 | 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
|
890 | CxAllocator *alloc = &talloc.base; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
891 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
892 | 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
|
893 | 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
|
894 | 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
|
895 | 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
|
896 | 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
|
897 | 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
|
898 | 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
|
899 | 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
|
900 | 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
|
901 | 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
|
902 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
903 | 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
|
904 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
905 | 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
|
906 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
907 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
908 | 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
|
909 | 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
|
910 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
911 | 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
|
912 | 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
|
913 | 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
|
914 | 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
|
915 | 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
|
916 | 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
|
917 | 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
|
918 | 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
|
919 | 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
|
920 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
921 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
922 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
923 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
924 | 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
|
925 | CxList *list = cxLinkedListCreateSimple(47); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
926 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
927 | 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
|
928 | cxListStorePointers(list); |
856
6bbbf219251d
fix name of collection base member (to avoid base.base)
Mike Becker <universe@uap-core.de>
parents:
855
diff
changeset
|
929 | 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
|
930 | 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
|
931 | 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
|
932 | 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
|
933 | cxListStoreObjects(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
934 | 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
|
935 | 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
|
936 | 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
|
937 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
938 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
939 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
940 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
941 | 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
|
942 | 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
|
943 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
944 | 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
|
945 | 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
|
946 | 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
|
947 | 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
|
948 | 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
|
949 | 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
|
950 | 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
|
951 | 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
|
952 | 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
|
953 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
954 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
955 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
956 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
957 | 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
|
958 | CxTestingAllocator talloc; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
959 | 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
|
960 | CxAllocator *alloc = &talloc.base; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
961 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
962 | 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
|
963 | 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
|
964 | 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
|
965 | 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
|
966 | 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
|
967 | 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
|
968 | 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
|
969 | 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
|
970 | 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
|
971 | 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
|
972 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
973 | 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
|
974 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
975 | 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
|
976 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
977 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
978 | 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
|
979 | 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
|
980 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
981 | 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
|
982 | 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
|
983 | 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
|
984 | 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
|
985 | 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
|
986 | 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
|
987 | 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
|
988 | 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
|
989 | 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
|
990 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
991 | cxListDestroy(list); |
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 | 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
|
995 | 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
|
996 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
997 | 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
|
998 | 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
|
999 | 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
|
1000 | 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
|
1001 | 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
|
1002 | 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
|
1003 | 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
|
1004 | 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
|
1005 | 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
|
1006 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1007 | cxListDestroy(list); |
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 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1010 | 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
|
1011 | *(int *) elem = 42; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1012 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1013 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1014 | 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
|
1015 | CxTestingAllocator talloc; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1016 | 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
|
1017 | CxAllocator *alloc = &talloc.base; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1018 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1019 | 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
|
1020 | 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
|
1021 | cxListAdd(list, item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1022 | 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
|
1023 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1024 | // 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
|
1025 | 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
|
1026 | cxFree(alloc, item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1027 | 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
|
1028 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1029 | 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
|
1030 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1031 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1032 | 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
|
1033 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1034 | int item = 0; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1035 | 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
|
1036 | 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
|
1037 | cxListAdd(list, &item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1038 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1039 | 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
|
1040 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1041 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1042 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1043 | 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
|
1044 | CxTestingAllocator talloc; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1045 | 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
|
1046 | CxAllocator *alloc = &talloc.base; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1047 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1048 | 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
|
1049 | 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
|
1050 | 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
|
1051 | 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
|
1052 | cxListAdd(list, item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1053 | 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
|
1054 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1055 | 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
|
1056 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1057 | 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
|
1058 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1059 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1060 | 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
|
1061 | CxTestingAllocator talloc; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1062 | 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
|
1063 | CxAllocator *alloc = &talloc.base; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1064 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1065 | 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
|
1066 | 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
|
1067 | cxListAdd(list, item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1068 | 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
|
1069 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1070 | // 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
|
1071 | 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
|
1072 | cxFree(alloc, item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1073 | 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
|
1074 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1075 | 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
|
1076 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1077 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1078 | 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
|
1079 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1080 | int item = 0; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1081 | 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
|
1082 | 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
|
1083 | cxListAdd(list, &item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1084 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1085 | 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
|
1086 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1087 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1088 | |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1089 | 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
|
1090 | CxTestingAllocator talloc; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1091 | 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
|
1092 | CxAllocator *alloc = &talloc.base; |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1093 | CX_TEST_DO { |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1094 | 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
|
1095 | 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
|
1096 | 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
|
1097 | 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
|
1098 | cxListAdd(list, item); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1099 | 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
|
1100 | cxListDestroy(list); |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1101 | 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
|
1102 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1103 | 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
|
1104 | } |
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1105 | |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1106 | #define set_up_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1107 | CxTestingAllocator talloc; \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1108 | cx_testing_allocator_init(&talloc); \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1109 | CxAllocator *alloc = &talloc.base; \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1110 | CX_TEST_DO { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1111 | #define tear_down_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1112 | cxListDestroy(list); \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1113 | 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
|
1114 | } \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1115 | 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
|
1116 | #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
|
1117 | CX_TEST(test_list_ll_##name) { \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1118 | set_up_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1119 | 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
|
1120 | 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
|
1121 | tear_down_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1122 | } \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1123 | CX_TEST(test_list_arl_##name) { \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1124 | set_up_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1125 | 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
|
1126 | 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
|
1127 | tear_down_combo \ |
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 | CX_TEST(test_list_pll_##name) { \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1130 | set_up_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1131 | 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
|
1132 | 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
|
1133 | tear_down_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1134 | } \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1135 | CX_TEST(test_list_parl_##name) { \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1136 | set_up_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1137 | 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
|
1138 | 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
|
1139 | tear_down_combo \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1140 | } |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1141 | #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
|
1142 | static CX_TEST_SUBROUTINE(test_list_verify_##name, CxList *list, \ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
962
diff
changeset
|
1143 | cx_attr_unused bool isptrlist) body \ |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1144 | roll_out_test_invokers(name) |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1145 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1146 | static void set_default_class_funcs(CxList *list, cx_list_class *defaulted_cl) { |
890
54565fd74e74
move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents:
886
diff
changeset
|
1147 | const cx_list_class *cl = list->climpl == NULL ? list->cl : list->climpl; |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1148 | 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
|
1149 | 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
|
1150 | 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
|
1151 | 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
|
1152 | 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
|
1153 | defaulted_cl->compare = NULL; |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1154 | if (list->climpl == NULL) { |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1155 | list->cl = defaulted_cl; |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1156 | } else { |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1157 | list->climpl = defaulted_cl; |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1158 | } |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1159 | } |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1160 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1161 | #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
|
1162 | cx_list_class defaulted_cl; \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1163 | 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
|
1164 | #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
|
1165 | static CX_TEST_SUBROUTINE(test_list_verify_##name, CxList *list, \ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
962
diff
changeset
|
1166 | cx_attr_unused bool isptrlist) body \ |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1167 | roll_out_test_invokers(name) \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1168 | 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
|
1169 | set_up_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1170 | 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
|
1171 | 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
|
1172 | 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
|
1173 | tear_down_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1174 | } \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1175 | 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
|
1176 | set_up_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1177 | 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
|
1178 | 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
|
1179 | 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
|
1180 | tear_down_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1181 | } \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1182 | 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
|
1183 | set_up_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1184 | 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
|
1185 | 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
|
1186 | 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
|
1187 | tear_down_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1188 | } \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1189 | 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
|
1190 | set_up_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1191 | 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
|
1192 | 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
|
1193 | 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
|
1194 | tear_down_combo \ |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1195 | } |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1196 | |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1197 | #define array_init(...) {__VA_ARGS__} |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1198 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1199 | 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
|
1200 | int *testdata = int_test_data(len); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1201 | if (isptrlist) { |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1202 | for (size_t i = 0; i < len; i++) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1203 | cxListAdd(list, &testdata[i]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1204 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1205 | } else { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1206 | cxListAddArray(list, testdata, len); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1207 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1208 | return testdata; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1209 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1210 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1211 | roll_out_test_combos(add, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1212 | const size_t len = 250; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1213 | int *testdata = int_test_data(len); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1214 | for (size_t i = 0; i < len; i++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1215 | CX_TEST_ASSERT(cxListAdd(list, &testdata[i]) == 0); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1216 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1217 | CX_TEST_ASSERT(cxListSize(list) == len); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1218 | for (size_t i = 0; i < len; i++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1219 | CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[i]); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1220 | } |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1221 | for (size_t i = 0; i < len; i++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1222 | ++testdata[i]; |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1223 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1224 | if (isptrlist) { |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1225 | for (size_t i = 0; i < len; i++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1226 | CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[i]); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1227 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1228 | } else { |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1229 | for (size_t i = 0; i < len; i++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1230 | CX_TEST_ASSERT(*(int *) cxListAt(list, i) == testdata[i] - 1); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1231 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1232 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1233 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1234 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1235 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1236 | roll_out_test_combos(insert, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1237 | int a = 5; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1238 | int b = 47; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1239 | int c = 13; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1240 | int d = 42; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1241 | 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
|
1242 | CX_TEST_ASSERT(cxListSize(list) == 0); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1243 | 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
|
1244 | CX_TEST_ASSERT(cxListSize(list) == 1); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1245 | 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
|
1246 | CX_TEST_ASSERT(cxListSize(list) == 2); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1247 | 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
|
1248 | CX_TEST_ASSERT(cxListSize(list) == 3); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1249 | 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
|
1250 | CX_TEST_ASSERT(cxListSize(list) == 4); |
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, 0) == 47); |
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, 1) == 13); |
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, 2) == 5); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1254 | 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
|
1255 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1256 | |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1257 | 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
|
1258 | 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
|
1259 | 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
|
1260 | int *aptr[5]; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1261 | int *bptr[5]; |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1262 | for (size_t i = 0; i < 5; i++) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1263 | aptr[i] = &a[i]; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1264 | bptr[i] = &b[i]; |
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 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1267 | size_t inserted; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1268 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1269 | if (isptrlist) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1270 | inserted = cxListInsertArray(list, 0, aptr, 5); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1271 | } else { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1272 | inserted = cxListInsertArray(list, 0, a, 5); |
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 | CX_TEST_ASSERT(inserted == 5); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1275 | 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
|
1276 | 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
|
1277 | 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
|
1278 | 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
|
1279 | 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
|
1280 | if (isptrlist) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1281 | inserted = cxListInsertArray(list, 3, bptr, 5); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1282 | } else { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1283 | inserted = cxListInsertArray(list, 3, b, 5); |
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 | CX_TEST_ASSERT(inserted == 5); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1286 | 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
|
1287 | 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
|
1288 | 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
|
1289 | 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
|
1290 | 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
|
1291 | 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
|
1292 | 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
|
1293 | 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
|
1294 | 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
|
1295 | 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
|
1296 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1297 | |
876
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1298 | 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
|
1299 | int d1 = 50; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1300 | int d2 = 80; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1301 | int d3 = 60; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1302 | int d4 = 40; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1303 | int d5 = 70; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1304 | 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
|
1305 | 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
|
1306 | int d8 = 90; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1307 | int *d6ptr[6]; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1308 | int *d7ptr[6]; |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1309 | for (size_t i = 0; i < 6; i++) { |
876
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1310 | d6ptr[i] = &d6a[i]; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1311 | d7ptr[i] = &d7a[i]; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1312 | } |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1313 | size_t inserted; |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1314 | 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
|
1315 | 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
|
1316 | 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
|
1317 | ); |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1318 | |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1319 | 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
|
1320 | 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
|
1321 | 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
|
1322 | 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
|
1323 | 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
|
1324 | if (isptrlist) { |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1325 | 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
|
1326 | } else { |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1327 | 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
|
1328 | } |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1329 | 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
|
1330 | if (isptrlist) { |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1331 | 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
|
1332 | } else { |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1333 | 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
|
1334 | } |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1335 | 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
|
1336 | 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
|
1337 | |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1338 | CX_TEST_ASSERT(cxListSize(list) == 18); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1339 | for (size_t i = 0; i < 18; i++) { |
876
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1340 | 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
|
1341 | } |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1342 | }) |
f4ce7df9cff0
add stupid default implementation for high level insertion sort
Mike Becker <universe@uap-core.de>
parents:
875
diff
changeset
|
1343 | |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1344 | roll_out_test_combos(remove, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1345 | const size_t testdata_len = 32; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1346 | 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
|
1347 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1348 | 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
|
1349 | 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
|
1350 | 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
|
1351 | 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
|
1352 | 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
|
1353 | 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
|
1354 | 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
|
1355 | 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
|
1356 | 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
|
1357 | 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
|
1358 | 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
|
1359 | 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
|
1360 | 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
|
1361 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1362 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1363 | |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1364 | static unsigned test_remove_array_destr_ctr; |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
962
diff
changeset
|
1365 | static void test_remove_array_destr(cx_attr_unused void *d) { |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1366 | test_remove_array_destr_ctr++; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1367 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1368 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1369 | roll_out_test_combos(remove_array, { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1370 | const size_t testdata_len = 32; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1371 | int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1372 | cxDefineDestructor(list, test_remove_array_destr); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1373 | test_remove_array_destr_ctr = 0; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1374 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1375 | // first, remove and get - no destructor must be called |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1376 | int targete[8]; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1377 | int *targetp[8]; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1378 | memset(targete, 0, sizeof(targete)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1379 | memset(targetp, 0, sizeof(targetp)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1380 | void *target = isptrlist ? (void*) targetp : targete; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1381 | CX_TEST_ASSERT(8 == cxListRemoveArrayAndGet(list, 8, 8, target)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1382 | CX_TEST_ASSERT(0 == test_remove_array_destr_ctr); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1383 | CX_TEST_ASSERT(24 == cxListSize(list)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1384 | for (unsigned int i = 0 ; i < 8 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1385 | CX_TEST_ASSERT((*(int*)cxListAt(list, i)) == testdata[i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1386 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1387 | for (unsigned int i = 8 ; i < 24 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1388 | CX_TEST_ASSERT((*(int*)cxListAt(list, i)) == testdata[8+i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1389 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1390 | for (unsigned int i = 0 ; i < 8 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1391 | if (isptrlist) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1392 | CX_TEST_ASSERT(targetp[i] == &testdata[8 + i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1393 | } else { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1394 | CX_TEST_ASSERT(targete[i] == testdata[8 + i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1395 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1396 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1397 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1398 | // now, just remove - destructor must be called |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1399 | CX_TEST_ASSERT(8 == cxListRemoveArray(list, 8, 8)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1400 | CX_TEST_ASSERT(8 == test_remove_array_destr_ctr); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1401 | CX_TEST_ASSERT(16 == cxListSize(list)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1402 | for (unsigned int i = 0 ; i < 8 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1403 | CX_TEST_ASSERT((*(int*)cxListAt(list, i)) == testdata[i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1404 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1405 | for (unsigned int i = 8 ; i < 16 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1406 | CX_TEST_ASSERT((*(int*)cxListAt(list, i)) == testdata[16+i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1407 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1408 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1409 | // finally, remove and get out of bounds |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1410 | test_remove_array_destr_ctr = 0; |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1411 | memset(targete, 0, sizeof(targete)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1412 | memset(targetp, 0, sizeof(targetp)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1413 | CX_TEST_ASSERT(4 == cxListRemoveArrayAndGet(list, 12, 8, target)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1414 | CX_TEST_ASSERT(0 == test_remove_array_destr_ctr); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1415 | CX_TEST_ASSERT(12 == cxListSize(list)); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1416 | for (unsigned int i = 0 ; i < 8 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1417 | CX_TEST_ASSERT((*(int*)cxListAt(list, i)) == testdata[i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1418 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1419 | for (unsigned int i = 8 ; i < 12 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1420 | CX_TEST_ASSERT((*(int*)cxListAt(list, i)) == testdata[16+i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1421 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1422 | for (unsigned int i = 0 ; i < 4 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1423 | if (isptrlist) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1424 | CX_TEST_ASSERT(targetp[i] == &testdata[28 + i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1425 | } else { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1426 | CX_TEST_ASSERT(targete[i] == testdata[28 + i]); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1427 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1428 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1429 | for (unsigned int i = 4 ; i < 8 ; i++) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1430 | if (isptrlist) { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1431 | CX_TEST_ASSERT(targetp[i] == 0); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1432 | } else { |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1433 | CX_TEST_ASSERT(targete[i] == 0); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1434 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1435 | } |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1436 | |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1437 | free(testdata); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1438 | }) |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1439 | |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1440 | roll_out_test_combos(find_remove, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1441 | const size_t testdata_len = 250; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1442 | 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
|
1443 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1444 | 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
|
1445 | int val = testdata[exp]; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1446 | // 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
|
1447 | 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
|
1448 | if (testdata[i] == val) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1449 | exp = i; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1450 | break; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1451 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1452 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1453 | 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
|
1454 | 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
|
1455 | 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
|
1456 | 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
|
1457 | 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
|
1458 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1459 | int notinlist = -1; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1460 | CX_TEST_ASSERT(cxListFindRemove(list, ¬inlist) < 0); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1461 | 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
|
1462 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1463 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1464 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1465 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1466 | roll_out_test_combos(clear, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1467 | 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
|
1468 | CX_TEST_ASSERT(cxListSize(list) > 0); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1469 | cxListClear(list); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1470 | CX_TEST_ASSERT(cxListSize(list) == 0); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1471 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1472 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1473 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1474 | roll_out_test_combos(at, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1475 | size_t len = 128; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1476 | 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
|
1477 | CX_TEST_ASSERT(cxListSize(list) == len); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1478 | for (size_t i = 0; i < len; i++) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1479 | 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
|
1480 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1481 | 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
|
1482 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1483 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1484 | |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1485 | 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
|
1486 | 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
|
1487 | 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
|
1488 | |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1489 | for (size_t i = 0; i < 16; i++) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1490 | cxListAdd(list, &original[i]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1491 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1492 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1493 | 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
|
1494 | 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
|
1495 | 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
|
1496 | 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
|
1497 | 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
|
1498 | 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
|
1499 | 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
|
1500 | 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
|
1501 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1502 | 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
|
1503 | 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
|
1504 | 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
|
1505 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1506 | CxIterator iter = cxListIterator(list); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1507 | cx_foreach(int*, e, iter) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1508 | 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
|
1509 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1510 | iter = cxListBackwardsIterator(list); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1511 | cx_foreach(int*, e, iter) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1512 | 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
|
1513 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1514 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1515 | |
807
c8d692131b1e
remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents:
804
diff
changeset
|
1516 | 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
|
1517 | 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
|
1518 | 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
|
1519 | 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
|
1520 | 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
|
1521 | } |
c8d692131b1e
remove flags to disable SBO in tests - fix #343 fix #358
Mike Becker <universe@uap-core.de>
parents:
804
diff
changeset
|
1522 | 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
|
1523 | 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
|
1524 | 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
|
1525 | 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
|
1526 | 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
|
1527 | } |
803
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 | roll_out_test_combos(find, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1530 | const size_t testdata_len = 500; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1531 | 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
|
1532 | |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1533 | for (size_t attempt = 0; attempt < 25; attempt++) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1534 | 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
|
1535 | int val = testdata[exp]; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1536 | // 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
|
1537 | 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
|
1538 | if (testdata[i] == val) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1539 | exp = i; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1540 | break; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1541 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1542 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1543 | 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
|
1544 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1545 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1546 | int notinlist = -1; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1547 | CX_TEST_ASSERT(cxListFind(list, ¬inlist) < 0); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1548 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1549 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1550 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1551 | |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1552 | 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
|
1553 | const size_t testdata_len = 250; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1554 | 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
|
1555 | 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
|
1556 | 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
|
1557 | 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
|
1558 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1559 | cxListSort(list); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1560 | for (size_t i = 0; i < testdata_len; i++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1561 | CX_TEST_ASSERT(*(int *) cxListAt(list, i) == expected[i]); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1562 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1563 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1564 | free(expected); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1565 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1566 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1567 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1568 | roll_out_test_combos(reverse, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1569 | const size_t testdata_len = 50; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1570 | 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
|
1571 | cxListReverse(list); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1572 | for (size_t i = 0; i < testdata_len; i++) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1573 | 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
|
1574 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1575 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1576 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1577 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1578 | roll_out_test_combos(iterator, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1579 | const size_t len = 50; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1580 | 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
|
1581 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1582 | 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
|
1583 | 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
|
1584 | 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
|
1585 | size_t i = 0; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1586 | cx_foreach(int*, x, iter) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1587 | CX_TEST_ASSERT(i == iter.index); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1588 | 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
|
1589 | i++; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1590 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1591 | CX_TEST_ASSERT(i == cxListSize(list)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1592 | iter = cxListBackwardsIterator(list); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1593 | cx_foreach(int*, x, iter) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1594 | 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
|
1595 | 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
|
1596 | i--; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1597 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1598 | CX_TEST_ASSERT(i == 0); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1599 | i = len / 2; |
853
d4baf4dd55c3
simplify iterator structures
Mike Becker <universe@uap-core.de>
parents:
850
diff
changeset
|
1600 | 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
|
1601 | 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
|
1602 | 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
|
1603 | size_t j = 0; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1604 | cx_foreach(int*, x, mut_iter) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1605 | 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
|
1606 | CX_TEST_ASSERT(*x == testdata[i]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1607 | 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
|
1608 | i++; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1609 | j++; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1610 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1611 | CX_TEST_ASSERT(i == len); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1612 | i = len / 2; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1613 | j = 0; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1614 | mut_iter = cxListMutBackwardsIteratorAt(list, i - 1); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1615 | cx_foreach(int*, x, mut_iter) { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1616 | 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
|
1617 | 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
|
1618 | 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
|
1619 | i--; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1620 | j++; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1621 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1622 | CX_TEST_ASSERT(i == 0); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1623 | CX_TEST_ASSERT(cxListSize(list) == len / 2); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1624 | for (size_t k = 0; k < len / 2; k++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1625 | CX_TEST_ASSERT(*(int *) cxListAt(list, k) == testdata[k * 2]); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1626 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1627 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1628 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1629 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1630 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1631 | 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
|
1632 | int fivenums[] = array_init(0, 1, 2, 3, 4); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1633 | for (size_t i = 0; i < 5; i++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1634 | cxListAdd(list, &fivenums[i]); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1635 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1636 | 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
|
1637 | |
853
d4baf4dd55c3
simplify iterator structures
Mike Becker <universe@uap-core.de>
parents:
850
diff
changeset
|
1638 | CxIterator iter = cxListMutIteratorAt(list, 2); |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1639 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1640 | CX_TEST_ASSERT(iter.index == 2); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1641 | 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
|
1642 | 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
|
1643 | cxListInsertAfter(&iter, &newdata[0]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1644 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1645 | CX_TEST_ASSERT(iter.index == 2); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1646 | 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
|
1647 | 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
|
1648 | cxListInsertBefore(&iter, &newdata[1]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1649 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1650 | CX_TEST_ASSERT(iter.index == 3); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1651 | 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
|
1652 | 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
|
1653 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1654 | iter = cxListMutIterator(list); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1655 | cxListInsertBefore(&iter, &newdata[2]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1656 | CX_TEST_ASSERT(cxIteratorValid(iter)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1657 | CX_TEST_ASSERT(iter.index == 1); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1658 | 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
|
1659 | 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
|
1660 | iter = cxListMutIteratorAt(list, cxListSize(list)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1661 | cxListInsertBefore(&iter, &newdata[3]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1662 | CX_TEST_ASSERT(!cxIteratorValid(iter)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1663 | 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
|
1664 | 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
|
1665 | iter = cxListMutIteratorAt(list, cxListSize(list)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1666 | cxListInsertAfter(&iter, &newdata[4]); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1667 | CX_TEST_ASSERT(!cxIteratorValid(iter)); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1668 | 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
|
1669 | 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
|
1670 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1671 | int expdata[] = array_init(30, 0, 1, 20, 2, 10, 3, 4, 40, 50); |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1672 | for (size_t j = 0; j < 10; j++) { |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1673 | CX_TEST_ASSERT(*(int *) cxListAt(list, j) == expdata[j]); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1674 | } |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1675 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1676 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1677 | 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
|
1678 | 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
|
1679 | int x = 42; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1680 | cxListAdd(left, &x); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1681 | 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
|
1682 | 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
|
1683 | 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
|
1684 | cxListAdd(right, &x); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1685 | 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
|
1686 | 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
|
1687 | int a = 5, b = 10; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1688 | cxListInsert(left, 15, &a); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1689 | cxListInsert(right, 15, &b); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1690 | 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
|
1691 | 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
|
1692 | 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
|
1693 | *(int *) cxListAt(left, 15) = 10; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1694 | 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
|
1695 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1696 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1697 | #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
|
1698 | roll_out_test_combos(compare_##suffix, { \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1699 | const size_t len = 47; \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1700 | 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
|
1701 | CxList *other = otherctr; \ |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1702 | for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); \ |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1703 | 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
|
1704 | cxListDestroy(other); \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1705 | free(testdata); \ |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1706 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1707 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1708 | roll_out_compare_tests( |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1709 | 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
|
1710 | ) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1711 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1712 | roll_out_compare_tests( |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1713 | 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
|
1714 | ) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1715 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1716 | roll_out_compare_tests( |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1717 | 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
|
1718 | ) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1719 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1720 | roll_out_compare_tests( |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1721 | 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
|
1722 | ) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1723 | |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1724 | roll_out_test_combos_with_defaulted_funcs(compare_unoptimized, { |
962
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1725 | const size_t len = 33; |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1726 | int *testdata = int_test_data_added_to_list(list, isptrlist, len); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1727 | CxList *other = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 50); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1728 | do_set_default_class_funcs(other); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1729 | for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1730 | CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1731 | cxListDestroy(other); |
cd418898af5c
remove cx_for_n() macro - fixes #467
Mike Becker <universe@uap-core.de>
parents:
961
diff
changeset
|
1732 | free(testdata); |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1733 | }) |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1734 | |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1735 | static unsigned destr_test_ctr; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1736 | static int destr_last_value; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1737 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1738 | 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
|
1739 | int *ptr = data; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1740 | destr_last_value = *ptr; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1741 | *ptr = destr_last_value + 1; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1742 | destr_test_ctr++; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1743 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1744 | |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
962
diff
changeset
|
1745 | static void advanced_destr_test_fun(cx_attr_unused void *u, void *data) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1746 | simple_destr_test_fun(data); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1747 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1748 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1749 | static CX_TEST_SUBROUTINE(test_list_verify_destructor, CxList *list, |
890
54565fd74e74
move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents:
886
diff
changeset
|
1750 | const int *testdata, size_t testdata_len) { |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1751 | destr_test_ctr = 0; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1752 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1753 | int off = cxListIsStoringPointers(list) ? 1 : 0; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1754 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1755 | cxListRemove(list, 15); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1756 | 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
|
1757 | 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
|
1758 | 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
|
1759 | cxListRemove(list, 47); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1760 | 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
|
1761 | 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
|
1762 | 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
|
1763 | |
853
d4baf4dd55c3
simplify iterator structures
Mike Becker <universe@uap-core.de>
parents:
850
diff
changeset
|
1764 | CxIterator iter = cxListMutIteratorAt(list, 7); |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1765 | cxIteratorNext(iter); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1766 | 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
|
1767 | 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
|
1768 | 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
|
1769 | cxIteratorFlagRemoval(iter); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1770 | cxIteratorNext(iter); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1771 | 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
|
1772 | 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
|
1773 | 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
|
1774 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1775 | iter = cxListMutBackwardsIteratorAt(list, 5); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1776 | cxIteratorNext(iter); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1777 | 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
|
1778 | 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
|
1779 | 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
|
1780 | cxIteratorFlagRemoval(iter); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1781 | cxIteratorNext(iter); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1782 | 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
|
1783 | 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
|
1784 | 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
|
1785 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1786 | cxListClear(list); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1787 | 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
|
1788 | 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
|
1789 | } |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1790 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1791 | roll_out_test_combos(simple_destr, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1792 | const size_t len = 60; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1793 | 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
|
1794 | 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
|
1795 | 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
|
1796 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1797 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1798 | |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1799 | roll_out_test_combos(advanced_destr, { |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1800 | const size_t len = 75; |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1801 | 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
|
1802 | 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
|
1803 | 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
|
1804 | free(testdata); |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1805 | }) |
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1806 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1807 | 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
|
1808 | 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
|
1809 | |
818
2be8fe3d5a2d
add cx_array_add() + fix type of cx_array_default_reallocator
Mike Becker <universe@uap-core.de>
parents:
807
diff
changeset
|
1810 | 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
|
1811 | 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
|
1812 | 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
|
1813 | |
801
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1814 | 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
|
1815 | 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
|
1816 | 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
|
1817 | 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
|
1818 | 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
|
1819 | 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
|
1820 | |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1821 | 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
|
1822 | 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
|
1823 | 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
|
1824 | 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
|
1825 | 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
|
1826 | 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
|
1827 | 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
|
1828 | 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
|
1829 | 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
|
1830 | cx_test_register(suite, test_list_parl_remove); |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1831 | cx_test_register(suite, test_list_arl_remove_array); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1832 | cx_test_register(suite, test_list_parl_remove_array); |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1833 | 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
|
1834 | 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
|
1835 | 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
|
1836 | 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
|
1837 | 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
|
1838 | 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
|
1839 | 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
|
1840 | 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
|
1841 | 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
|
1842 | 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
|
1843 | 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
|
1844 | 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
|
1845 | 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
|
1846 | 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
|
1847 | 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
|
1848 | 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
|
1849 | 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
|
1850 | 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
|
1851 | 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
|
1852 | 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
|
1853 | 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
|
1854 | 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
|
1855 | 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
|
1856 | 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
|
1857 | 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
|
1858 | 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
|
1859 | 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
|
1860 | 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
|
1861 | 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
|
1862 | 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
|
1863 | 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
|
1864 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1865 | return suite; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1866 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1867 | |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1868 | 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
|
1869 | 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
|
1870 | "array_list with defaulted functions"); |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1871 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1872 | 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
|
1873 | 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
|
1874 | 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
|
1875 | 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
|
1876 | 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
|
1877 | 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
|
1878 | 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
|
1879 | 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
|
1880 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1881 | 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
|
1882 | 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
|
1883 | 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
|
1884 | 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
|
1885 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1886 | return suite; |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1887 | } |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1888 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1889 | 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
|
1890 | 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
|
1891 | |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1892 | 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
|
1893 | 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
|
1894 | 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
|
1895 | 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
|
1896 | 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
|
1897 | 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
|
1898 | 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
|
1899 | cx_test_register(suite, test_linked_list_insert_chain); |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1900 | cx_test_register(suite, test_linked_list_insert_sorted); |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1901 | 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
|
1902 | 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
|
1903 | 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
|
1904 | cx_test_register(suite, test_linked_list_remove); |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1905 | cx_test_register(suite, test_linked_list_remove_chain); |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1906 | 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
|
1907 | 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
|
1908 | 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
|
1909 | 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
|
1910 | |
801
04aa3913c0e3
migrate list create and destroy tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
800
diff
changeset
|
1911 | 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
|
1912 | 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
|
1913 | 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
|
1914 | 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
|
1915 | 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
|
1916 | 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
|
1917 | 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
|
1918 | |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1919 | 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
|
1920 | 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
|
1921 | 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
|
1922 | 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
|
1923 | 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
|
1924 | 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
|
1925 | 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
|
1926 | 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
|
1927 | 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
|
1928 | cx_test_register(suite, test_list_pll_remove); |
961
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1929 | cx_test_register(suite, test_list_ll_remove_array); |
bc8b7c5f55fb
increase list test coverage - fixes #454
Mike Becker <universe@uap-core.de>
parents:
912
diff
changeset
|
1930 | cx_test_register(suite, test_list_pll_remove_array); |
803
0711d869ce4d
complete migration of list tests - fixes #342
Mike Becker <universe@uap-core.de>
parents:
801
diff
changeset
|
1931 | 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
|
1932 | 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
|
1933 | 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
|
1934 | 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
|
1935 | 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
|
1936 | 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
|
1937 | 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
|
1938 | 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
|
1939 | 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
|
1940 | 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
|
1941 | 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
|
1942 | 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
|
1943 | 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
|
1944 | 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
|
1945 | 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
|
1946 | 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
|
1947 | 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
|
1948 | 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
|
1949 | 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
|
1950 | 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
|
1951 | 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
|
1952 | 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
|
1953 | 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
|
1954 | 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
|
1955 | 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
|
1956 | 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
|
1957 | 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
|
1958 | 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
|
1959 | 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
|
1960 | 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
|
1961 | 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
|
1962 | |
798
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1963 | return suite; |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1964 | } |
7644da6e2d35
migrate low level linked list tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1965 | |
875
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1966 | 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
|
1967 | 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
|
1968 | "linked_list with defaulted functions"); |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1969 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1970 | 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
|
1971 | 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
|
1972 | 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
|
1973 | 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
|
1974 | 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
|
1975 | 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
|
1976 | 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
|
1977 | 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
|
1978 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1979 | 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
|
1980 | 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
|
1981 | 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
|
1982 | 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
|
1983 | |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1984 | return suite; |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1985 | } |
ee84ac776cbc
add default impl for some list member functions
Mike Becker <universe@uap-core.de>
parents:
857
diff
changeset
|
1986 | |
800
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
1987 | CxTestSuite *cx_test_suite_empty_list(void) { |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
1988 | 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
|
1989 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
1990 | 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
|
1991 | 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
|
1992 | 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
|
1993 | 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
|
1994 | 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
|
1995 | 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
|
1996 | |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
1997 | return suite; |
1274e46b3013
migrate cxEmptyList tests - relates to #342
Mike Becker <universe@uap-core.de>
parents:
799
diff
changeset
|
1998 | } |