]>
git.proxmox.com Git - libgit2.git/blob - tests/libgit2/blame/getters.c
1 #include "clar_libgit2.h"
7 void test_blame_getters__initialize(void)
10 git_blame_options opts
= GIT_BLAME_OPTIONS_INIT
;
12 git_blame_hunk hunks
[] = {
13 { 3, {{0}}, 1, NULL
, {{0}}, "a", 0},
14 { 3, {{0}}, 4, NULL
, {{0}}, "b", 0},
15 { 3, {{0}}, 7, NULL
, {{0}}, "c", 0},
16 { 3, {{0}}, 10, NULL
, {{0}}, "d", 0},
17 { 3, {{0}}, 13, NULL
, {{0}}, "e", 0},
20 g_blame
= git_blame__alloc(NULL
, opts
, "");
23 git_blame_hunk
*h
= git__calloc(1, sizeof(git_blame_hunk
));
24 h
->final_start_line_number
= hunks
[i
].final_start_line_number
;
25 h
->orig_path
= git__strdup(hunks
[i
].orig_path
);
26 h
->lines_in_hunk
= hunks
[i
].lines_in_hunk
;
28 git_vector_insert(&g_blame
->hunks
, h
);
32 void test_blame_getters__cleanup(void)
34 git_blame_free(g_blame
);
38 void test_blame_getters__byindex(void)
40 const git_blame_hunk
*h
= git_blame_get_hunk_byindex(g_blame
, 2);
42 cl_assert_equal_s(h
->orig_path
, "c");
44 h
= git_blame_get_hunk_byindex(g_blame
, 95);
45 cl_assert_equal_p(h
, NULL
);
48 void test_blame_getters__byline(void)
50 const git_blame_hunk
*h
= git_blame_get_hunk_byline(g_blame
, 5);
52 cl_assert_equal_s(h
->orig_path
, "b");
54 h
= git_blame_get_hunk_byline(g_blame
, 95);
55 cl_assert_equal_p(h
, NULL
);