From d83ffb41c7f5d42bfb43a19e38ab3d1331f0d86e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 2 Feb 2022 11:50:53 -0500 Subject: tests: Add tests for syntactically invalid globs --- tests.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests.sh') diff --git a/tests.sh b/tests.sh index 0990110..940187e 100755 --- a/tests.sh +++ b/tests.sh @@ -233,6 +233,10 @@ posix_tests=( test_name_root_depth test_name_trailing_slash test_name_star_star + test_name_character_class + test_name_bracket + test_name_backslash + test_name_double_backslash test_newer test_newer_link @@ -993,6 +997,7 @@ function make_weirdnames() { touchp "$1/.../h" touchp "$1/\\/i" touchp "$1/ /j" + touchp "$1/[/k" } make_weirdnames "$TMP/weirdnames" @@ -1301,6 +1306,25 @@ function test_name_star_star() { bfs_diff basic -name '**f**' } +function test_name_character_class() { + bfs_diff basic -name '[e-g][!a-n][!p-z]' +} + +function test_name_bracket() { + # An unclosed [ should be matched literally + bfs_diff weirdnames -name '[' +} + +function test_name_backslash() { + # An unescaped \ doesn't match + bfs_diff weirdnames -name '\' +} + +function test_name_double_backslash() { + # An escaped \\ matches + bfs_diff weirdnames -name '\\' +} + function test_path() { bfs_diff basic -path 'basic/*f*' } -- cgit v1.2.3