diff options
author | Vicent Martà <vicent@github.com> | 2013-06-03 20:28:58 +0400 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-06-03 20:28:58 +0400 |
commit | 947fad4f7f7fbbc6d624570e9186326d3beb8cce (patch) | |
tree | 6a52a0a06d219abcffa62046054d54c6114a0854 /tests-clar/refs | |
parent | 9d9fff3c3dbc207a8a2ee2114eab19086afecb6e (diff) | |
parent | efd5a4e16a55ff32ce0b300d3792e44aed4157f8 (diff) |
Merge pull request #1624 from libgit2/vmg/full-ref-iterator
Breaking RefDB changes
Diffstat (limited to 'tests-clar/refs')
-rw-r--r-- | tests-clar/refs/iterator.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/tests-clar/refs/iterator.c b/tests-clar/refs/iterator.c index d5555c657..7a966892b 100644 --- a/tests-clar/refs/iterator.c +++ b/tests-clar/refs/iterator.c @@ -38,40 +38,43 @@ static const char *refnames[] = { "refs/tags/wrapped_tag", }; +static int refcmp_cb(const void *a, const void *b) +{ + const git_reference *refa = (const git_reference *)a; + const git_reference *refb = (const git_reference *)b; + + return strcmp(refa->name, refb->name); +} + void test_refs_iterator__list(void) { git_reference_iterator *iter; git_vector output; - char *refname; + git_reference *ref; int error; size_t i; - cl_git_pass(git_vector_init(&output, 32, git__strcmp_cb)); + cl_git_pass(git_vector_init(&output, 32, &refcmp_cb)); cl_git_pass(git_reference_iterator_new(&iter, repo)); do { - const char *name; - error = git_reference_next(&name, iter); + error = git_reference_next(&ref, iter); cl_assert(error == 0 || error == GIT_ITEROVER); if (error != GIT_ITEROVER) { - char *dup = git__strdup(name); - cl_assert(dup != NULL); - cl_git_pass(git_vector_insert(&output, dup)); + cl_git_pass(git_vector_insert(&output, ref)); } } while (!error); + git_reference_iterator_free(iter); cl_assert_equal_i(output.length, ARRAY_SIZE(refnames)); git_vector_sort(&output); - git_vector_foreach(&output, i, refname) { - cl_assert_equal_s(refname, refnames[i]); - } - - git_reference_iterator_free(iter); - git_vector_foreach(&output, i, refname) { - git__free(refname); + git_vector_foreach(&output, i, ref) { + cl_assert_equal_s(ref->name, refnames[i]); + git_reference_free(ref); } + git_vector_free(&output); } @@ -79,14 +82,14 @@ void test_refs_iterator__empty(void) { git_reference_iterator *iter; git_odb *odb; - const char *name; + git_reference *ref; git_repository *empty; cl_git_pass(git_odb_new(&odb)); cl_git_pass(git_repository_wrap_odb(&empty, odb)); cl_git_pass(git_reference_iterator_new(&iter, empty)); - cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&name, iter)); + cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&ref, iter)); git_reference_iterator_free(iter); git_odb_free(odb); |