unicode.c 1.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "clar_libgit2.h"

static git_repository *repo;

void test_refs_unicode__initialize(void)
{
	cl_fixture_sandbox("testrepo.git");

	cl_git_pass(git_repository_open(&repo, "testrepo.git"));
}

void test_refs_unicode__cleanup(void)
{
	git_repository_free(repo);
15 16
	repo = NULL;

17 18 19 20 21
	cl_fixture_cleanup("testrepo.git");
}

void test_refs_unicode__create_and_lookup(void)
{
22
	git_reference *ref0, *ref1, *ref2;
23 24 25 26 27 28
	git_repository *repo2;

	const char *REFNAME = "refs/heads/" "\305" "ngstr" "\366" "m";
	const char *master = "refs/heads/master";

	/* Create the reference */
29
	cl_git_pass(git_reference_lookup(&ref0, repo, master));
30
	cl_git_pass(git_reference_create(&ref1, repo, REFNAME, git_reference_target(ref0), 0));
31
	cl_assert_equal_s(REFNAME, git_reference_name(ref1));
32 33 34 35 36

	/* Lookup the reference in a different instance of the repository */
	cl_git_pass(git_repository_open(&repo2, "testrepo.git"));
	cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME));

37
	cl_assert(git_oid_cmp(git_reference_target(ref1), git_reference_target(ref2)) == 0);
38
	cl_assert_equal_s(REFNAME, git_reference_name(ref2));
39

40 41
	git_reference_free(ref0);
	git_reference_free(ref1);
42 43 44
	git_reference_free(ref2);
	git_repository_free(repo2);
}