diff options
| author | rationalcoder <rationalcoder@gmail.com> | 2025-09-16 16:31:10 -0500 |
|---|---|---|
| committer | rationalcoder <rationalcoder@gmail.com> | 2025-09-16 16:31:10 -0500 |
| commit | 710533975e6da554b943bc24fb6e38ba22fe959a (patch) | |
| tree | 712468d3c479b0be84086c9a6bb7785f227905f5 /tests | |
| parent | 11be0cb4ab41c52591a90ca07e7a04062487369e (diff) | |
Fix out-of-band allocations in dynamic arenas
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/mem/test_mem_dynamic_pool.odin | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/core/mem/test_mem_dynamic_pool.odin b/tests/core/mem/test_mem_dynamic_pool.odin index fa204d3b1..82cee89af 100644 --- a/tests/core/mem/test_mem_dynamic_pool.odin +++ b/tests/core/mem/test_mem_dynamic_pool.odin @@ -44,11 +44,11 @@ expect_pool_allocation :: proc(t: ^testing.T, expected_used_bytes, num_bytes, al testing.expect(t, pool.used_blocks == nil) } -expect_pool_allocation_out_of_band :: proc(t: ^testing.T, num_bytes, out_band_size: int) { +expect_pool_allocation_out_of_band :: proc(t: ^testing.T, num_bytes, block_size, out_band_size: int) { testing.expect(t, num_bytes >= out_band_size, "Sanity check failed, your test call is flawed! Make sure that num_bytes >= out_band_size!") pool: mem.Dynamic_Pool - mem.dynamic_pool_init(&pool, out_band_size = out_band_size) + mem.dynamic_pool_init(&pool, block_size = block_size, out_band_size = out_band_size) pool_allocator := mem.dynamic_pool_allocator(&pool) element, err := mem.alloc(num_bytes, allocator = pool_allocator) @@ -69,14 +69,15 @@ test_dynamic_pool_alloc_aligned :: proc(t: ^testing.T) { @(test) test_dynamic_pool_alloc_unaligned :: proc(t: ^testing.T) { - expect_pool_allocation(t, expected_used_bytes = 8, num_bytes=1, alignment=8) - expect_pool_allocation(t, expected_used_bytes = 16, num_bytes=9, alignment=8) + expect_pool_allocation(t, expected_used_bytes = 8, num_bytes = 1, alignment = 8) + expect_pool_allocation(t, expected_used_bytes = 16, num_bytes = 9, alignment = 8) } @(test) test_dynamic_pool_alloc_out_of_band :: proc(t: ^testing.T) { - expect_pool_allocation_out_of_band(t, num_bytes = 128, out_band_size = 128) - expect_pool_allocation_out_of_band(t, num_bytes = 129, out_band_size = 128) + expect_pool_allocation_out_of_band(t, num_bytes = 128, block_size = 512, out_band_size = 128) + expect_pool_allocation_out_of_band(t, num_bytes = 129, block_size = 512, out_band_size = 128) + expect_pool_allocation_out_of_band(t, num_bytes = 513, block_size = 512, out_band_size = 128) } @(test) @@ -98,4 +99,4 @@ intentionally_leaky_test :: proc(t: ^testing.T) { leak_verifier :: proc(t: ^testing.T, ta: ^mem.Tracking_Allocator) { testing.expect_value(t, len(ta.allocation_map), 1) testing.expect_value(t, len(ta.bad_free_array), 1) -}
\ No newline at end of file +} |