aboutsummaryrefslogtreecommitdiff
path: root/listpool/test/listpool_test.c
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2023-01-23 18:32:49 -0800
committer3gg <3gg@shellblade.net>2023-01-23 18:32:49 -0800
commit470a25323ca89ffa3b0b697aeddcf184d12a1382 (patch)
treec5076734e0154d5a3189105f61dc5f9a526a8e07 /listpool/test/listpool_test.c
parentf5b77325c44649bb92fa379b7df77c275f3925dc (diff)
Update listpool's interface to be on par with mempool's.
Diffstat (limited to 'listpool/test/listpool_test.c')
-rw-r--r--listpool/test/listpool_test.c17
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.
141TEST_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.
141TEST_CASE(listpool_remove_value) { 158TEST_CASE(listpool_remove_value) {
142 test_pool pool; 159 test_pool pool;