iterator test: handle case (in)sensitivity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
diff --git a/tests/repo/iterator.c b/tests/repo/iterator.c
index 619e118..9c4cc9e 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);