summaryrefslogtreecommitdiff
path: root/tests/graph
diff options
context:
space:
mode:
authorArthur Schreiber <schreiber.arthur@googlemail.com>2014-01-28 19:39:14 +0100
committerArthur Schreiber <schreiber.arthur@googlemail.com>2014-01-28 19:39:14 +0100
commite7c16943f4551830a148995640f87bec2fe08e8f (patch)
treee309913211b29ac99fd0c8a129bdc8f8bcc6dd6b /tests/graph
parenta1a9d0bd484edb26c579820190d8f5fda24276ef (diff)
downloadlibgit2-e7c16943f4551830a148995640f87bec2fe08e8f.tar.gz
Add `git_graph_descendant_of`.
Diffstat (limited to 'tests/graph')
-rw-r--r--tests/graph/descendant_of.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/graph/descendant_of.c b/tests/graph/descendant_of.c
new file mode 100644
index 000000000..ffdd0cfc8
--- /dev/null
+++ b/tests/graph/descendant_of.c
@@ -0,0 +1,47 @@
+#include "clar_libgit2.h"
+
+static git_repository *_repo;
+static git_commit *commit;
+
+void test_graph_descendant_of__initialize(void)
+{
+ git_oid oid;
+
+ cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git")));
+
+ git_oid_fromstr(&oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+ cl_git_pass(git_commit_lookup(&commit, _repo, &oid));
+}
+
+void test_graph_descendant_of__cleanup(void)
+{
+ git_commit_free(commit);
+ commit = NULL;
+
+ git_repository_free(_repo);
+ _repo = NULL;
+}
+
+void test_graph_descendant_of__returns_correct_result(void)
+{
+ git_commit *other;
+
+ cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(commit)));
+
+
+ cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 1));
+
+ cl_assert_equal_i(1, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(other)));
+ cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(other), git_commit_id(commit)));
+
+ git_commit_free(other);
+
+
+ cl_git_pass(git_commit_nth_gen_ancestor(&other, commit, 3));
+
+ cl_assert_equal_i(1, git_graph_descendant_of(_repo, git_commit_id(commit), git_commit_id(other)));
+ cl_assert_equal_i(0, git_graph_descendant_of(_repo, git_commit_id(other), git_commit_id(commit)));
+
+ git_commit_free(other);
+
+}