]>
git.proxmox.com Git - libgit2.git/blob - tests/core/buf.c
1 #include "clar_libgit2.h"
4 void test_core_buf__sanitize(void)
6 git_buf buf
= { (char *)0x42, 0, 16 };
8 cl_git_pass(git_buf_sanitize(&buf
));
9 cl_assert_equal_s(buf
.ptr
, "");
10 cl_assert_equal_i(buf
.reserved
, 0);
11 cl_assert_equal_i(buf
.size
, 0);
13 git_buf_dispose(&buf
);
16 void test_core_buf__tostr(void)
18 git_str str
= GIT_STR_INIT
;
19 git_buf buf
= { (char *)0x42, 0, 16 };
21 cl_git_pass(git_buf_tostr(&str
, &buf
));
23 cl_assert_equal_s(buf
.ptr
, "");
24 cl_assert_equal_i(buf
.reserved
, 0);
25 cl_assert_equal_i(buf
.size
, 0);
27 cl_assert_equal_s(str
.ptr
, "");
28 cl_assert_equal_i(str
.asize
, 0);
29 cl_assert_equal_i(str
.size
, 0);
31 git_buf_dispose(&buf
);
32 git_str_dispose(&str
);
35 void test_core_buf__fromstr(void)
37 git_str str
= GIT_STR_INIT
;
38 git_buf buf
= { (char *)0x42, 0, 16 };
40 cl_git_pass(git_buf_tostr(&str
, &buf
));
41 cl_git_pass(git_str_puts(&str
, "Hello, world."));
42 cl_git_pass(git_buf_fromstr(&buf
, &str
));
44 cl_assert(buf
.reserved
> 14);
45 cl_assert_equal_i(buf
.size
, 13);
46 cl_assert_equal_s(buf
.ptr
, "Hello, world.");
48 cl_assert_equal_s(str
.ptr
, "");
49 cl_assert_equal_i(str
.asize
, 0);
50 cl_assert_equal_i(str
.size
, 0);
52 git_buf_dispose(&buf
);
53 git_str_dispose(&str
);