| 43 | } |
| 44 | |
| 45 | void 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 | |
| 75 | void test_objectPoolRemoveItem() { |
| 76 | ObjectPool *object_pool = ObjectPool_New(1024, sizeof(uint), NULL); |
nothing calls this directly
no test coverage detected