]> git.proxmox.com Git - libgit2.git/blob - tests/refs/dup.c
8a89cd95c5ef6e974823fb4de49b0aa12374c013
[libgit2.git] / tests / refs / dup.c
1 #include "clar_libgit2.h"
2 #include "refs.h"
3
4 static git_repository *g_repo;
5
6 void test_refs_dup__initialize(void)
7 {
8 g_repo = cl_git_sandbox_init("testrepo.git");
9 }
10
11 void test_refs_dup__cleanup(void)
12 {
13 cl_git_sandbox_cleanup();
14 }
15
16 void test_refs_dup__direct(void)
17 {
18 git_reference *a, *b;
19
20 cl_git_pass(git_reference_lookup(&a, g_repo, "refs/heads/master"));
21 cl_git_pass(git_reference_dup(&b, a));
22
23 cl_assert(git_reference_cmp(a, b) == 0);
24 cl_assert(git_reference_owner(b) == g_repo);
25
26 git_reference_free(b);
27 git_reference_free(a);
28 }
29
30 void test_refs_dup__symbolic(void)
31 {
32 git_reference *a, *b;
33
34 cl_git_pass(git_reference_lookup(&a, g_repo, "HEAD"));
35 cl_git_pass(git_reference_dup(&b, a));
36
37 cl_assert(git_reference_cmp(a, b) == 0);
38 cl_assert(git_reference_owner(b) == g_repo);
39
40 git_reference_free(b);
41 git_reference_free(a);
42 }