3 # Copyright (c) 2008 David Reiss
6 test_description
='Test various path utilities'
11 test_expect_success
"normalize absolute: $1 => $2" \
12 "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
16 test_expect_success
"longest ancestor: $1 $2 => $3" \
17 "test \"\$(test-path-utils longest_ancestor_length '$1' '$2')\" = '$3'"
26 norm_abs
/.
/..
++failed
++
27 norm_abs
/..
/.
++failed
++
28 norm_abs
/.
/..
/.
// ++failed
++
30 norm_abs
/dir
/sub
/..
/..
/
31 norm_abs
/dir
/sub
/..
/..
/..
++failed
++
36 norm_abs
/dir
///.
/ /dir
/
37 norm_abs
/dir
//sub
/..
/dir
/
38 norm_abs
/dir
/sub
/..
/ /dir
/
39 norm_abs
//dir
/sub
/..
/.
/dir
/
40 norm_abs
/dir
/s
1/..
/s
2/ /dir
/s
2/
41 norm_abs
/d
1/s
1///s
2/..
//..
/s
3/ /d
1/s
3/
42 norm_abs
/d
1/s
1//..
/s
2/..
/..
/d2
/d2
43 norm_abs
/d
1/...
/d2
/d
1/...
/d2
44 norm_abs
/d
1/...
/.
/..
/d2
/d
1/d2
51 ancestor
/foo
::..
:: -1
55 ancestor
/foo
/foo
/ -1
57 ancestor
/foo
/bar
/ -1
58 ancestor
/foo
/foo
/bar
-1
59 ancestor
/foo
/foo
:/bar
/ -1
60 ancestor
/foo
/foo
/:/bar
/ -1
61 ancestor
/foo
/foo
::/bar
/ -1
62 ancestor
/foo
/:/foo
:/bar
/ 0
63 ancestor
/foo
/foo
:/:/bar
/ 0
64 ancestor
/foo
/:/bar
/:/foo
0
65 ancestor
/foo
/bar
"" -1
67 ancestor
/foo
/bar
/fo
-1
68 ancestor
/foo
/bar foo
-1
69 ancestor
/foo
/bar
/foo
4
70 ancestor
/foo
/bar
/foo
/ 4
71 ancestor
/foo
/bar
/foo
/ba
-1
72 ancestor
/foo
/bar
/:/fo
0
73 ancestor
/foo
/bar
/foo
:/foo
/ba
4
74 ancestor
/foo
/bar
/bar
-1
75 ancestor
/foo
/bar
/bar
/ -1
76 ancestor
/foo
/bar
/fo
: -1
77 ancestor
/foo
/bar
:/fo
-1
78 ancestor
/foo
/bar
/foo
:/bar
/ 4
79 ancestor
/foo
/bar
/:/foo
:/bar
/ 4
80 ancestor
/foo
/bar
/foo
:/:/bar
/ 4
81 ancestor
/foo
/bar
/:/bar
/:/fo
0
82 ancestor
/foo
/bar
/:/bar
/ 0
83 ancestor
/foo
/bar
:://foo
/.
4
84 ancestor
/foo
/bar
:://foo
/.
:: 4
85 ancestor
/foo
/bar
//foo
/.
/::/bar
4
86 ancestor
/foo
/bar
::/bar
-1
88 test_expect_success
'strip_path_suffix' '
89 test c:/msysgit = $(test-path-utils strip_path_suffix \
90 c:/msysgit/libexec//git-core libexec/git-core)