Hash :
f0e693b1
Author :
Date :
2021-09-07T17:53:49
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#include "clar_libgit2.h"
#include "buf.h"
void test_core_buf__sanitize(void)
{
git_buf buf = { (char *)0x42, 0, 16 };
cl_git_pass(git_buf_sanitize(&buf));
cl_assert_equal_s(buf.ptr, "");
cl_assert_equal_i(buf.reserved, 0);
cl_assert_equal_i(buf.size, 0);
git_buf_dispose(&buf);
}
void test_core_buf__tostr(void)
{
git_str str = GIT_STR_INIT;
git_buf buf = { (char *)0x42, 0, 16 };
cl_git_pass(git_buf_tostr(&str, &buf));
cl_assert_equal_s(buf.ptr, "");
cl_assert_equal_i(buf.reserved, 0);
cl_assert_equal_i(buf.size, 0);
cl_assert_equal_s(str.ptr, "");
cl_assert_equal_i(str.asize, 0);
cl_assert_equal_i(str.size, 0);
git_buf_dispose(&buf);
git_str_dispose(&str);
}
void test_core_buf__fromstr(void)
{
git_str str = GIT_STR_INIT;
git_buf buf = { (char *)0x42, 0, 16 };
cl_git_pass(git_buf_tostr(&str, &buf));
cl_git_pass(git_str_puts(&str, "Hello, world."));
cl_git_pass(git_buf_fromstr(&buf, &str));
cl_assert(buf.reserved > 14);
cl_assert_equal_i(buf.size, 13);
cl_assert_equal_s(buf.ptr, "Hello, world.");
cl_assert_equal_s(str.ptr, "");
cl_assert_equal_i(str.asize, 0);
cl_assert_equal_i(str.size, 0);
git_buf_dispose(&buf);
git_str_dispose(&str);
}