Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-09-13 20:52:19 +0300
committerEdward Thomson <ethomson@microsoft.com>2015-09-13 20:52:23 +0300
commit2cde210d47f94962443cc090896cc1d5ef88452f (patch)
tree83f518f89b0d2f5c5dcc9c33a2c7f319bae2184a /tests/core
parent9562ebcd6b26e321f638a2a9795e2c1b493e033e (diff)
diriter: test we can iterate root
Ensure that we can iterate the filesystem root and that paths come back well-formed, not with an additional '/'. (eg, when iterating `c:/`, expect that we do not get some path like `c://autoexec.bat`).
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/dirent.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/core/dirent.c b/tests/core/dirent.c
index d95e44196..2bd60269d 100644
--- a/tests/core/dirent.c
+++ b/tests/core/dirent.c
@@ -275,3 +275,32 @@ void test_core_dirent__diriter_with_fullname(void)
check_counts(&sub);
}
+
+void test_core_dirent__diriter_at_directory_root(void)
+{
+ git_path_diriter diriter = GIT_PATH_DIRITER_INIT;
+ const char *sandbox_path, *path;
+ char *root_path;
+ size_t path_len;
+ int root_offset, error;
+
+ sandbox_path = clar_sandbox_path();
+ cl_assert((root_offset = git_path_root(sandbox_path)) >= 0);
+
+ cl_assert(root_path = git__calloc(1, root_offset + 2));
+ strncpy(root_path, sandbox_path, root_offset + 1);
+
+ cl_git_pass(git_path_diriter_init(&diriter, root_path, 0));
+
+ while ((error = git_path_diriter_next(&diriter)) == 0) {
+ cl_git_pass(git_path_diriter_fullpath(&path, &path_len, &diriter));
+
+ cl_assert(path_len > (size_t)(root_offset + 1));
+ cl_assert(path[root_offset+1] != '/');
+ }
+
+ cl_assert_equal_i(error, GIT_ITEROVER);
+
+ git_path_diriter_free(&diriter);
+ git__free(root_path);
+}