summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLeo Yang <lyang@topologyinc.com>2015-08-17 15:02:02 -0400
committerLeo Yang <lyang@topologyinc.com>2015-09-04 12:24:36 -0400
commitc097f7173daced0f86fd816a72ad5fc0f636484a (patch)
tree2934468800976cc954f7042f5f7cc89b4ce34921 /tests
parent1cef6b9f190587a78c65bd3168879be3eb37e0fb (diff)
downloadlibgit2-c097f7173daced0f86fd816a72ad5fc0f636484a.tar.gz
New API: git_index_find_prefix
Find the first index entry matching a prefix.
Diffstat (limited to 'tests')
-rw-r--r--tests/index/tests.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/index/tests.c b/tests/index/tests.c
index e1ff12ad0..60c212681 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -155,6 +155,27 @@ void test_index_tests__find_in_empty(void)
git_index_free(index);
}
+void test_index_tests__find_prefix(void)
+{
+ git_index *index;
+ const git_index_entry *entry;
+ size_t pos;
+
+ cl_git_pass(git_index_open(&index, TEST_INDEX_PATH));
+
+ cl_git_pass(git_index_find_prefix(&pos, index, "src"));
+ entry = git_index_get_byindex(index, pos);
+ cl_assert(git__strcmp(entry->path, "src/block-sha1/sha1.c") == 0);
+
+ cl_git_pass(git_index_find_prefix(&pos, index, "src/co"));
+ entry = git_index_get_byindex(index, pos);
+ cl_assert(git__strcmp(entry->path, "src/commit.c") == 0);
+
+ cl_assert(GIT_ENOTFOUND == git_index_find_prefix(NULL, index, "blah"));
+
+ git_index_free(index);
+}
+
void test_index_tests__write(void)
{
git_index *index;