summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-11-01 13:04:40 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-11-09 15:17:17 +0000
commitdd748dbede1a36f1e929461ecbfcde749eb685bb (patch)
tree60e695e05378a21db5218c81285a5c0e3b5de395 /tests
parentbef02d3e638ce8c95c9e63622b46d87a0f8ee2b2 (diff)
downloadlibgit2-dd748dbede1a36f1e929461ecbfcde749eb685bb.tar.gz
fs_path: make empty component validation optional
Diffstat (limited to 'tests')
-rw-r--r--tests/path/core.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/tests/path/core.c b/tests/path/core.c
index 6fa0450ca..ccb328b10 100644
--- a/tests/path/core.c
+++ b/tests/path/core.c
@@ -68,41 +68,58 @@ void test_path_core__isvalid_standard(void)
void test_path_core__isvalid_standard_str(void)
{
git_str str = GIT_STR_INIT_CONST("foo/bar//zap", 0);
+ unsigned int flags = GIT_FS_PATH_REJECT_EMPTY_COMPONENT;
str.size = 0;
- cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, 0));
+ cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, flags));
str.size = 3;
- cl_assert_equal_b(true, git_fs_path_is_valid_str(&str, 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid_str(&str, flags));
str.size = 4;
- cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, 0));
+ cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, flags));
str.size = 5;
- cl_assert_equal_b(true, git_fs_path_is_valid_str(&str, 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid_str(&str, flags));
str.size = 7;
- cl_assert_equal_b(true, git_fs_path_is_valid_str(&str, 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid_str(&str, flags));
str.size = 8;
- cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, 0));
+ cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, flags));
str.size = strlen(str.ptr);
- cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, 0));
+ cl_assert_equal_b(false, git_fs_path_is_valid_str(&str, flags));
}
void test_path_core__isvalid_empty_dir_component(void)
{
- cl_assert_equal_b(false, git_fs_path_is_valid("foo//bar", 0));
+ unsigned int flags = GIT_FS_PATH_REJECT_EMPTY_COMPONENT;
+
+ /* empty component */
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo//bar", 0));
+
+ /* leading slash */
+ cl_assert_equal_b(true, git_fs_path_is_valid("/", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("/foo", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("/foo/bar", 0));
+
+ /* trailing slash */
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/", 0));
+ cl_assert_equal_b(true, git_fs_path_is_valid("foo/bar/", 0));
+
+
+ /* empty component */
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo//bar", flags));
/* leading slash */
- cl_assert_equal_b(false, git_fs_path_is_valid("/", 0));
- cl_assert_equal_b(false, git_fs_path_is_valid("/foo", 0));
- cl_assert_equal_b(false, git_fs_path_is_valid("/foo/bar", 0));
+ cl_assert_equal_b(false, git_fs_path_is_valid("/", flags));
+ cl_assert_equal_b(false, git_fs_path_is_valid("/foo", flags));
+ cl_assert_equal_b(false, git_fs_path_is_valid("/foo/bar", flags));
/* trailing slash */
- cl_assert_equal_b(false, git_fs_path_is_valid("foo/", 0));
- cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar/", 0));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/", flags));
+ cl_assert_equal_b(false, git_fs_path_is_valid("foo/bar/", flags));
}
void test_path_core__isvalid_dot_and_dotdot(void)