]> git.proxmox.com Git - libgit2.git/blob - tests/libgit2/refs/unicode.c
New upstream version 1.5.0+ds
[libgit2.git] / tests / libgit2 / refs / unicode.c
1 #include "clar_libgit2.h"
2
3 static git_repository *repo;
4
5 void test_refs_unicode__initialize(void)
6 {
7 repo = cl_git_sandbox_init("testrepo.git");
8 }
9
10 void test_refs_unicode__cleanup(void)
11 {
12 cl_git_sandbox_cleanup();
13 repo = NULL;
14 }
15
16 void test_refs_unicode__create_and_lookup(void)
17 {
18 git_reference *ref0, *ref1, *ref2;
19 git_repository *repo2;
20
21 const char *REFNAME = "refs/heads/" "\303\205" "ngstr" "\303\266" "m";
22 const char *master = "refs/heads/master";
23
24 /* Create the reference */
25 cl_git_pass(git_reference_lookup(&ref0, repo, master));
26 cl_git_pass(git_reference_create(
27 &ref1, repo, REFNAME, git_reference_target(ref0), 0, NULL));
28 cl_assert_equal_s(REFNAME, git_reference_name(ref1));
29 git_reference_free(ref0);
30
31 /* Lookup the reference in a different instance of the repository */
32 cl_git_pass(git_repository_open(&repo2, "testrepo.git"));
33
34 cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME));
35 cl_assert_equal_oid(git_reference_target(ref1), git_reference_target(ref2));
36 cl_assert_equal_s(REFNAME, git_reference_name(ref2));
37 git_reference_free(ref2);
38
39 #if GIT_USE_ICONV
40 /* Lookup reference by decomposed unicode name */
41
42 #define REFNAME_DECOMPOSED "refs/heads/" "A" "\314\212" "ngstro" "\314\210" "m"
43
44 cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME_DECOMPOSED));
45 cl_assert_equal_oid(git_reference_target(ref1), git_reference_target(ref2));
46 cl_assert_equal_s(REFNAME, git_reference_name(ref2));
47 git_reference_free(ref2);
48 #endif
49
50 /* Cleanup */
51
52 git_reference_free(ref1);
53 git_repository_free(repo2);
54 }