3 # Copyright (c) 2008 David Reiss
6 test_description
='Test various path utilities'
11 test_expect_success
"normalize absolute" \
12 "test \$(test-path-utils normalize_absolute_path '$1') = '$2'"
16 test_expect_success
"longest ancestor" \
17 "test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'"
30 norm_abs
/dir
/sub
/..
/..
/
35 norm_abs
/dir
///.
/ /dir
36 norm_abs
/dir
//sub
/..
/dir
37 norm_abs
/dir
/sub
/..
/ /dir
38 norm_abs
//dir
/sub
/..
/.
/dir
39 norm_abs
/dir
/s
1/..
/s
2/ /dir
/s2
40 norm_abs
/d
1/s
1///s
2/..
//..
/s
3/ /d
1/s3
41 norm_abs
/d
1/s
1//..
/s
2/..
/..
/d2
/d2
42 norm_abs
/d
1/...
/d2
/d
1/...
/d2
43 norm_abs
/d
1/...
/.
/..
/d2
/d
1/d2
50 ancestor
/foo
::..
:: -1
54 ancestor
/foo
/foo
/ -1
56 ancestor
/foo
/bar
/ -1
57 ancestor
/foo
/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
/ 0
62 ancestor
/foo
/foo
:/:/bar
/ 0
63 ancestor
/foo
/:/bar
/:/foo
0
64 ancestor
/foo
/bar
"" -1
66 ancestor
/foo
/bar
/fo
-1
67 ancestor
/foo
/bar foo
-1
68 ancestor
/foo
/bar
/foo
4
69 ancestor
/foo
/bar
/foo
/ 4
70 ancestor
/foo
/bar
/foo
/ba
-1
71 ancestor
/foo
/bar
/:/fo
0
72 ancestor
/foo
/bar
/foo
:/foo
/ba
4
73 ancestor
/foo
/bar
/bar
-1
74 ancestor
/foo
/bar
/bar
/ -1
75 ancestor
/foo
/bar
/fo
: -1
76 ancestor
/foo
/bar
:/fo
-1
77 ancestor
/foo
/bar
/foo
:/bar
/ 4
78 ancestor
/foo
/bar
/:/foo
:/bar
/ 4
79 ancestor
/foo
/bar
/foo
:/:/bar
/ 4
80 ancestor
/foo
/bar
/:/bar
/:/fo
0
81 ancestor
/foo
/bar
/:/bar
/ 0
82 ancestor
/foo
/bar
:://foo
/.
4
83 ancestor
/foo
/bar
:://foo
/.
:: 4
84 ancestor
/foo
/bar
//foo
/.
/::/bar
4
85 ancestor
/foo
/bar
::/bar
-1