summaryrefslogtreecommitdiff
path: root/tests-clar/diff/iterator.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-01-08 15:56:11 -0800
committerRussell Belfer <rb@github.com>2013-01-15 09:51:34 -0800
commita49340c3e5de90ca551b46ea79573c428e3836b0 (patch)
treebb6a7a9a56b5d5c6c136d9e44fe342c211b022ea /tests-clar/diff/iterator.c
parent134d8c918c3430b19b75f45b1e490ce2aae526ff (diff)
downloadlibgit2-a49340c3e5de90ca551b46ea79573c428e3836b0.tar.gz
Test for ignore_case ranges on workdir iterator
This adds a test that confirms that the working directory iterator can actually correctly process ranges of files case insensitively with proper sorting and proper boundaries.
Diffstat (limited to 'tests-clar/diff/iterator.c')
-rw-r--r--tests-clar/diff/iterator.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests-clar/diff/iterator.c b/tests-clar/diff/iterator.c
index 6fc5730bc..846145abb 100644
--- a/tests-clar/diff/iterator.c
+++ b/tests-clar/diff/iterator.c
@@ -755,3 +755,52 @@ void test_diff_iterator__workdir_builtin_ignores(void)
git_iterator_free(i);
}
+
+static void check_first_through_third_range(
+ git_repository *repo, const char *start, const char *end)
+{
+ git_iterator *i;
+ const git_index_entry *entry;
+ int idx;
+ static const char *expected[] = {
+ "FIRST", "second", "THIRD", NULL
+ };
+
+ cl_git_pass(git_iterator_for_workdir_range(
+ &i, repo, GIT_IGNORE_CASE, start, end));
+ cl_git_pass(git_iterator_current(i, &entry));
+
+ for (idx = 0; entry != NULL; ++idx) {
+ cl_assert_equal_s(expected[idx], entry->path);
+
+ if (S_ISDIR(entry->mode))
+ cl_git_pass(git_iterator_advance_into_directory(i, &entry));
+ else
+ cl_git_pass(git_iterator_advance(i, &entry));
+ }
+
+ cl_assert(expected[idx] == NULL);
+
+ git_iterator_free(i);
+}
+
+void test_diff_iterator__workdir_handles_icase_range(void)
+{
+ git_repository *repo;
+
+ repo = cl_git_sandbox_init("empty_standard_repo");
+ cl_git_remove_placeholders(git_repository_path(repo), "dummy-marker.txt");
+
+ cl_git_mkfile("empty_standard_repo/before", "whatever\n");
+ cl_git_mkfile("empty_standard_repo/FIRST", "whatever\n");
+ cl_git_mkfile("empty_standard_repo/second", "whatever\n");
+ cl_git_mkfile("empty_standard_repo/THIRD", "whatever\n");
+ cl_git_mkfile("empty_standard_repo/zafter", "whatever\n");
+ cl_git_mkfile("empty_standard_repo/Zlast", "whatever\n");
+
+ check_first_through_third_range(repo, "first", "third");
+ check_first_through_third_range(repo, "FIRST", "THIRD");
+ check_first_through_third_range(repo, "first", "THIRD");
+ check_first_through_third_range(repo, "FIRST", "third");
+ check_first_through_third_range(repo, "FirSt", "tHiRd");
+}