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

Function test_objectPoolNew

tests/unit/test_object_pool.c:19–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "acutest.h"
18
19void test_objectPoolNew() {
20 // Create a new ObjectPool capable of holding at least 1024 integer items.
21 uint item_size = sizeof(uint);
22 ObjectPool *object_pool = ObjectPool_New(1024, item_size, NULL);
23
24 TEST_ASSERT(object_pool->itemCount == 0); // No items have been added.
25 TEST_ASSERT(object_pool->itemCap >= 1024);
26
27 // The size of items in the pool is greater to accommodate an internal header ID.
28 uint header_size = sizeof(uint64_t);
29 TEST_ASSERT(object_pool->itemSize == item_size + header_size);
30 TEST_ASSERT(object_pool->blockCount >= 1024 / POOL_BLOCK_CAP);
31
32 // Verify that blocks are properly chained together.
33 for(uint i = 0; i < object_pool->blockCount; i++) {
34 Block *block = object_pool->blocks[i];
35 TEST_ASSERT(block->itemSize == object_pool->itemSize);
36 TEST_ASSERT(block->data != NULL);
37 if(i > 0) {
38 TEST_ASSERT(object_pool->blocks[i - 1]->next == object_pool->blocks[i]);
39 }
40 }
41
42 ObjectPool_Free(object_pool);
43}
44
45void test_objectPoolAddItem() {
46 ObjectPool *object_pool = ObjectPool_New(256, sizeof(uint), NULL);

Callers

nothing calls this directly

Calls 2

ObjectPool_NewFunction · 0.85
ObjectPool_FreeFunction · 0.85

Tested by

no test coverage detected