Commit 0ef0b71c by Edward Thomson

iterator: refactor index iterator

parent ba6f86eb
......@@ -108,3 +108,39 @@ void expect_iterator_items(
cl_assert_equal_i(expected_total, count);
}
void expect_advance_over(
git_iterator *i,
const char *expected_path,
git_iterator_status_t expected_status)
{
const git_index_entry *entry;
git_iterator_status_t status;
int error;
cl_git_pass(git_iterator_current(&entry, i));
cl_assert_equal_s(expected_path, entry->path);
error = git_iterator_advance_over(&entry, &status, i);
cl_assert(!error || error == GIT_ITEROVER);
cl_assert_equal_i(expected_status, status);
}
void expect_advance_into(
git_iterator *i,
const char *expected_path)
{
const git_index_entry *entry;
int error;
cl_git_pass(git_iterator_current(&entry, i));
cl_assert_equal_s(expected_path, entry->path);
if (S_ISDIR(entry->mode))
error = git_iterator_advance_into(&entry, i);
else
error = git_iterator_advance(&entry, i);
cl_assert(!error || error == GIT_ITEROVER);
}
......@@ -6,3 +6,11 @@ extern void expect_iterator_items(
int expected_total,
const char **expected_total_paths);
extern void expect_advance_over(
git_iterator *i,
const char *expected_path,
git_iterator_status_t expected_status);
void expect_advance_into(
git_iterator *i,
const char *expected_path);
......@@ -1243,23 +1243,6 @@ void test_iterator_workdir__bounded_submodules(void)
git_tree_free(head);
}
static void expect_advance_over(
git_iterator *i,
const char *expected_path,
git_iterator_status_t expected_status)
{
const git_index_entry *entry;
git_iterator_status_t status;
int error;
cl_git_pass(git_iterator_current(&entry, i));
cl_assert_equal_s(expected_path, entry->path);
error = git_iterator_advance_over(&entry, &status, i);
cl_assert(!error || error == GIT_ITEROVER);
cl_assert_equal_i(expected_status, status);
}
void test_iterator_workdir__advance_over(void)
{
git_iterator *i;
......@@ -1380,24 +1363,6 @@ void test_iterator_workdir__advance_over_with_pathlist(void)
git_vector_free(&pathlist);
}
static void expect_advance_into(
git_iterator *i,
const char *expected_path)
{
const git_index_entry *entry;
int error;
cl_git_pass(git_iterator_current(&entry, i));
cl_assert_equal_s(expected_path, entry->path);
if (S_ISDIR(entry->mode))
error = git_iterator_advance_into(&entry, i);
else
error = git_iterator_advance(&entry, i);
cl_assert(!error || error == GIT_ITEROVER);
}
void test_iterator_workdir__advance_into(void)
{
git_iterator *i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment