Blame tests/graph/descendant_of.c

Packit Service 20376f
#include "clar_libgit2.h"
Packit Service 20376f
Packit Service 20376f
static git_repository *_repo;
Packit Service 20376f
static git_commit *commit;
Packit Service 20376f
Packit Service 20376f
void test_graph_descendant_of__initialize(void)
Packit Service 20376f
{
Packit Service 20376f
	git_oid oid;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git")));
Packit Service 20376f
Packit Service 20376f
	git_oid_fromstr(&oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
Packit Service 20376f
	cl_git_pass(git_commit_lookup(&commit, _repo, &oid));
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_graph_descendant_of__cleanup(void)
Packit Service 20376f
{
Packit Service 20376f
	git_commit_free(commit);
Packit Service 20376f
	commit = NULL;
Packit Service 20376f
Packit Service 20376f
	git_repository_free(_repo);
Packit Service 20376f
	_repo = NULL;
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_graph_descendant_of__returns_correct_result(void)
Packit Service 20376f
{
Packit Service 20376f
	git_commit *other;
Packit Service 20376f
Packit Service 20376f
	cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(commit)));
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 1));
Packit Service 20376f
Packit Service 20376f
	cl_assert_equal_i(1, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(other)));
Packit Service 20376f
	cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(other), git_commit_id(commit)));
Packit Service 20376f
Packit Service 20376f
	git_commit_free(other);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 3));
Packit Service 20376f
Packit Service 20376f
	cl_assert_equal_i(1, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(other)));
Packit Service 20376f
	cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(other), git_commit_id(commit)));
Packit Service 20376f
Packit Service 20376f
	git_commit_free(other);
Packit Service 20376f
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_graph_descendant_of__nopath(void)
Packit Service 20376f
{
Packit Service 20376f
	git_oid oid;
Packit Service 20376f
Packit Service 20376f
	git_oid_fromstr(&oid, "e90810b8df3e80c413d903f631643c716887138d");
Packit Service 20376f
	cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(commit), &oid));
Packit Service 20376f
}