]> git.proxmox.com Git - libgit2.git/blob - tests/libgit2/core/pool.c
New upstream version 1.5.0+ds
[libgit2.git] / tests / libgit2 / core / pool.c
1 #include "clar_libgit2.h"
2 #include "pool.h"
3 #include "git2/oid.h"
4
5 static char to_hex[] = "0123456789abcdef";
6
7 void test_core_pool__oid(void)
8 {
9 git_pool p;
10 char oid_hex[GIT_OID_HEXSZ];
11 git_oid *oid;
12 int i, j;
13
14 memset(oid_hex, '0', sizeof(oid_hex));
15
16 git_pool_init(&p, sizeof(git_oid));
17 p.page_size = 4000;
18
19 for (i = 1000; i < 10000; i++) {
20 oid = git_pool_malloc(&p, 1);
21 cl_assert(oid != NULL);
22
23 for (j = 0; j < 8; j++)
24 oid_hex[j] = to_hex[(i >> (4 * j)) & 0x0f];
25 cl_git_pass(git_oid_fromstr(oid, oid_hex));
26 }
27
28 #ifndef GIT_DEBUG_POOL
29 /* with fixed page size, allocation must end up with these values */
30 cl_assert_equal_i(sizeof(void *) == 8 ? 55 : 45, git_pool__open_pages(&p));
31 #endif
32 git_pool_clear(&p);
33 }