Grafted root commit from savannah git master:
[gnu-stow.git] / t / join_paths.t
blob1fc6b245f9fc9d04e2784e1ecc890bc84b540c40
1 #!/usr/local/bin/perl
4 # Testing join_paths();
7 # load as a library
8 BEGIN { use lib qw(. ..); require "stow"; }
10 use Test::More tests => 13;
12 is(
13 join_paths('a/b/c', 'd/e/f'),
14 'a/b/c/d/e/f',
15 => 'simple'
18 is(
19 join_paths('/a/b/c', '/d/e/f'),
20 '/a/b/c/d/e/f',
21 => 'leading /'
24 is(
25 join_paths('/a/b/c/', '/d/e/f/'),
26 '/a/b/c/d/e/f',
27 => 'trailing /'
30 is(
31 join_paths('///a/b///c//', '/d///////e/f'),
32 '/a/b/c/d/e/f',
33 => 'mltiple /\'s'
36 is(
37 join_paths('', 'a/b/c'),
38 'a/b/c',
39 => 'first empty'
42 is(
43 join_paths('a/b/c', ''),
44 'a/b/c',
45 => 'second empty'
48 is(
49 join_paths('/', 'a/b/c'),
50 '/a/b/c',
51 => 'first is /'
54 is(
55 join_paths('a/b/c', '/'),
56 'a/b/c',
57 => 'second is /'
60 is(
61 join_paths('///a/b///c//', '/d///////e/f'),
62 '/a/b/c/d/e/f',
63 => 'multiple /\'s'
67 is(
68 join_paths('../a1/b1/../c1/', '/a2/../b2/e2'),
69 '../a1/c1/b2/e2',
70 => 'simple deref ".."'
73 is(
74 join_paths('../a1/b1/../c1/d1/e1', '../a2/../b2/c2/d2/../e2'),
75 '../a1/c1/d1/b2/c2/e2',
76 => 'complex deref ".."'
79 is(
80 join_paths('../a1/../../c1', 'a2/../../'),
81 '../..',
82 => 'too many ".."'
85 is(
86 join_paths('./a1', '../../a2'),
87 '../a2',
88 => 'drop any "./"'