tests/test_mempool.c

changeset 1328
2cf66dee40b8
parent 1325
20caf6efaf07
equal deleted inserted replaced
1327:ed75dc1db503 1328:2cf66dee40b8
29 #include "cx/test.h" 29 #include "cx/test.h"
30 #include "util_allocator.h" 30 #include "util_allocator.h"
31 31
32 #include "cx/mempool.h" 32 #include "cx/mempool.h"
33 33
34 #include <errno.h>
35
36 static unsigned test_mempool_destructor_called;
37
38 static void test_mempool_destructor(cx_attr_unused void *mem) {
39 test_mempool_destructor_called++;
40 }
41
42 static void test_mempool_destructor2(void *data, cx_attr_unused void *mem) {
43 int *ctr = data;
44 *ctr = *ctr + 1;
45 }
46
34 CX_TEST(test_mempool_create) { 47 CX_TEST(test_mempool_create) {
35 CxMempool *pool = cxMempoolCreateSimple(16); 48 CxMempool *pool = cxMempoolCreateSimple(16);
36 CX_TEST_DO { 49 CX_TEST_DO {
37 CX_TEST_ASSERT(pool->destr == NULL); 50 CX_TEST_ASSERT(pool->destr == NULL);
38 CX_TEST_ASSERT(pool->destr2 == NULL); 51 CX_TEST_ASSERT(pool->destr2 == NULL);
49 CX_TEST_ASSERT(pool->data != NULL); 62 CX_TEST_ASSERT(pool->data != NULL);
50 } 63 }
51 cxMempoolFree(pool); 64 cxMempoolFree(pool);
52 } 65 }
53 66
67 static CX_TEST_SUBROUTINE(test_mempool_malloc_verify, CxMempool *pool) {
68 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL);
69 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL);
70 CX_TEST_ASSERT(pool->size == 2);
71 CX_TEST_ASSERT(pool->capacity == 4);
72 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL);
73 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL);
74 CX_TEST_ASSERT(pool->size == 4);
75 CX_TEST_ASSERT(pool->capacity == 4);
76 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL);
77 int *i = cxMalloc(pool->allocator, sizeof(int));
78 CX_TEST_ASSERT(i != NULL);
79 *i = 4083914; // let asan / valgrind check
80 CX_TEST_ASSERT(pool->size == 6);
81 CX_TEST_ASSERT(pool->capacity >= 6);
82 }
83
84 CX_TEST(test_mempool_malloc0) {
85 CxMempool *pool = cxMempoolCreatePure(4);
86 CX_TEST_DO {
87 CX_TEST_CALL_SUBROUTINE(test_mempool_malloc_verify, pool);
88 }
89 cxMempoolFree(pool);
90 }
91
54 CX_TEST(test_mempool_malloc) { 92 CX_TEST(test_mempool_malloc) {
55 CxMempool *pool = cxMempoolCreateSimple(4); 93 CxMempool *pool = cxMempoolCreateSimple(4);
56 CX_TEST_DO { 94 CX_TEST_DO {
57 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL); 95 CX_TEST_CALL_SUBROUTINE(test_mempool_malloc_verify, pool);
58 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL); 96 }
59 CX_TEST_ASSERT(pool->size == 2); 97 cxMempoolFree(pool);
60 CX_TEST_ASSERT(pool->capacity == 4); 98 }
61 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL); 99
62 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL); 100 CX_TEST(test_mempool_malloc2) {
63 CX_TEST_ASSERT(pool->size == 4); 101 CxMempool *pool = cxMempoolCreateAdvanced(4);
64 CX_TEST_ASSERT(pool->capacity == 4); 102 CX_TEST_DO {
65 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL); 103 CX_TEST_CALL_SUBROUTINE(test_mempool_malloc_verify, pool);
66 CX_TEST_ASSERT(cxMalloc(pool->allocator, sizeof(int)) != NULL); 104 }
67 CX_TEST_ASSERT(pool->size == 6); 105 cxMempoolFree(pool);
68 CX_TEST_ASSERT(pool->capacity >= 6); 106 }
107
108 static CX_TEST_SUBROUTINE(test_mempool_calloc_verify, CxMempool *pool) {
109 int *test = cxCalloc(pool->allocator, 2, sizeof(int));
110 CX_TEST_ASSERT(test != NULL);
111 CX_TEST_ASSERT(test[0] == 0);
112 CX_TEST_ASSERT(test[1] == 0);
113 #if __GNUC__ > 11
114 // we want to explicitly test the overflow
115 #pragma GCC diagnostic push
116 #pragma GCC diagnostic ignored "-Walloc-size-larger-than="
117 #endif
118 errno = 0;
119 CX_TEST_ASSERT(NULL == cxCalloc(pool->allocator, SIZE_MAX / 2, sizeof(int)));
120 CX_TEST_ASSERT(errno == EOVERFLOW);
121 #if __GNUC__ > 11
122 #pragma GCC diagnostic pop
123 #endif
124 }
125
126 CX_TEST(test_mempool_calloc0) {
127 CxMempool *pool = cxMempoolCreatePure(4);
128 CX_TEST_DO {
129 CX_TEST_CALL_SUBROUTINE(test_mempool_calloc_verify, pool);
69 } 130 }
70 cxMempoolFree(pool); 131 cxMempoolFree(pool);
71 } 132 }
72 133
73 CX_TEST(test_mempool_calloc) { 134 CX_TEST(test_mempool_calloc) {
74 CxMempool *pool = cxMempoolCreateSimple(4); 135 CxMempool *pool = cxMempoolCreateSimple(4);
75 CX_TEST_DO { 136 CX_TEST_DO {
76 int *test = cxCalloc(pool->allocator, 2, sizeof(int)); 137 CX_TEST_CALL_SUBROUTINE(test_mempool_calloc_verify, pool);
77 CX_TEST_ASSERT(test != NULL); 138 }
78 CX_TEST_ASSERT(test[0] == 0); 139 cxMempoolFree(pool);
79 CX_TEST_ASSERT(test[1] == 0); 140 }
80 } 141
81 cxMempoolFree(pool); 142 CX_TEST(test_mempool_calloc2) {
82 } 143 CxMempool *pool = cxMempoolCreateAdvanced(4);
83 144 CX_TEST_DO {
84 static unsigned test_mempool_destructor_called; 145 CX_TEST_CALL_SUBROUTINE(test_mempool_calloc_verify, pool);
85 146 }
86 static void test_mempool_destructor(cx_attr_unused void *mem) { 147 cxMempoolFree(pool);
87 test_mempool_destructor_called++; 148 }
88 } 149
89 150 static CX_TEST_SUBROUTINE(test_mempool_realloc_verify, CxMempool *pool, enum cx_mempool_type type) {
90 CX_TEST(test_mempool_realloc) { 151 // use realloc with NULL which shall behave as a malloc
91 CxMempool *pool = cxMempoolCreateSimple(4); 152 int *data = cxRealloc(pool->allocator, NULL, 2*sizeof(int));
92 cxMempoolGlobalDestructor(pool, test_mempool_destructor); 153 if (type == CX_MEMPOOL_TYPE_SIMPLE) {
93 CX_TEST_DO { 154 cxMempoolSetDestructor(data, test_mempool_destructor);
94 CX_TEST_ASSERT(pool->destr == test_mempool_destructor); 155 } else if (type == CX_MEMPOOL_TYPE_ADVANCED) {
95 int *data = cxMalloc(pool->allocator, sizeof(int)); 156 cxMempoolSetDestructor2(data, test_mempool_destructor2, &test_mempool_destructor_called);
96 *data = 13; 157 }
97 158 *data = 13;
98 int *rdata = data; 159
99 unsigned n = 1; 160 // shrink to actual sizeof(int)
100 while (rdata == data) { 161 data = cxRealloc(pool->allocator, data, sizeof(int));
101 n <<= 1; 162 CX_TEST_ASSERT(*data == 13);
102 // eventually the memory should be moved elsewhere 163
103 CX_TEST_ASSERTM(n < 65536, "Reallocation attempt failed - test not executable"); 164 // realloc with the same size (should not do anything)
104 rdata = cxRealloc(pool->allocator, data, n * sizeof(intptr_t)); 165 data = cxRealloc(pool->allocator, data, sizeof(int));
105 } 166 CX_TEST_ASSERT(*data == 13);
106 167
107 CX_TEST_ASSERT(*rdata == 13); 168 // now try hard to trigger a memmove
108 // test if destructor is still intact 169 int *rdata = data;
170 unsigned n = 1;
171 while (rdata == data) {
172 n <<= 1;
173 // eventually the memory should be moved elsewhere
174 CX_TEST_ASSERTM(n < 65536, "Reallocation attempt failed - test not executable");
175 rdata = cxRealloc(pool->allocator, data, n * sizeof(intptr_t));
176 }
177
178 CX_TEST_ASSERT(*rdata == 13);
179 // test if destructor is still intact
180 if (type != CX_MEMPOOL_TYPE_PURE) {
109 test_mempool_destructor_called = 0; 181 test_mempool_destructor_called = 0;
110 cxFree(pool->allocator, rdata); 182 cxFree(pool->allocator, rdata);
111 CX_TEST_ASSERT(test_mempool_destructor_called == 1); 183 CX_TEST_ASSERT(test_mempool_destructor_called == 1);
112 } 184 }
113 cxMempoolFree(pool); 185 }
114 } 186
115 187 CX_TEST(test_mempool_realloc0) {
188 CxMempool *pool = cxMempoolCreatePure(4);
189 CX_TEST_DO {
190 CX_TEST_CALL_SUBROUTINE(test_mempool_realloc_verify, pool, CX_MEMPOOL_TYPE_PURE);
191 }
192 cxMempoolFree(pool);
193 }
194
195 CX_TEST(test_mempool_realloc) {
196 CxMempool *pool = cxMempoolCreateSimple(4);
197 CX_TEST_DO {
198 CX_TEST_CALL_SUBROUTINE(test_mempool_realloc_verify, pool, CX_MEMPOOL_TYPE_SIMPLE);
199 }
200 cxMempoolFree(pool);
201 }
202
203 CX_TEST(test_mempool_realloc2) {
204 CxMempool *pool = cxMempoolCreateAdvanced(4);
205 CX_TEST_DO {
206 CX_TEST_CALL_SUBROUTINE(test_mempool_realloc_verify, pool, CX_MEMPOOL_TYPE_ADVANCED);
207 }
208 cxMempoolFree(pool);
209 }
210
211 static CX_TEST_SUBROUTINE(test_mempool_free_verify, CxMempool *pool) {
212 void *mem1, *mem2;
213 mem1 = cxMalloc(pool->allocator, 16);
214 cxFree(pool->allocator, mem1);
215 CX_TEST_ASSERT(pool->size == 0);
216
217 mem1 = cxMalloc(pool->allocator, 16);
218 mem1 = cxMalloc(pool->allocator, 16);
219 mem1 = cxMalloc(pool->allocator, 16);
220 mem2 = cxMalloc(pool->allocator, 16);
221 mem2 = cxMalloc(pool->allocator, 16);
222
223 CX_TEST_ASSERT(pool->size == 5);
224 // a realloc with size zero shall behave like a free
225 void *freed = cxRealloc(pool->allocator, mem1, 0);
226 CX_TEST_ASSERT(freed == NULL);
227 CX_TEST_ASSERT(pool->size == 4);
228 cxFree(pool->allocator, mem2);
229 CX_TEST_ASSERT(pool->size == 3);
230 }
231
232 CX_TEST(test_mempool_free0) {
233 CxMempool *pool = cxMempoolCreatePure(4);
234 CX_TEST_DO {
235 CX_TEST_CALL_SUBROUTINE(test_mempool_free_verify, pool);
236 }
237 cxMempoolFree(pool);
238 }
116 239
117 CX_TEST(test_mempool_free) { 240 CX_TEST(test_mempool_free) {
118 CxMempool *pool = cxMempoolCreateSimple(4); 241 CxMempool *pool = cxMempoolCreateSimple(4);
119 void *mem1, *mem2; 242 CX_TEST_DO {
120 CX_TEST_DO { 243 CX_TEST_CALL_SUBROUTINE(test_mempool_free_verify, pool);
121 mem1 = cxMalloc(pool->allocator, 16); 244 }
122 cxFree(pool->allocator, mem1); 245 cxMempoolFree(pool);
123 CX_TEST_ASSERT(pool->size == 0); 246 }
124 247
125 mem1 = cxMalloc(pool->allocator, 16); 248 CX_TEST(test_mempool_free2) {
126 mem1 = cxMalloc(pool->allocator, 16); 249 CxMempool *pool = cxMempoolCreateAdvanced(4);
127 mem1 = cxMalloc(pool->allocator, 16); 250 CX_TEST_DO {
128 mem2 = cxMalloc(pool->allocator, 16); 251 CX_TEST_CALL_SUBROUTINE(test_mempool_free_verify, pool);
129 mem2 = cxMalloc(pool->allocator, 16);
130
131 CX_TEST_ASSERT(pool->size == 5);
132 cxFree(pool->allocator, mem1);
133 CX_TEST_ASSERT(pool->size == 4);
134 cxFree(pool->allocator, mem2);
135 CX_TEST_ASSERT(pool->size == 3);
136 } 252 }
137 cxMempoolFree(pool); 253 cxMempoolFree(pool);
138 } 254 }
139 255
140 CX_TEST(test_mempool_destroy) { 256 CX_TEST(test_mempool_destroy) {
152 cxMempoolFree(pool); 268 cxMempoolFree(pool);
153 CX_TEST_ASSERT(test_mempool_destructor_called == 2); 269 CX_TEST_ASSERT(test_mempool_destructor_called == 2);
154 } 270 }
155 } 271 }
156 272
273 CX_TEST(test_mempool_destroy2) {
274 CxMempool *pool = cxMempoolCreateAdvanced(4);
275 CX_TEST_DO {
276 int *data = cxMalloc(pool->allocator, sizeof(int));
277 int ctr = 0;
278 *data = 47;
279 cxMempoolSetDestructor2(data, test_mempool_destructor2, &ctr);
280 CX_TEST_ASSERT(*data == 47);
281 cxFree(pool->allocator, data);
282 CX_TEST_ASSERT(ctr == 1);
283 data = cxMalloc(pool->allocator, sizeof(int));
284 cxMempoolSetDestructor2(data, test_mempool_destructor2, &ctr);
285 cxMempoolFree(pool);
286 CX_TEST_ASSERT(ctr == 2);
287 }
288 }
289
290 CX_TEST(test_mempool_remove_destructor) {
291 CxMempool *pool = cxMempoolCreateSimple(4);
292 CX_TEST_DO {
293 int *data = cxMalloc(pool->allocator, sizeof(int));
294 *data = 13;
295 cxMempoolSetDestructor(data, test_mempool_destructor);
296 CX_TEST_ASSERT(*data == 13);
297 cxMempoolRemoveDestructor(data);
298 CX_TEST_ASSERT(*data == 13);
299 test_mempool_destructor_called = 0;
300 cxFree(pool->allocator, data);
301 CX_TEST_ASSERT(test_mempool_destructor_called == 0);
302 data = cxMalloc(pool->allocator, sizeof(int));
303 *data = 99;
304 cxMempoolSetDestructor(data, test_mempool_destructor);
305 cxMempoolRemoveDestructor(data);
306 CX_TEST_ASSERT(*data == 99);
307 cxMempoolFree(pool);
308 CX_TEST_ASSERT(test_mempool_destructor_called == 0);
309 }
310 }
311
312 CX_TEST(test_mempool_remove_destructor2) {
313 CxMempool *pool = cxMempoolCreateAdvanced(4);
314 CX_TEST_DO {
315 int *data = cxMalloc(pool->allocator, sizeof(int));
316 int ctr = 0;
317 *data = 47;
318 cxMempoolSetDestructor2(data, test_mempool_destructor2, &ctr);
319 CX_TEST_ASSERT(*data == 47);
320 cxMempoolRemoveDestructor2(data);
321 CX_TEST_ASSERT(*data == 47);
322 cxFree(pool->allocator, data);
323 CX_TEST_ASSERT(ctr == 0);
324 data = cxMalloc(pool->allocator, sizeof(int));
325 *data = 99;
326 cxMempoolSetDestructor2(data, test_mempool_destructor2, &ctr);
327 cxMempoolRemoveDestructor2(data);
328 CX_TEST_ASSERT(*data == 99);
329 cxMempoolFree(pool);
330 CX_TEST_ASSERT(ctr == 0);
331 }
332 }
333
334 static CX_TEST_SUBROUTINE(test_mempool_global_destructors_verify, CxMempool *pool) {
335 int *data = cxMalloc(pool->allocator, sizeof(int));
336 int ctr = 0;
337 cxMempoolGlobalDestructor(pool, test_mempool_destructor);
338 cxMempoolGlobalDestructor2(pool, test_mempool_destructor2, &ctr);
339 test_mempool_destructor_called = 0;
340 cxFree(pool->allocator, data);
341 CX_TEST_ASSERT(ctr == 1);
342 CX_TEST_ASSERT(test_mempool_destructor_called == 1);
343 data = cxMalloc(pool->allocator, sizeof(int));
344 cxMempoolFree(pool);
345 CX_TEST_ASSERT(ctr == 2);
346 CX_TEST_ASSERT(test_mempool_destructor_called == 2);
347 }
348
349 CX_TEST(test_mempool_global_destructors0) {
350 CxMempool *pool = cxMempoolCreatePure(4);
351 CX_TEST_DO {
352 CX_TEST_CALL_SUBROUTINE(test_mempool_global_destructors_verify, pool);
353 }
354 }
355
356 CX_TEST(test_mempool_global_destructors) {
357 CxMempool *pool = cxMempoolCreateSimple(4);
358 CX_TEST_DO {
359 CX_TEST_CALL_SUBROUTINE(test_mempool_global_destructors_verify, pool);
360 }
361 }
362
363 CX_TEST(test_mempool_global_destructors2) {
364 CxMempool *pool = cxMempoolCreateAdvanced(4);
365 CX_TEST_DO {
366 CX_TEST_CALL_SUBROUTINE(test_mempool_global_destructors_verify, pool);
367 }
368 }
369
157 CX_TEST(test_mempool_register) { 370 CX_TEST(test_mempool_register) {
371 CxMempool *pool = cxMempoolCreateAdvanced(4);
372 CX_TEST_DO {
373 int *data = cxMalloc(pool->allocator, sizeof(int));
374 test_mempool_destructor_called = 0;
375 cxMempoolSetDestructor2(data, test_mempool_destructor2, &test_mempool_destructor_called);
376 int donotfree = 0;
377 cxMempoolRegister(pool, &donotfree, test_mempool_destructor);
378 cxMempoolFree(pool);
379 CX_TEST_ASSERT(test_mempool_destructor_called == 2);
380 }
381 }
382
383 CX_TEST(test_mempool_register2) {
158 CxMempool *pool = cxMempoolCreateSimple(4); 384 CxMempool *pool = cxMempoolCreateSimple(4);
159 CX_TEST_DO { 385 CX_TEST_DO {
160 int *data = cxMalloc(pool->allocator, sizeof(int)); 386 int *data = cxMalloc(pool->allocator, sizeof(int));
161 test_mempool_destructor_called = 0; 387 test_mempool_destructor_called = 0;
162 cxMempoolSetDestructor(data, test_mempool_destructor); 388 cxMempoolSetDestructor(data, test_mempool_destructor);
163 int donotfree = 0; 389 int donotfree = 0;
164 cxMempoolRegister(pool, &donotfree, test_mempool_destructor); 390 cxMempoolRegister2(pool, &donotfree, test_mempool_destructor2, &test_mempool_destructor_called);
165 cxMempoolFree(pool); 391 cxMempoolFree(pool);
166 CX_TEST_ASSERT(test_mempool_destructor_called == 2); 392 CX_TEST_ASSERT(test_mempool_destructor_called == 2);
167 } 393 }
168 } 394 }
169 395
220 446
221 CX_TEST(test_mempool_transfer_object) { 447 CX_TEST(test_mempool_transfer_object) {
222 CxMempool *src = cxMempoolCreateSimple(4); 448 CxMempool *src = cxMempoolCreateSimple(4);
223 CxMempool *dest = cxMempoolCreateSimple(4); 449 CxMempool *dest = cxMempoolCreateSimple(4);
224 CX_TEST_DO { 450 CX_TEST_DO {
451 int *a = cxMalloc(src->allocator, sizeof(int));
225 int *b = cxMalloc(src->allocator, sizeof(int)); 452 int *b = cxMalloc(src->allocator, sizeof(int));
226 b = cxMalloc(src->allocator, sizeof(int));
227 int *c = malloc(sizeof(int)); 453 int *c = malloc(sizeof(int));
228 cxMempoolRegister(src, c, free); 454 cxMempoolRegister(src, c, free);
455 int *d = malloc(sizeof(int));
456 cxMempoolRegister(src, d, free);
229 CX_TEST_ASSERT(src->size == 2); 457 CX_TEST_ASSERT(src->size == 2);
230 CX_TEST_ASSERT(src->registered_size == 1); 458 CX_TEST_ASSERT(src->registered_size == 2);
231 459
232 int result = cxMempoolTransferObject(src, dest, b); 460 int result = cxMempoolTransferObject(src, dest, a);
233 CX_TEST_ASSERT(result == 0); 461 CX_TEST_ASSERT(result == 0);
234 CX_TEST_ASSERT(src->size == 1); 462 CX_TEST_ASSERT(src->size == 1);
463 CX_TEST_ASSERT(src->registered_size == 2);
235 CX_TEST_ASSERT(dest->size == 1); 464 CX_TEST_ASSERT(dest->size == 1);
236 result = cxMempoolTransferObject(src, dest, b); 465 CX_TEST_ASSERT(dest->registered_size == 0);
466 result = cxMempoolTransferObject(src, dest, a);
237 CX_TEST_ASSERT(result != 0); 467 CX_TEST_ASSERT(result != 0);
238 CX_TEST_ASSERT(src->size == 1); 468 CX_TEST_ASSERT(src->size == 1);
469 CX_TEST_ASSERT(src->registered_size == 2);
239 CX_TEST_ASSERT(dest->size == 1); 470 CX_TEST_ASSERT(dest->size == 1);
471 CX_TEST_ASSERT(dest->registered_size == 0);
240 472
241 // can also transfer foreign memory this way 473 // can also transfer foreign memory this way
242 CX_TEST_ASSERT(src->registered_size == 1);
243 CX_TEST_ASSERT(dest->registered_size == 0);
244 result = cxMempoolTransferObject(src, dest, c); 474 result = cxMempoolTransferObject(src, dest, c);
245 CX_TEST_ASSERT(result == 0); 475 CX_TEST_ASSERT(result == 0);
246 CX_TEST_ASSERT(src->registered_size == 0); 476 CX_TEST_ASSERT(src->size == 1);
477 CX_TEST_ASSERT(src->registered_size == 1);
478 CX_TEST_ASSERT(dest->size == 1);
247 CX_TEST_ASSERT(dest->registered_size == 1); 479 CX_TEST_ASSERT(dest->registered_size == 1);
248 480
481 // src==dest is an error
249 result = cxMempoolTransferObject(dest, dest, b); 482 result = cxMempoolTransferObject(dest, dest, b);
250 CX_TEST_ASSERT(result != 0); 483 CX_TEST_ASSERT(result != 0);
251 CX_TEST_ASSERT(src->size == 1); 484 CX_TEST_ASSERT(src->size == 1);
252 CX_TEST_ASSERT(dest->size == 1); 485 CX_TEST_ASSERT(dest->size == 1);
486
487 // check that we don't die when we free memory that's still in the source pool
488 cxFree(src->allocator, b);
253 } 489 }
254 cxMempoolFree(src); 490 cxMempoolFree(src);
255 cxMempoolFree(dest); 491 cxMempoolFree(dest);
256 // let valgrind check that everything worked 492 // let valgrind check that everything else worked
257 } 493 }
258 494
259 CxTestSuite *cx_test_suite_mempool(void) { 495 CxTestSuite *cx_test_suite_mempool(void) {
260 CxTestSuite *suite = cx_test_suite_new("mempool"); 496 CxTestSuite *suite = cx_test_suite_new("mempool");
261 497
262 cx_test_register(suite, test_mempool_create); 498 cx_test_register(suite, test_mempool_create);
499 cx_test_register(suite, test_mempool_malloc0);
500 cx_test_register(suite, test_mempool_calloc0);
501 cx_test_register(suite, test_mempool_realloc0);
502 cx_test_register(suite, test_mempool_free0);
263 cx_test_register(suite, test_mempool_malloc); 503 cx_test_register(suite, test_mempool_malloc);
264 cx_test_register(suite, test_mempool_calloc); 504 cx_test_register(suite, test_mempool_calloc);
265 cx_test_register(suite, test_mempool_realloc); 505 cx_test_register(suite, test_mempool_realloc);
266 cx_test_register(suite, test_mempool_free); 506 cx_test_register(suite, test_mempool_free);
267 cx_test_register(suite, test_mempool_destroy); 507 cx_test_register(suite, test_mempool_destroy);
508 cx_test_register(suite, test_mempool_malloc2);
509 cx_test_register(suite, test_mempool_calloc2);
510 cx_test_register(suite, test_mempool_realloc2);
511 cx_test_register(suite, test_mempool_free2);
512 cx_test_register(suite, test_mempool_destroy2);
513 cx_test_register(suite, test_mempool_remove_destructor);
514 cx_test_register(suite, test_mempool_remove_destructor2);
515 cx_test_register(suite, test_mempool_global_destructors0);
516 cx_test_register(suite, test_mempool_global_destructors);
517 cx_test_register(suite, test_mempool_global_destructors2);
268 cx_test_register(suite, test_mempool_register); 518 cx_test_register(suite, test_mempool_register);
519 cx_test_register(suite, test_mempool_register2);
269 cx_test_register(suite, test_mempool_transfer); 520 cx_test_register(suite, test_mempool_transfer);
270 cx_test_register(suite, test_mempool_transfer_object); 521 cx_test_register(suite, test_mempool_transfer_object);
271 522
272 return suite; 523 return suite;
273 } 524 }

mercurial