Fri, 12 Oct 2012 10:54:55 +0200
made the code work with VC++ compiler (use make CONF=windows)
9 | 1 | /* |
2 | * tests of list implementation | |
3 | */ | |
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 | 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 |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
10 | 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
|
11 | "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
12 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
13 | list = ucx_list_append(list, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
14 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
15 | 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
|
16 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
17 | 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
|
18 | |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
19 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
20 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
21 | } |
9 | 22 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
23 | 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
|
24 | UcxList *list = ucx_list_prepend(NULL, " World!"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
25 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
26 | list = ucx_list_prepend(list, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
27 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
28 | 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
|
29 | "failed"); |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
30 | 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
|
31 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
32 | 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
|
33 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
34 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
35 | 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
|
36 | } |
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
|
37 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
38 | 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
|
39 | UcxList *list = ucx_list_append(NULL, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
40 | list = ucx_list_append(list, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
41 | UcxList *list2 = ucx_list_prepend(NULL, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
42 | list2 = ucx_list_prepend(list2, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
43 | UcxList *list3 = ucx_list_prepend(NULL, " Welt!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
44 | list3 = ucx_list_prepend(list3, "Hallo"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
45 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
46 | UCX_TEST_BEGIN |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
47 | UCX_TEST_ASSERT(ucx_list_equals(list, list2, cmp_string, NULL), "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
48 | 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
|
49 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
50 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
51 | ucx_list_free(list3); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
52 | ucx_list_free(list2); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
53 | ucx_list_free(list); |
18
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
54 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
55 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
56 | 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
|
57 | UcxList *list = ucx_list_append(NULL, "Hello"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
58 | UcxList *list2 = ucx_list_prepend(NULL, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
59 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
60 | list = ucx_list_concat(list, list2); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
61 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
62 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
63 | 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
|
64 | "failed"); |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
65 | 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
|
66 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
67 | 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
|
68 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
69 | UCX_TEST_END |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
70 | if (list->next == NULL) { |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
71 | ucx_list_free(list2); |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
72 | } |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
73 | ucx_list_free(list); |
9 | 74 | } |
75 | ||
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
76 | 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
|
77 | UcxList *list = ucx_list_append(NULL, "This "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
78 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
79 | list = ucx_list_append(list, "list "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
80 | list = ucx_list_append(list, "has "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
81 | list = ucx_list_append(list, "size "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
82 | list = ucx_list_append(list, "5!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
83 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
84 | 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
|
85 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
86 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
87 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
88 | } |
9 | 89 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
90 | 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
|
91 | UcxList *list = ucx_list_append(NULL, "Find "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
92 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
93 | list = ucx_list_append(list, "the "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
94 | list = ucx_list_append(list, "last!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
95 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
96 | const char* last = (const char*) (ucx_list_last(list)->data); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
97 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
98 | 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
|
99 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
100 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
101 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
102 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
103 | } |
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
|
104 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
105 | 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
|
106 | UcxList *list = ucx_list_append(NULL, "Find "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
107 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
108 | list = ucx_list_append(list, "the "); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
109 | list = ucx_list_append(list, "mid!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
110 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
111 | const char* mid = (const char*) (ucx_list_get(list, 1)->data); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
112 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
113 | 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
|
114 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
115 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
116 | ucx_list_free(list); |
9 | 117 | } |
11 | 118 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
119 | 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
|
120 | UcxList *list = ucx_list_append(NULL, "Hello"); |
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 | list = ucx_list_append(list, " fucking"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
123 | list = ucx_list_append(list, " World!"); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
124 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
125 | 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
|
126 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
127 | 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
|
128 | "failed"); |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
129 | 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
|
130 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
131 | 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
|
132 | UCX_TEST_END |
27
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 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
135 | } |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
136 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
137 | 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
|
138 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
139 | char *hello = (char*)malloc(6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
140 | char *world = (char*)malloc(8); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
141 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
142 | memcpy(hello, "Hello", 6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
143 | memcpy(world, " World!", 8); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
144 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
145 | UcxList *list = ucx_list_append(NULL, hello); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
146 | list = ucx_list_append(list, world); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
147 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
148 | 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
|
149 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
150 | |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
151 | UCX_TEST_ASSERT(ucx_list_equals(list, copy, cmp_string, NULL), "failed"); |
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
152 | 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
|
153 | 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
|
154 | |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
155 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
156 | free(copy->next->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
157 | free(copy->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
158 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
159 | free(world); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
160 | free(hello); |
30 | 161 | ucx_list_free(list); |
162 | ucx_list_free(copy); | |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
163 | } |
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
|
164 | |
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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | 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
|
178 | 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
|
179 | 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
|
180 | 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
|
181 | |
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
|
182 | 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
|
183 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
184 | 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
|
185 | 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
|
186 | 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
|
187 | 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
|
188 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
189 | 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
|
190 | 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
|
191 | } |