test/mpool_tests.c

Fri, 24 Feb 2012 15:53:50 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 24 Feb 2012 15:53:50 +0100
changeset 30
23bb65cbf7a4
parent 28
1666cbeb1db8
child 32
c7af4ec56e19
permissions
-rw-r--r--

some fixes

13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 *
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 */
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
5 #include <inttypes.h>
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
6
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 #include "mpool_tests.h"
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
9 UCX_TEST_BEGIN(test_ucx_mempool_new) {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
10 UcxMempool *pool = ucx_mempool_new(16);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
11
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
12 UCX_TEST_ASSERT(pool->size == 16, "wrong size")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
13 UCX_TEST_ASSERT(pool->ndata == 0, "uninitialized counter")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
14 UCX_TEST_ASSERT(pool->data != NULL, "no memory addressed")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
15
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
16 ucx_mempool_free(pool);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
17
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
18 UCX_TEST_END
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
19 }
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
21 UCX_TEST_BEGIN(test_ucx_mempool_malloc) {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
22
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
23 UcxMempool *pool = ucx_mempool_new(1);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
24
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
25 int *test = (int*) ucx_mempool_malloc(pool, sizeof(int));
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
26
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
27 UCX_TEST_ASSERT(pool->ndata == 1, "counter not incremented")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
28 UCX_TEST_ASSERT(pool->size == 1, "chcap called")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
29
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
30 int *pooladdr = (int*)((char*)pool->data[0] + sizeof(ucx_destructor));
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
31 *pooladdr = 5;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
32
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
33 UCX_TEST_ASSERT(*test == 5, "wrong pointer")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
34
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
35 ucx_mempool_free(pool);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
36
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
37 UCX_TEST_END
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 }
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
40 UCX_TEST_BEGIN(test_ucx_mempool_malloc_with_chcap) {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
41
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
42 UcxMempool *pool = ucx_mempool_new(1);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
43
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
44 ucx_mempool_malloc(pool, sizeof(int));
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
45 int *test = (int*) ucx_mempool_malloc(pool, sizeof(int));
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
46
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
47 UCX_TEST_ASSERT(pool->ndata == 2, "counter not incremented")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
48 UCX_TEST_ASSERT(pool->size == 17, "chcap not called")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
49
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
50 int *pooladdr = (int*)((char*)pool->data[1] + sizeof(ucx_destructor));
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
51 *pooladdr = 5;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
52
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
53 UCX_TEST_ASSERT(*test == 5, "wrong pointer")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
54
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
55 ucx_mempool_free(pool);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
56
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
57 UCX_TEST_END
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
58 }
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
59
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
60 UCX_TEST_BEGIN(test_ucx_mempool_calloc) {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
61
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
62 UcxMempool *pool = ucx_mempool_new(1);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
63
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
64 int *test = (int*) ucx_mempool_calloc(pool, 2, sizeof(int));
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
65
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
66 UCX_TEST_ASSERT(test != NULL, "no memory for test data")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
67 UCX_TEST_ASSERT(test[0] == 0 && test[1] == 0, "failed")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
68
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
69 ucx_mempool_free(pool);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
70
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
71 UCX_TEST_END
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
72 }
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
73
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
74 void test_setdestr(void* elem) {
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
75 intptr_t *cb = (intptr_t*) ((intptr_t*) elem)[1];
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
76 *cb = 42;
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 }
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
79 UCX_TEST_BEGIN(test_ucx_mempool_set_destr) {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
80
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
81 UcxMempool *pool = ucx_mempool_new(2);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
82
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
83 ucx_mempool_malloc(pool, sizeof(int));
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
84 intptr_t *test = (intptr_t*) ucx_mempool_calloc(pool, 2, sizeof(intptr_t));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
85
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
86 int *cb = (intptr_t*) malloc(sizeof(intptr_t));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
87 UCX_TEST_ASSERT(cb != NULL && test != NULL, "no memory for test data")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
88
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
89 test[0] = 5; test[1] = (intptr_t) cb;
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
90 *cb = 13;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
91
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
92 ucx_mempool_set_destr(test, test_setdestr);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
93 UCX_TEST_ASSERT(
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
94 *(ucx_destructor*)(pool->data[1]) == test_setdestr, "failed")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
95 UCX_TEST_ASSERT(
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
96 test[0] == 5 && test[1] == (intptr_t) cb, "setdestr destroyed data")
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
97
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
98 ucx_mempool_free(pool);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
99
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
100 UCX_TEST_ASSERT(*cb == 42, "destructor not called")
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
102 free(cb);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
103
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
104 UCX_TEST_END
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
105 }
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
108 UCX_TEST_BEGIN(test_ucx_mempool_reg_destr) {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
109
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
110 UcxMempool *pool = ucx_mempool_new(1);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
111
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
112 intptr_t *test = (intptr_t*) calloc(2, sizeof(intptr_t));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
113
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
114 intptr_t *cb = (intptr_t*) malloc(sizeof(intptr_t));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
115 UCX_TEST_ASSERT(cb != NULL && test != NULL, "no memory for test data")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
116
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
117 test[0] = 5; test[1] = (intptr_t) cb;
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
118 *cb = 13;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
119
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
120 ucx_mempool_reg_destr(pool, test, test_setdestr);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
121
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
122 ucx_destructor *pooladdr = (ucx_destructor*)
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
123 ((char*)pool->data[0] + sizeof(ucx_destructor));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
124
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
125 UCX_TEST_ASSERT(*pooladdr == test_setdestr, "failed")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
126
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
127 ucx_mempool_free(pool);
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
128 free(test);
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
129
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
130 UCX_TEST_ASSERT(*cb == 42, "destructor not called")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
131
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
132 free(cb);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
133
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
134 UCX_TEST_END
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
135 }
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
137 UCX_TEST_BEGIN(test_ucx_mempool_realloc) {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
138
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
139 UcxMempool *pool = ucx_mempool_new(2);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
140
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
141 ucx_mempool_malloc(pool, sizeof(int));
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
142 intptr_t *test = (intptr_t*) ucx_mempool_calloc(pool, 2, sizeof(intptr_t));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
143
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
144 intptr_t *cb = (intptr_t*) malloc(sizeof(intptr_t));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
145 UCX_TEST_ASSERT(cb != NULL && test != NULL, "no memory for test data")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
146
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
147 test[0] = 5; test[1] = (intptr_t) cb;
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
148 *cb = 13;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
149
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
150 ucx_mempool_set_destr(test, test_setdestr);
14
b78e174b6814 Fixed realloc
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 13
diff changeset
151
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
152 int *rtest, n = 2;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
153 do {
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
154 n *= 2;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
155 UCX_TEST_ASSERT(n < 65536, "test corrupt - no movement for realloc")
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
156 rtest = ucx_mempool_realloc(pool, test, n*sizeof(intptr_t));
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
157 } while (rtest == test);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
158 test = rtest;
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
159
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
160 UCX_TEST_ASSERT(*(ucx_destructor*)(pool->data[1]) == test_setdestr,
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
161 "realloc killed destructor")
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
162 UCX_TEST_ASSERT(
30
23bb65cbf7a4 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
163 test[0] == 5 && test[1] == (intptr_t) cb, "realloc destroyed data")
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
164
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
165 ucx_mempool_free(pool);
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
166
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
167 UCX_TEST_ASSERT(*cb == 42, "destructor not called")
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
169 free(cb);
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170
28
1666cbeb1db8 new mempool tests
Mike Becker <universe@uap-core.de>
parents: 19
diff changeset
171 UCX_TEST_END
13
98ac89e3aa37 Added mempool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 }

mercurial