summaryrefslogtreecommitdiff
path: root/tests/repo
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-08-31 12:12:21 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-08-31 12:16:16 -0400
commit03210cfa00d9fe4cd4cc236253b0d590c0d994cc (patch)
tree597a68b26e417d041d5394f92379d0ed4773973d /tests/repo
parent4d19bced3f8156b4255997b553fed99746c2a785 (diff)
downloadlibgit2-03210cfa00d9fe4cd4cc236253b0d590c0d994cc.tar.gz
iterator test: handle case (in)sensitivity
Diffstat (limited to 'tests/repo')
-rw-r--r--tests/repo/iterator.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/repo/iterator.c b/tests/repo/iterator.c
index 619e11842..9c4cc9ea4 100644
--- a/tests/repo/iterator.c
+++ b/tests/repo/iterator.c
@@ -1099,6 +1099,7 @@ void test_repo_iterator__indexfilelist(void)
g_repo = cl_git_sandbox_init("icase");
cl_git_pass(git_repository_index(&index, g_repo));
+
/* In this test we DO NOT force a case setting on the index. */
default_icase = ((git_index_caps(index) & GIT_INDEXCAP_IGNORE_CASE) != 0);
@@ -1139,6 +1140,7 @@ void test_repo_iterator__indexfilelist_2(void)
git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
git_index *index;
git_vector filelist = GIT_VECTOR_INIT;
+ int default_icase, expect;
g_repo = cl_git_sandbox_init("icase");
@@ -1149,16 +1151,23 @@ void test_repo_iterator__indexfilelist_2(void)
cl_git_pass(git_vector_insert(&filelist, "c"));
cl_git_pass(git_vector_insert(&filelist, "D"));
cl_git_pass(git_vector_insert(&filelist, "e"));
+ cl_git_pass(git_vector_insert(&filelist, "k/1"));
cl_git_pass(git_vector_insert(&filelist, "k/a"));
+ /* In this test we DO NOT force a case setting on the index. */
+ default_icase = ((git_index_caps(index) & GIT_INDEXCAP_IGNORE_CASE) != 0);
+
i_opts.pathlist.strings = (char **)filelist.contents;
i_opts.pathlist.count = filelist.length;
i_opts.start = "b";
i_opts.end = "k/D";
+ /* (c D e k/1 k/a ==> 5) vs (c e k/1 ==> 3) */
+ expect = default_icase ? 5 : 3;
+
cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
- expect_iterator_items(i, 4, NULL, 4, NULL);
+ expect_iterator_items(i, expect, NULL, expect, NULL);
git_iterator_free(i);
git_index_free(index);
@@ -1171,6 +1180,7 @@ void test_repo_iterator__indexfilelist_3(void)
git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
git_index *index;
git_vector filelist = GIT_VECTOR_INIT;
+ int default_icase, expect;
g_repo = cl_git_sandbox_init("icase");
@@ -1186,14 +1196,20 @@ void test_repo_iterator__indexfilelist_3(void)
cl_git_pass(git_vector_insert(&filelist, "k.b"));
cl_git_pass(git_vector_insert(&filelist, "kZZZZZZZ"));
+ /* In this test we DO NOT force a case setting on the index. */
+ default_icase = ((git_index_caps(index) & GIT_INDEXCAP_IGNORE_CASE) != 0);
+
i_opts.pathlist.strings = (char **)filelist.contents;
i_opts.pathlist.count = filelist.length;
i_opts.start = "b";
i_opts.end = "k/D";
+ /* (c D e k/1 k/a k/B k/c k/D) vs (c e k/1 k/B k/D) */
+ expect = default_icase ? 8 : 5;
+
cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
- expect_iterator_items(i, 8, NULL, 8, NULL);
+ expect_iterator_items(i, expect, NULL, expect, NULL);
git_iterator_free(i);
git_index_free(index);
@@ -1206,6 +1222,7 @@ void test_repo_iterator__indexfilelist_4(void)
git_iterator_options i_opts = GIT_ITERATOR_OPTIONS_INIT;
git_index *index;
git_vector filelist = GIT_VECTOR_INIT;
+ int default_icase, expect;
g_repo = cl_git_sandbox_init("icase");
@@ -1221,14 +1238,20 @@ void test_repo_iterator__indexfilelist_4(void)
cl_git_pass(git_vector_insert(&filelist, "k.b"));
cl_git_pass(git_vector_insert(&filelist, "kZZZZZZZ"));
+ /* In this test we DO NOT force a case setting on the index. */
+ default_icase = ((git_index_caps(index) & GIT_INDEXCAP_IGNORE_CASE) != 0);
+
i_opts.pathlist.strings = (char **)filelist.contents;
i_opts.pathlist.count = filelist.length;
i_opts.start = "b";
i_opts.end = "k/D";
+ /* (c D e k/1 k/a k/B k/c k/D) vs (c e k/1 k/B k/D) */
+ expect = default_icase ? 8 : 5;
+
cl_git_pass(git_iterator_for_index(&i, index, &i_opts));
- expect_iterator_items(i, 8, NULL, 8, NULL);
+ expect_iterator_items(i, expect, NULL, expect, NULL);
git_iterator_free(i);
git_index_free(index);