Wed, 27 Feb 2013 16:59:02 +0100
happy 100th commit + removed deprecated sstrcat + fixed sstrncat
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" |
94
57ea041df22f
renamed comparator to utils module and added copy functions
Mike Becker <universe@uap-core.de>
parents:
90
diff
changeset
|
6 | #include "ucx/utils.h" |
9 | 7 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
8 | UCX_TEST_IMPLEMENT(test_ucx_list_append) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
9 | UcxList *list = ucx_list_append(NULL, (void*)"Hello"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
10 | 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
|
11 | 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
|
12 | "failed"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
13 | |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
14 | 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
|
15 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
16 | 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
|
17 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
18 | 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
|
19 | |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
20 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
21 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
22 | } |
9 | 23 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
24 | UCX_TEST_IMPLEMENT(test_ucx_list_prepend) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
25 | UcxList *list = ucx_list_prepend(NULL, (void*)" World!"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
26 | UCX_TEST_BEGIN |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
27 | 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
|
28 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
29 | 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
|
30 | "failed"); |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
31 | 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
|
32 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
33 | 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
|
34 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
35 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
36 | 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
|
37 | } |
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
|
38 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
39 | UCX_TEST_IMPLEMENT(test_ucx_list_equals) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
40 | UcxList *list = ucx_list_append(NULL, (void*)"Hello"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
41 | list = ucx_list_append(list, (void*)" World!"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
42 | UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
43 | list2 = ucx_list_prepend(list2, (void*)"Hello"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
44 | UcxList *list3 = ucx_list_prepend(NULL, (void*)" Welt!"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
45 | list3 = ucx_list_prepend(list3, (void*)"Hallo"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
46 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
47 | UCX_TEST_BEGIN |
89 | 48 | UCX_TEST_ASSERT(ucx_list_equals(list, list2, ucx_strcmp, NULL), "failed"); |
49 | UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_strcmp, NULL), "failed"); | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
50 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
51 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
52 | ucx_list_free(list3); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
53 | ucx_list_free(list2); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
54 | ucx_list_free(list); |
18
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
55 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
56 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
57 | UCX_TEST_IMPLEMENT(test_ucx_list_concat) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
58 | UcxList *list = ucx_list_append(NULL, (void*)"Hello"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
59 | UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!"); |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
60 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
61 | list = ucx_list_concat(list, list2); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
62 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
63 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
64 | 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
|
65 | "failed"); |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
66 | 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
|
67 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
68 | 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
|
69 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
70 | UCX_TEST_END |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
71 | if (list->next == NULL) { |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
72 | ucx_list_free(list2); |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
73 | } |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
74 | ucx_list_free(list); |
9 | 75 | } |
76 | ||
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
77 | UCX_TEST_IMPLEMENT(test_ucx_list_size) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
78 | UcxList *list = ucx_list_append(NULL, (void*)"This "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
79 | UCX_TEST_BEGIN |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
80 | list = ucx_list_append(list, (void*)"list "); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
81 | list = ucx_list_append(list, (void*)"has "); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
82 | list = ucx_list_append(list, (void*)"size "); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
83 | 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
|
84 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
85 | 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
|
86 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
87 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
88 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
89 | } |
9 | 90 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
91 | UCX_TEST_IMPLEMENT(test_ucx_list_last) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
92 | UcxList *list = ucx_list_append(NULL, (void*)"Find "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
93 | UCX_TEST_BEGIN |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
94 | list = ucx_list_append(list, (void*)"the "); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
95 | 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
|
96 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
97 | 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
|
98 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
99 | 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
|
100 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
101 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
102 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
103 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
104 | } |
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
|
105 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
106 | UCX_TEST_IMPLEMENT(test_ucx_list_get) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
107 | UcxList *list = ucx_list_append(NULL, (void*)"Find "); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
108 | UCX_TEST_BEGIN |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
109 | list = ucx_list_append(list, (void*)"the "); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
110 | 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
|
111 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
112 | 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
|
113 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
114 | 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
|
115 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
116 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
117 | ucx_list_free(list); |
9 | 118 | } |
11 | 119 | |
90
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
120 | UCX_TEST_IMPLEMENT(test_ucx_list_contains) { |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
121 | UcxList *l = ucx_list_append(NULL, (void*)"Contains "); |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
122 | UCX_TEST_BEGIN |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
123 | l = ucx_list_append(l, (void*)"a "); |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
124 | l = ucx_list_append(l, (void*)"string!"); |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
125 | |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
126 | UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_strcmp,NULL), "failed"); |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
127 | UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_strcmp,NULL), "failed"); |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
128 | |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
129 | UCX_TEST_END |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
130 | ucx_list_free(l); |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
131 | } |
ef3163857e88
added tests for ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
89
diff
changeset
|
132 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
133 | UCX_TEST_IMPLEMENT(test_ucx_list_remove) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
134 | UcxList *list = ucx_list_append(NULL, (void*)"Hello"); |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
135 | UCX_TEST_BEGIN |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
136 | list = ucx_list_append(list, (void*)" fucking"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
137 | 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
|
138 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
139 | 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
|
140 | |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
141 | 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
|
142 | "failed"); |
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
40
diff
changeset
|
143 | 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
|
144 | "failed"); |
40
583718dd4cf3
added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
145 | 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
|
146 | UCX_TEST_END |
27
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 | ucx_list_free(list); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
149 | } |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
150 | |
33
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
151 | 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
|
152 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
153 | char *hello = (char*)malloc(6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
154 | char *world = (char*)malloc(8); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
155 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
156 | memcpy(hello, "Hello", 6); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
157 | memcpy(world, " World!", 8); |
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 | UcxList *list = ucx_list_append(NULL, hello); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
160 | list = ucx_list_append(list, world); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
161 | |
94
57ea041df22f
renamed comparator to utils module and added copy functions
Mike Becker <universe@uap-core.de>
parents:
90
diff
changeset
|
162 | 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
|
163 | UCX_TEST_BEGIN |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
164 | |
89 | 165 | 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
|
166 | 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
|
167 | 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
|
168 | |
9c219a62070d
major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents:
30
diff
changeset
|
169 | UCX_TEST_END |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
170 | free(copy->next->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
171 | free(copy->data); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
172 | |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
173 | free(world); |
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
174 | free(hello); |
30 | 175 | ucx_list_free(list); |
176 | ucx_list_free(copy); | |
27
22644e2572bc
removed old foreach + refactored list tests
Mike Becker <universe@uap-core.de>
parents:
24
diff
changeset
|
177 | } |
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
|
178 | |
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
|
179 | UCX_TEST_IMPLEMENT(test_ucx_list_sort) { |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
180 | UcxList *list = ucx_list_append(NULL, (void*)"this"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
181 | list = ucx_list_append(list, (void*)"is"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
182 | list = ucx_list_append(list, (void*)"a"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
183 | list = ucx_list_append(list, (void*)"test"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
184 | list = ucx_list_append(list, (void*)"for"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
185 | list = ucx_list_append(list, (void*)"partial"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
186 | list = ucx_list_append(list, (void*)"correctness"); |
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
|
187 | |
71
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
188 | UcxList *expected = ucx_list_append(NULL, (void*)"a"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
189 | expected = ucx_list_append(expected, (void*)"correctness"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
190 | expected = ucx_list_append(expected, (void*)"for"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
191 | expected = ucx_list_append(expected, (void*)"is"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
192 | expected = ucx_list_append(expected, (void*)"partial"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
193 | expected = ucx_list_append(expected, (void*)"test"); |
303dabadff1c
made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
194 | 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
|
195 | |
89 | 196 | 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
|
197 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
198 | 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
|
199 | UCX_TEST_ASSERT( |
89 | 200 | ucx_list_equals(list, expected, ucx_strcmp, NULL), "failed"); |
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
|
201 | 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
|
202 | |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
33
diff
changeset
|
203 | 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
|
204 | 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
|
205 | } |