test/list_tests.c

Thu, 16 Aug 2012 11:31:16 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 16 Aug 2012 11:31:16 +0200
changeset 36
a9d656e4f7ce
parent 35
fdabd1240b69
child 40
583718dd4cf3
permissions
-rw-r--r--

changed API of sort algorithms (no further hint for the algorithms used in preparation for the upcomming change from qsort to natural merge sort)

9
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * tests of list implementation
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 */
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
5 #include "list_tests.h"
9
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
7 UCX_TEST_IMPLEMENT(test_ucx_list_append) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
8 UcxList *list = ucx_list_append(NULL, "Hello");
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
9 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
10 UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
11
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
12 list = ucx_list_append(list, " World!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
13
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
14 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
15 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
16
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
17 UCX_TEST_END
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
18 ucx_list_free(list);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
19 }
9
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
21 UCX_TEST_IMPLEMENT(test_ucx_list_prepend) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
22 UcxList *list = ucx_list_prepend(NULL, " World!");
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
23 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
24 list = ucx_list_prepend(list, "Hello");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
25
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
26 UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
27 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
28 UCX_TEST_ASSERT(list->next->next == NULL, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
29
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
30 UCX_TEST_END
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
31 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
32 }
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
33
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
34 UCX_TEST_IMPLEMENT(test_ucx_list_equals) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
35 UcxList *list = ucx_list_append(NULL, "Hello");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
36 list = ucx_list_append(list, " World!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
37 UcxList *list2 = ucx_list_prepend(NULL, " World!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
38 list2 = ucx_list_prepend(list2, "Hello");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
39 UcxList *list3 = ucx_list_prepend(NULL, " Welt!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
40 list3 = ucx_list_prepend(list3, "Hallo");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
41
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
42 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
43 UCX_TEST_ASSERT(ucx_list_equals(list, list2, cmp_string, NULL), "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
44 UCX_TEST_ASSERT(!ucx_list_equals(list, list3, cmp_string, NULL), "failed")
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
45 UCX_TEST_END
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
46
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
47 ucx_list_free(list3);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
48 ucx_list_free(list2);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
49 ucx_list_free(list);
18
69636f81db31 added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents: 11
diff changeset
50 }
69636f81db31 added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents: 11
diff changeset
51
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
52 UCX_TEST_IMPLEMENT(test_ucx_list_concat) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
53 UcxList *list = ucx_list_append(NULL, "Hello");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
54 UcxList *list2 = ucx_list_prepend(NULL, " World!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
55
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
56 list = ucx_list_concat(list, list2);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
57 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
58
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
59 UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
60 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
61 UCX_TEST_ASSERT(list->next->next == NULL, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
62
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
63 UCX_TEST_END
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
64 if (list->next == NULL) {
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
65 ucx_list_free(list2);
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
66 }
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
67 ucx_list_free(list);
9
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 }
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
70 UCX_TEST_IMPLEMENT(test_ucx_list_size) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
71 UcxList *list = ucx_list_append(NULL, "This ");
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
72 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
73 list = ucx_list_append(list, "list ");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
74 list = ucx_list_append(list, "has ");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
75 list = ucx_list_append(list, "size ");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
76 list = ucx_list_append(list, "5!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
77
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
78 UCX_TEST_ASSERT(ucx_list_size(list) == 5, "failed");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
79
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
80 UCX_TEST_END
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
81 ucx_list_free(list);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
82 }
9
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
84 UCX_TEST_IMPLEMENT(test_ucx_list_last) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
85 UcxList *list = ucx_list_append(NULL, "Find ");
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
86 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
87 list = ucx_list_append(list, "the ");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
88 list = ucx_list_append(list, "last!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
89
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
90 char* last = (char*) (ucx_list_last(list)->data);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
91
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
92 UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
93
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
94 UCX_TEST_END
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
95 ucx_list_free(list);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
96
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
97 }
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
98
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
99 UCX_TEST_IMPLEMENT(test_ucx_list_get) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
100 UcxList *list = ucx_list_append(NULL, "Find ");
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
101 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
102 list = ucx_list_append(list, "the ");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
103 list = ucx_list_append(list, "mid!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
104
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
105 char* mid = (char*) (ucx_list_get(list, 1)->data);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
106
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
107 UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed");
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
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
110 ucx_list_free(list);
9
013c5c4b7e44 Added dlist tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 }
11
4f6082f99bd7 Added list tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 9
diff changeset
112
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
113 UCX_TEST_IMPLEMENT(test_ucx_list_remove) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
114 UcxList *list = ucx_list_append(NULL, "Hello");
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
115 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
116 list = ucx_list_append(list, " fucking");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
117 list = ucx_list_append(list, " World!");
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
118
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
119 list = ucx_list_remove(list, ucx_list_get(list, 1));
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
120
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
121 UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
122 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
123 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
124 UCX_TEST_END
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
125
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
126 ucx_list_free(list);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
127 }
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
128
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
129 UCX_TEST_IMPLEMENT(test_ucx_list_clone) {
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
130
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
131 char *hello = (char*)malloc(6);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
132 char *world = (char*)malloc(8);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
133
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
134 memcpy(hello, "Hello", 6);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
135 memcpy(world, " World!", 8);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
136
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
137 UcxList *list = ucx_list_append(NULL, hello);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
138 list = ucx_list_append(list, world);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
139
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
140 UcxList *copy = ucx_list_clone(list, copy_string, NULL);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
141 UCX_TEST_BEGIN
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
142
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
143 UCX_TEST_ASSERT(ucx_list_equals(list, copy, cmp_string, NULL), "failed")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
144 UCX_TEST_ASSERT(hello != copy->data, "first element is no copy")
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
145 UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy")
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
146
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 30
diff changeset
147 UCX_TEST_END
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
148 free(copy->next->data);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
149 free(copy->data);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
150
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
151 free(world);
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
152 free(hello);
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
153 ucx_list_free(list);
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
154 ucx_list_free(copy);
27
22644e2572bc removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
155 }
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
156
36
a9d656e4f7ce changed API of sort algorithms (no further hint for the algorithms used in preparation for the upcomming change from qsort to natural merge sort)
Mike Becker <universe@uap-core.de>
parents: 35
diff changeset
157 UCX_TEST_IMPLEMENT(test_ucx_list_sort) {
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
158 UcxList *list = ucx_list_append(NULL, "this");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
159 list = ucx_list_append(list, "is");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
160 list = ucx_list_append(list, "a");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
161 list = ucx_list_append(list, "test");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
162 list = ucx_list_append(list, "for");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
163 list = ucx_list_append(list, "partial");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
164 list = ucx_list_append(list, "correctness");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
165
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
166 UcxList *expected = ucx_list_append(NULL, "a");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
167 expected = ucx_list_append(expected, "correctness");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
168 expected = ucx_list_append(expected, "for");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
169 expected = ucx_list_append(expected, "is");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
170 expected = ucx_list_append(expected, "partial");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
171 expected = ucx_list_append(expected, "test");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
172 expected = ucx_list_append(expected, "this");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
173
36
a9d656e4f7ce changed API of sort algorithms (no further hint for the algorithms used in preparation for the upcomming change from qsort to natural merge sort)
Mike Becker <universe@uap-core.de>
parents: 35
diff changeset
174 list = ucx_list_sort(list, cmp_string, 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
175
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
176 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
177 UCX_TEST_ASSERT(
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
178 ucx_list_equals(list, expected, cmp_string, NULL), "failed");
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
179 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
180
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
181 ucx_list_free(expected);
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
182 ucx_list_free(list);
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
183 }

mercurial