]>
git.proxmox.com Git - libgit2.git/blob - tests/util/pool.c
1 #include "clar_libgit2.h"
5 void test_pool__0(void)
13 for (i
= 1; i
< 10000; i
*= 2) {
14 ptr
= git_pool_malloc(&p
, i
);
15 cl_assert(ptr
!= NULL
);
16 cl_assert(git_pool__ptr_in_pool(&p
, ptr
));
17 cl_assert(!git_pool__ptr_in_pool(&p
, &i
));
23 void test_pool__1(void)
31 for (i
= 2010; i
> 0; i
--)
32 cl_assert(git_pool_malloc(&p
, i
) != NULL
);
34 #ifndef GIT_DEBUG_POOL
35 /* with fixed page size, allocation must end up with these values */
36 cl_assert_equal_i(591, git_pool__open_pages(&p
));
43 for (i
= 2010; i
> 0; i
--)
44 cl_assert(git_pool_malloc(&p
, i
) != NULL
);
46 #ifndef GIT_DEBUG_POOL
47 /* with fixed page size, allocation must end up with these values */
48 cl_assert_equal_i(sizeof(void *) == 8 ? 575 : 573, git_pool__open_pages(&p
));
53 void test_pool__strndup_limit(void)
58 /* ensure 64 bit doesn't overflow */
59 cl_assert(git_pool_strndup(&p
, "foo", (size_t)-1) == NULL
);