summaryrefslogtreecommitdiff
path: root/tests/index
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-12 10:04:42 +0200
committerPatrick Steinhardt <ps@pks.im>2017-06-06 09:38:44 +0200
commit82368b1bad1eae400b9e1f8f0e7a452c1335d4db (patch)
tree9bdca94782fb1b14bc3e9dd937c97e3f7bace1ae /tests/index
parentfea0c81e95d5c22b758df6bedbd13321fa2ab195 (diff)
downloadlibgit2-82368b1bad1eae400b9e1f8f0e7a452c1335d4db.tar.gz
tests: index::version: add test to read index version v4
While we have a simple test to determine whether we can write an index of version 4, we never verified that we are able to read this kind of index (and in fact, we were not able to do so). Add a new repository which has an index of version 4. This repository is then read from a new test.
Diffstat (limited to 'tests/index')
-rw-r--r--tests/index/version.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/index/version.c b/tests/index/version.c
index 688a20f20..c3cb0cd40 100644
--- a/tests/index/version.c
+++ b/tests/index/version.c
@@ -9,6 +9,29 @@ void test_index_version__cleanup(void)
g_repo = NULL;
}
+void test_index_version__can_read_v4(void)
+{
+ const char *paths[] = {
+ "file.tx", "file.txt", "file.txz", "foo", "zzz",
+ };
+ git_index *index;
+ size_t i;
+
+ g_repo = cl_git_sandbox_init("indexv4");
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_assert_equal_sz(git_index_entrycount(index), 5);
+
+ for (i = 0; i < ARRAY_SIZE(paths); i++) {
+ const git_index_entry *entry =
+ git_index_get_bypath(index, paths[i], GIT_INDEX_STAGE_NORMAL);
+
+ cl_assert(entry != NULL);
+ }
+
+ git_index_free(index);
+}
+
void test_index_version__can_write_v4(void)
{
git_index *index;