diff options
Diffstat (limited to 'listpool/test')
-rw-r--r-- | listpool/test/listpool_test.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/listpool/test/listpool_test.c b/listpool/test/listpool_test.c index cb54d00..7a7b0cf 100644 --- a/listpool/test/listpool_test.c +++ b/listpool/test/listpool_test.c | |||
@@ -137,6 +137,23 @@ TEST_CASE(listpool_traverse_full) { | |||
137 | TEST_EQUAL(sum(&pool), (NUM_BLOCKS) * (NUM_BLOCKS + 1) / 2); | 137 | TEST_EQUAL(sum(&pool), (NUM_BLOCKS) * (NUM_BLOCKS + 1) / 2); |
138 | } | 138 | } |
139 | 139 | ||
140 | // Get the ith (allocated) block. | ||
141 | TEST_CASE(listpool_get_block) { | ||
142 | test_pool pool; | ||
143 | listpool_make(&pool); | ||
144 | |||
145 | for (int i = 0; i < NUM_BLOCKS; ++i) { | ||
146 | int* block = listpool_alloc(&pool); | ||
147 | TEST_TRUE(block != 0); | ||
148 | *block = i; | ||
149 | TEST_EQUAL(listpool_get_block_index(&pool, block), (size_t)i); | ||
150 | } | ||
151 | |||
152 | for (int i = 0; i < NUM_BLOCKS; ++i) { | ||
153 | TEST_EQUAL(*listpool_get_block(&pool, i), i); | ||
154 | } | ||
155 | } | ||
156 | |||
140 | // Remove a value from the list. | 157 | // Remove a value from the list. |
141 | TEST_CASE(listpool_remove_value) { | 158 | TEST_CASE(listpool_remove_value) { |
142 | test_pool pool; | 159 | test_pool pool; |