summaryrefslogtreecommitdiff
path: root/tests-clay
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2011-12-29 10:37:28 +0100
committerClemens Buchacher <drizzd@aon.at>2011-12-30 20:14:05 +0100
commit0fb3fba123d8fbd99a9e1f9f47c192c704daee24 (patch)
treeb3f7858412941354e33fcdc12b5ee49a834360ff /tests-clay
parent1f783edf1746cb0254b6e28299dbe106bf8bbe69 (diff)
downloadlibgit2-0fb3fba123d8fbd99a9e1f9f47c192c704daee24.tar.gz
add diff-index tests
Diffstat (limited to 'tests-clay')
-rw-r--r--tests-clay/object/tree/diff.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests-clay/object/tree/diff.c b/tests-clay/object/tree/diff.c
index d2d5f754b..b2c7f6913 100644
--- a/tests-clay/object/tree/diff.c
+++ b/tests-clay/object/tree/diff.c
@@ -3,6 +3,7 @@
#include "repository.h"
static git_repository *repo;
+static git_index *theindex;
static git_tree *atree, *btree;
static git_oid aoid, boid;
@@ -26,9 +27,18 @@ static int diff_cb(const git_tree_diff_data *diff, void *data)
return GIT_SUCCESS;
}
+static void test_diff(git_tree *a, git_tree *b, git_tree_diff_cb cb, void *data)
+{
+ cl_must_pass(git_tree_diff(a, b, cb, data));
+
+ cl_git_pass(git_index_read_tree(theindex, b));
+ cl_git_pass(git_tree_diff_index_recursive(a, theindex, cb, data));
+}
+
void test_object_tree_diff__initialize(void)
{
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+ cl_git_pass(git_repository_index(&theindex, repo));
}
void test_object_tree_diff__cleanup(void)
@@ -57,7 +67,7 @@ void test_object_tree_diff__addition(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_cb, &expect));
+ test_diff(atree, btree, diff_cb, &expect);
}
void test_object_tree_diff__deletion(void)
@@ -78,7 +88,7 @@ void test_object_tree_diff__deletion(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_cb, &expect));
+ test_diff(atree, btree, diff_cb, &expect);
}
void test_object_tree_diff__modification(void)
@@ -100,7 +110,7 @@ void test_object_tree_diff__modification(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_cb, &expect));
+ test_diff(atree, btree, diff_cb, &expect);
}
struct diff_more_data {
@@ -153,5 +163,5 @@ void test_object_tree_diff__more(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_more_cb, &more_data));
+ test_diff(atree, btree, diff_more_cb, &more_data);
}