Sat, 28 Oct 2017 16:07:52 +0200
UCX release
9 | 1 | /* |
103
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
3 | * |
259 | 4 | * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved. |
103
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
5 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
8 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
11 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
15 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
94
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
9 | 27 | */ |
28 | ||
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
29 | #include "list_tests.h" |
251
fae240d633fc
changes source directory structure in preperation for autotools rollout
Mike Becker <universe@uap-core.de>
parents:
250
diff
changeset
|
30 | #include <ucx/utils.h> |
9 | 31 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
32 | UCX_TEST(test_ucx_list_append) { |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
33 | UcxList *list, *first; |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
34 | list = first = ucx_list_append(NULL, (void*)"Hello"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
35 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
36 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
37 | UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
38 | "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
39 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
40 | list = ucx_list_append(list, (void*)" World!"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
41 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
42 | UCX_TEST_ASSERT(list == first, "does not return first element"); |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
43 | UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0, |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
44 | "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
45 | UCX_TEST_ASSERT(list->next->prev == list, "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
46 | UCX_TEST_ASSERT(list->next->next == NULL, "failed"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
47 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
48 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
49 | ucx_list_free(list); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
50 | } |
9 | 51 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
52 | UCX_TEST(test_ucx_list_prepend) { |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
53 | UcxList *list, *last; |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
54 | list = last = ucx_list_prepend(NULL, (void*)" World!"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
55 | UCX_TEST_BEGIN |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
56 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
57 | list = ucx_list_prepend(list, (void*)"Hello"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
58 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
59 | UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
60 | "failed"); |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
61 | UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0, |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
62 | "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
63 | UCX_TEST_ASSERT(list == last->prev, "does not return first element"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
64 | UCX_TEST_ASSERT(list->next->next == NULL, "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
65 | UCX_TEST_ASSERT(list->prev == NULL, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
66 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
67 | UCX_TEST_END |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
68 | ucx_list_free(list); |
24
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
69 | } |
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
70 | |
228
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
71 | UCX_TEST(test_ucx_list_append_once) { |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
72 | UcxList *list, *first; |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
73 | list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_strcmp, NULL); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
74 | UCX_TEST_BEGIN |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
75 | |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
76 | UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
77 | "failed"); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
78 | |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
79 | list = ucx_list_append_once(list, (void*)"Hello", ucx_strcmp, NULL); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
80 | list = ucx_list_append_once(list, (void*)" World!", ucx_strcmp, NULL); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
81 | |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
82 | UCX_TEST_ASSERT(list == first, "does not return first element"); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
83 | UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0, |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
84 | "'Hello' was not inserted _once_"); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
85 | UCX_TEST_ASSERT(list->next->prev == list, "failed"); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
86 | UCX_TEST_ASSERT(list->next->next == NULL, "right not terminated"); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
87 | UCX_TEST_END |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
88 | |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
89 | ucx_list_free(list); |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
90 | } |
9f385abc72fb
adds ucx_list_append_once() and ucx_list_prepend_once()
Mike Becker <universe@uap-core.de>
parents:
225
diff
changeset
|
91 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
92 | UCX_TEST(test_ucx_list_equals) { |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
93 | const char *hello = "Hello"; |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
94 | const char *world = " World!"; |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
95 | UcxList *list = ucx_list_append(NULL, (void*)hello); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
96 | list = ucx_list_append(list, (void*)world); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
97 | UcxList *list2 = ucx_list_prepend(NULL, (void*)world); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
98 | list2 = ucx_list_prepend(list2, (void*)hello); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
99 | UcxList *list3 = ucx_list_prepend(NULL, (void*)" Welt!"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
100 | list3 = ucx_list_prepend(list3, (void*)"Hallo"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
101 | UcxList *list4 = ucx_list_prepend(NULL, (void*)" World!"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
102 | list4 = ucx_list_prepend(list4, (void*)"Hello"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
103 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
104 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
105 | UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_strcmp, NULL), "failed"); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
106 | UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_strcmp, NULL), "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
107 | UCX_TEST_ASSERT(ucx_list_equals(list, list2, NULL, NULL), "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
108 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
109 | UCX_TEST_END |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
110 | ucx_list_free(list4); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
111 | ucx_list_free(list3); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
112 | ucx_list_free(list2); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
113 | ucx_list_free(list); |
18
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
114 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
115 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
116 | UCX_TEST(test_ucx_list_concat) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
117 | UcxList *list = ucx_list_append(NULL, (void*)"Hello"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
118 | list = ucx_list_append(list, (void*)" my "); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
119 | UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
120 | list2 = ucx_list_prepend(list2, (void*)" sweet "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
121 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
122 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
123 | list = ucx_list_concat(list, list2); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
124 | list = ucx_list_concat(list, NULL); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
125 | list = ucx_list_concat(NULL, list); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
126 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
127 | UCX_TEST_ASSERT(!strncmp((const char*)list->data, "Hello", 5), |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
128 | "failed"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
129 | UCX_TEST_ASSERT(!strncmp((const char*)list->next->data, " my ", 4), |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
130 | "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
131 | UCX_TEST_ASSERT(!strncmp((const char*)list->next->next->data, " sweet ", 7), |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
132 | "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
133 | UCX_TEST_ASSERT(!strncmp((const char*)ucx_list_last(list)->data, |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
134 | " World!", 7), "failed"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
135 | |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
136 | UCX_TEST_ASSERT(list->prev == NULL, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
137 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
138 | UCX_TEST_END |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
139 | // don't free list2, as it is freed by freeing list; |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
140 | ucx_list_free(list); |
24
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
141 | } |
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
142 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
143 | UCX_TEST(test_ucx_list_size) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
144 | UcxList *list = ucx_list_append(NULL, (void*)"This "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
145 | list = ucx_list_append(list, (void*)"list "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
146 | list = ucx_list_append(list, (void*)"has "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
147 | list = ucx_list_append(list, (void*)"size "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
148 | list = ucx_list_append(list, (void*)"5!"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
149 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
150 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
151 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
152 | UCX_TEST_ASSERT(ucx_list_size(list) == 5, "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
153 | list = ucx_list_remove(list, ucx_list_get(list, 2)); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
154 | UCX_TEST_ASSERT(ucx_list_size(list) == 4, "failed after removal"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
155 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
156 | UCX_TEST_END |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
157 | ucx_list_free(list); |
9 | 158 | } |
159 | ||
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
160 | UCX_TEST(test_ucx_list_first) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
161 | UcxList *list = ucx_list_append(NULL, (void*)"Find "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
162 | list = ucx_list_append(list, (void*)"the "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
163 | list = ucx_list_append(list, (void*)"first!"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
164 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
165 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
166 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
167 | const char* first = (const char*) (ucx_list_first(list)->data); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
168 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
169 | UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
170 | UCX_TEST_ASSERT(ucx_list_first(list->next->next) == list, "failed"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
171 | UCX_TEST_ASSERT(!ucx_list_first(NULL), |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
172 | "does not return NULL on an empty list"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
173 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
174 | UCX_TEST_END |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
175 | ucx_list_free(list); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
176 | } |
9 | 177 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
178 | UCX_TEST(test_ucx_list_last) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
179 | UcxList *list = ucx_list_append(NULL, (void*)"Find "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
180 | list = ucx_list_append(list, (void*)"the "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
181 | list = ucx_list_append(list, (void*)"last!"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
182 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
183 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
184 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
185 | const char* last = (const char*) (ucx_list_last(list->next->next)->data); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
186 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
187 | UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
188 | UCX_TEST_ASSERT(ucx_list_last(list) == list->next->next, "failed"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
189 | UCX_TEST_ASSERT(!ucx_list_last(NULL), |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
190 | "does not return NULL on an empty list"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
191 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
192 | UCX_TEST_END |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
193 | ucx_list_free(list); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
194 | } |
24
e04822101291
changed make clean + added dlist_clone with copy test + added va_end statements to string.c
Mike Becker <universe@uap-core.de>
parents:
22
diff
changeset
|
195 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
196 | UCX_TEST(test_ucx_list_get) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
197 | UcxList *list = ucx_list_append(NULL, (void*)"Find "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
198 | list = ucx_list_append(list, (void*)"the "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
199 | list = ucx_list_append(list, (void*)"mid!"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
200 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
201 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
202 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
203 | const char* first = (const char*) (ucx_list_get(list, 0)->data); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
204 | const char* mid = (const char*) (ucx_list_get(list, 1)->data); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
205 | const char* last = (const char*) (ucx_list_get(list, 2)->data); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
206 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
207 | UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
208 | UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
209 | UCX_TEST_ASSERT(strncmp(last, "mid!", 4) == 0, "failed"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
210 | UCX_TEST_ASSERT(!ucx_list_get(list, -1), "out of bounds (neg)"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
211 | UCX_TEST_ASSERT(!ucx_list_get(list, 3), "out of bounds"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
212 | UCX_TEST_ASSERT(!ucx_list_get(NULL, 0), "empty list"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
213 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
214 | UCX_TEST_END |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
215 | ucx_list_free(list); |
9 | 216 | } |
11 | 217 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
218 | UCX_TEST(test_ucx_list_indexof) { |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
219 | UcxList *list = ucx_list_append(NULL, (void*)"Find "); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
220 | list = ucx_list_append(list, (void*)"the "); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
221 | list = ucx_list_append(list, (void*)"mid!"); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
222 | |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
223 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
224 | |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
225 | UCX_TEST_ASSERT(ucx_list_indexof(list, list) == 0, "failed"); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
226 | UCX_TEST_ASSERT(ucx_list_indexof(list, list->next) == 1, "failed"); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
227 | UCX_TEST_ASSERT(ucx_list_indexof(list, ucx_list_get(list, 2)) == 2, |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
228 | "failed"); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
229 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
230 | UcxList *otherlist = ucx_list_append(NULL, (void*) "the "); |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
231 | UCX_TEST_ASSERT(ucx_list_indexof(list, otherlist) == -1, "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
232 | UCX_TEST_ASSERT(ucx_list_indexof(NULL, otherlist) == -1, "empty list"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
233 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
234 | ucx_list_free(otherlist); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
235 | |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
236 | UCX_TEST_END |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
237 | ucx_list_free(list); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
238 | } |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
239 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
240 | UCX_TEST(test_ucx_list_find) { |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
241 | const char* teststr = "string!"; |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
242 | UcxList *l = ucx_list_append(NULL, (void*)"find "); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
243 | l = ucx_list_append(l, (void*)"some "); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
244 | l = ucx_list_append(l, (void*)teststr); |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
245 | |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
246 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
247 | |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
248 | UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_strcmp,NULL) == 1, |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
249 | "doesn't find string"); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
250 | UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_strcmp,NULL) == -1, |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
251 | "finds non-existing string"); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
252 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
253 | UCX_TEST_ASSERT(ucx_list_find(l,(void*)teststr,NULL,NULL) == 2, |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
254 | "doesn't find integer without cmp_func"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
255 | |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
256 | UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_strcmp,NULL) == -1, |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
257 | "empty list"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
258 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
259 | UCX_TEST_END |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
260 | ucx_list_free(l); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
261 | } |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
262 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
263 | UCX_TEST(test_ucx_list_contains) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
264 | UcxList *l = ucx_list_append(NULL, (void*)"Contains "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
265 | l = ucx_list_append(l, (void*)"a "); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
266 | l = ucx_list_append(l, (void*)"string!"); |
90
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
267 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
268 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
269 | |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
270 | UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_strcmp,NULL), |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
271 | "false negative"); |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
272 | UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_strcmp,NULL), |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
273 | "false positive"); |
90
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
274 | |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
275 | UCX_TEST_END |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
276 | ucx_list_free(l); |
90
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
277 | } |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
278 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
279 | UCX_TEST(test_ucx_list_remove) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
280 | UcxList *list = ucx_list_append(NULL, (void*)"Hello"); |
162
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
281 | list = ucx_list_append(list, (void*)"fucking"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
282 | list = ucx_list_append(list, (void*)"World!"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
283 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
284 | UcxList *list2 = ucx_list_append(NULL, (void*)"A"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
285 | list2 = ucx_list_append(list2, (void*)"B"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
286 | list2 = ucx_list_append(list2, (void*)"C"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
287 | list2 = ucx_list_append(list2, (void*)"D"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
288 | list2 = ucx_list_append(list2, (void*)"E"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
289 | list2 = ucx_list_append(list2, (void*)"F"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
290 | list2 = ucx_list_append(list2, (void*)"G"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
291 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
292 | UCX_TEST_BEGIN |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
293 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
294 | list = ucx_list_remove(list, ucx_list_get(list, 1)); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
295 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
296 | UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
297 | "failed"); |
162
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
298 | UCX_TEST_ASSERT(strncmp((const char*)list->next->data, "World!", 7) == 0, |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
299 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
300 | UCX_TEST_ASSERT(list->next->next == NULL, "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
301 | |
162
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
302 | // remove first element: B, C, D, E, F, G |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
303 | list2 = ucx_list_remove(list2, list2); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
304 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
305 | UCX_TEST_ASSERT(ucx_list_size(list2) == 6, "list2 has wrong size"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
306 | UCX_TEST_ASSERT(strncmp((const char*)list2->data, "B", 1) == 0, |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
307 | "wrong first element"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
308 | UCX_TEST_ASSERT(strncmp((const char*)ucx_list_get(list2, 5)->data, "G", 1) |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
309 | == 0, "wrong last element"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
310 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
311 | // remove second element: B, D, E, F, G |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
312 | list2 = ucx_list_remove(list2, list2->next); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
313 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
314 | UCX_TEST_ASSERT(ucx_list_size(list2) == 5, "list2 has wrong size"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
315 | UCX_TEST_ASSERT(strncmp((const char*)list2->next->data, "D", 1) == 0, |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
316 | "wrong second element"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
317 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
318 | UcxList *last = ucx_list_get(list2, 4); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
319 | list2 = ucx_list_remove(list2, last->prev); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
320 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
321 | UCX_TEST_ASSERT(ucx_list_size(list2) == 4, "list2 has wrong size"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
322 | UCX_TEST_ASSERT(strncmp((const char*)last->prev->data, "E", 1) == 0, |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
323 | "wrong element"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
324 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
325 | // remove last element: B, D, E, F |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
326 | list2 = ucx_list_remove(list2, last); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
327 | UCX_TEST_ASSERT(ucx_list_size(list2) == 3, "list2 has wrong size"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
328 | UCX_TEST_ASSERT(strncmp((const char*)ucx_list_get(list2, 2)->data, "E", 1) |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
329 | == 0, "wrong last element"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
330 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
331 | UCX_TEST_ASSERT(strncmp((const char*)list2->data, "B", 1) == 0, |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
332 | "wrong element"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
333 | |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
334 | list2 = ucx_list_remove(list2, list2); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
335 | UCX_TEST_ASSERT(ucx_list_size(list2) == 2, "list2 has wrong size"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
336 | list2 = ucx_list_remove(list2, list2); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
337 | UCX_TEST_ASSERT(ucx_list_size(list2) == 1, "list2 has wrong size"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
338 | list2 = ucx_list_remove(list2, list2); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
339 | UCX_TEST_ASSERT(list2 == NULL, "list2 is not null"); |
52dfe5f4ecd7
added more tests for ucx_list_remove
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
340 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
341 | UCX_TEST_END |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
342 | ucx_list_free(list); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
343 | } |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
344 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
345 | UCX_TEST(test_ucx_list_clone) { |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
346 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
347 | char *hello = (char*)malloc(6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
348 | char *world = (char*)malloc(8); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
349 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
350 | memcpy(hello, "Hello", 6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
351 | memcpy(world, " World!", 8); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
352 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
353 | UcxList *list = ucx_list_append(NULL, hello); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
354 | list = ucx_list_append(list, world); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
355 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
356 | UcxList *copy = ucx_list_clone(list, ucx_strcpy, NULL); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
357 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
358 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
359 | UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_strcmp, NULL), "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
360 | UCX_TEST_ASSERT(hello != copy->data, "first element is no copy"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
361 | UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
362 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
363 | UCX_TEST_END |
211
07a284486fa1
added ucx_list_free_contents()
Mike Becker <universe@uap-core.de>
parents:
192
diff
changeset
|
364 | |
212
c766c423dee6
fixed name of ucx_list_free_content()
Mike Becker <universe@uap-core.de>
parents:
211
diff
changeset
|
365 | ucx_list_free_content(copy, free); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
366 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
367 | free(world); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
368 | free(hello); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
369 | ucx_list_free(list); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
370 | ucx_list_free(copy); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
371 | } |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
372 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
373 | UCX_TEST(test_ucx_list_sort) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
374 | UcxList *list = ucx_list_append(NULL, (void*)"this"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
375 | list = ucx_list_append(list, (void*)"is"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
376 | list = ucx_list_append(list, (void*)"a"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
377 | list = ucx_list_append(list, (void*)"test"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
378 | list = ucx_list_append(list, (void*)"for"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
379 | list = ucx_list_append(list, (void*)"partial"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
380 | list = ucx_list_append(list, (void*)"correctness"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
381 | list = ucx_list_append(list, (void*)"of"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
382 | list = ucx_list_append(list, (void*)"the"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
383 | list = ucx_list_append(list, (void*)"sort"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
384 | list = ucx_list_append(list, (void*)"function"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
385 | list = ucx_list_append(list, (void*)"that"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
386 | list = ucx_list_append(list, (void*)"shall"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
387 | list = ucx_list_append(list, (void*)"pass"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
388 | list = ucx_list_append(list, (void*)"this"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
389 | list = ucx_list_append(list, (void*)"test"); |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
390 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
391 | UcxList *expected = ucx_list_append(NULL, (void*)"a"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
392 | expected = ucx_list_append(expected, (void*)"correctness"); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
393 | expected = ucx_list_append(expected, (void*)"for"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
394 | expected = ucx_list_append(expected, (void*)"function"); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
395 | expected = ucx_list_append(expected, (void*)"is"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
396 | expected = ucx_list_append(expected, (void*)"of"); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
397 | expected = ucx_list_append(expected, (void*)"partial"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
398 | expected = ucx_list_append(expected, (void*)"pass"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
399 | expected = ucx_list_append(expected, (void*)"shall"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
400 | expected = ucx_list_append(expected, (void*)"sort"); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
401 | expected = ucx_list_append(expected, (void*)"test"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
402 | expected = ucx_list_append(expected, (void*)"test"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
403 | expected = ucx_list_append(expected, (void*)"that"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
404 | expected = ucx_list_append(expected, (void*)"the"); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
405 | expected = ucx_list_append(expected, (void*)"this"); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
406 | expected = ucx_list_append(expected, (void*)"this"); |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
407 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
408 | list = ucx_list_sort(list, ucx_strcmp, NULL); |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
409 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
410 | UCX_TEST_BEGIN |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
411 | UCX_TEST_ASSERT( |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
412 | ucx_list_equals(list, expected, ucx_strcmp, NULL), "failed"); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
413 | UCX_TEST_ASSERT(ucx_list_size(list) == 16, "list has now a wrong size"); |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
414 | UcxList *l = list; |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
415 | UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null"); |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
416 | while (l->next != NULL) { |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
417 | UCX_TEST_ASSERT(l->next->prev == l, "next or prev pointer corrupted"); |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
418 | l = l->next; |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
419 | } |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
420 | UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_strcmp, NULL), |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
162
diff
changeset
|
421 | "failed to sort empty list"); |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
422 | UCX_TEST_END |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
423 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
424 | ucx_list_free(expected); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
103
diff
changeset
|
425 | ucx_list_free(list); |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
426 | } |