summaryrefslogtreecommitdiff
path: root/tests/repo
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-03-16 10:17:20 -0400
committerEdward Thomson <ethomson@github.com>2016-03-23 17:16:37 -0400
commit4c88198a85932b69f779b2078f22b0231a18857e (patch)
treeb6ebbeb4947f2d7e0774393f9dee282215a91838 /tests/repo
parent0e0589fcc383a0ca96d342896103e01d715df755 (diff)
downloadlibgit2-4c88198a85932b69f779b2078f22b0231a18857e.tar.gz
iterator: test that we're at the end of iteration
Ensure that we have hit the end of iteration; previously we tested that we saw all the values that we expected to see. We did not then ensure that we were at the end of the iteration (and that there were subsequently values in the iteration that we did *not* expect.)
Diffstat (limited to 'tests/repo')
-rw-r--r--tests/repo/iterator.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/repo/iterator.c b/tests/repo/iterator.c
index ea2b37d10..e668caf44 100644
--- a/tests/repo/iterator.c
+++ b/tests/repo/iterator.c
@@ -16,6 +16,17 @@ void test_repo_iterator__cleanup(void)
g_repo = NULL;
}
+static void assert_at_end(git_iterator *i, bool verbose)
+{
+ const git_index_entry *end;
+ int error = git_iterator_advance(&end, i);
+
+ if (verbose && error != GIT_ITEROVER)
+ fprintf(stderr, "Expected end of iterator, got '%s'\n", end->path);
+
+ cl_git_fail_with(GIT_ITEROVER, error);
+}
+
static void expect_iterator_items(
git_iterator *i,
int expected_flat,
@@ -57,6 +68,7 @@ static void expect_iterator_items(
break;
}
+ assert_at_end(i, v);
cl_assert_equal_i(expected_flat, count);
cl_git_pass(git_iterator_reset(i));
@@ -103,6 +115,7 @@ static void expect_iterator_items(
break;
}
+ assert_at_end(i, v);
cl_assert_equal_i(expected_total, count);
}