MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_objectPoolAddItem

Function test_objectPoolAddItem

tests/unit/test_object_pool.c:45–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void test_objectPoolAddItem() {
46 ObjectPool *object_pool = ObjectPool_New(256, sizeof(uint), NULL);
47 uint item_count = 128;
48 uint final_item_count = item_count *= 16;
49 uint *item_pointers[final_item_count];
50 // Add items to pool.
51 for(uint i = 0; i < item_count; i++) {
52 uint *item = (uint *)ObjectPool_NewItem(object_pool);
53 *item = i;
54 item_pointers[i] = item;
55 }
56
57 // Add enough items to cause the ObjectPool to reallocate.
58 uint prev_count = object_pool->itemCount;
59 item_count = final_item_count;
60
61 // Add new items.
62 for(uint i = prev_count; i < item_count; i++) {
63 uint *item = (uint *)ObjectPool_NewItem(object_pool);
64 *item = i;
65 item_pointers[i] = item;
66 }
67
68 // Validate that no items have been modified.
69 for(uint i = 0; i < item_count; i++) {
70 TEST_ASSERT(*item_pointers[i] == i);
71 }
72 ObjectPool_Free(object_pool);
73}
74
75void test_objectPoolRemoveItem() {
76 ObjectPool *object_pool = ObjectPool_New(1024, sizeof(uint), NULL);

Callers

nothing calls this directly

Calls 3

ObjectPool_NewFunction · 0.85
ObjectPool_NewItemFunction · 0.85
ObjectPool_FreeFunction · 0.85

Tested by

no test coverage detected