interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / unit-tests / u-mem-pool.c

25 lines · 611 bytes Raw Blame History
1#include "unit-test.h"
2#include "mem-pool.h"
3
4static void test_many_pool_allocations(size_t block_alloc)
5{
6 struct mem_pool pool = { .block_alloc = block_alloc };
7 size_t size = 100;
8 char *buffer = mem_pool_calloc(&pool, 1, size);
9 for (size_t i = 0; i < size; i++)
10 cl_assert_equal_i(0, buffer[i]);
11 cl_assert(pool.mp_block != NULL);
12 cl_assert(pool.mp_block->next_free != NULL);
13 cl_assert(pool.mp_block->end != NULL);
14 mem_pool_discard(&pool, 0);
15}
16
17void test_mem_pool__big_block(void)
18{
19 test_many_pool_allocations(1024 * 1024);
20}
21
22void test_mem_pool__tiny_block(void)
23{
24 test_many_pool_allocations(1);
25}