Hash :
a24e656a
Author :
Date :
2021-09-04T10:16:41
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
#include "clar_libgit2.h"
#include "cache.h"
void test_core_opts__cleanup(void)
{
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, NULL, 0));
}
void test_core_opts__readwrite(void)
{
size_t old_val = 0;
size_t new_val = 0;
git_libgit2_opts(GIT_OPT_GET_MWINDOW_SIZE, &old_val);
git_libgit2_opts(GIT_OPT_SET_MWINDOW_SIZE, (size_t)1234);
git_libgit2_opts(GIT_OPT_GET_MWINDOW_SIZE, &new_val);
cl_assert(new_val == 1234);
git_libgit2_opts(GIT_OPT_SET_MWINDOW_SIZE, old_val);
git_libgit2_opts(GIT_OPT_GET_MWINDOW_SIZE, &new_val);
cl_assert(new_val == old_val);
}
void test_core_opts__invalid_option(void)
{
cl_git_fail(git_libgit2_opts(-1, "foobar"));
}
void test_core_opts__extensions_query(void)
{
git_strarray out = { 0 };
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
cl_assert_equal_sz(out.count, 1);
cl_assert_equal_s("noop", out.strings[0]);
git_strarray_dispose(&out);
}
void test_core_opts__extensions_add(void)
{
const char *in[] = { "foo" };
git_strarray out = { 0 };
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in)));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
cl_assert_equal_sz(out.count, 2);
cl_assert_equal_s("noop", out.strings[0]);
cl_assert_equal_s("foo", out.strings[1]);
git_strarray_dispose(&out);
}
void test_core_opts__extensions_remove(void)
{
const char *in[] = { "bar", "!negate", "!noop", "baz" };
git_strarray out = { 0 };
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in)));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
cl_assert_equal_sz(out.count, 2);
cl_assert_equal_s("bar", out.strings[0]);
cl_assert_equal_s("baz", out.strings[1]);
git_strarray_dispose(&out);
}