summaryrefslogtreecommitdiff
path: root/cpan/Win32/t/GetLongPathName.t
blob: 5019a2ba258dd24533d5e6570f1ca599f1e9a529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use strict;
use Test;
use Win32;

my @paths = qw(
    /
    //
    .
    ..
    c:
    c:/
    c:./
    c:/.
    c:/..
    c:./..
    //./
    //.
    //..
    //./..
);
push @paths, map { my $x = $_; $x =~ s,/,\\,g; $x } @paths;
push @paths, qw(
    ../\
    c:.\\../\
    c:/\..//
    c://.\/./\
    \\.\\../\
    //\..//
    //.\/./\
);

my $drive = $ENV{SYSTEMDRIVE};
if ($drive) {
    for (@paths) {
	s/^c:/$drive/;
    }
}
my %expect;
@expect{@paths} = map { my $x = $_;
                        $x =~ s,(.[/\\])[/\\]+,$1,g;
                        $x =~ s,^(\w):,\U$1:,;
                        $x } @paths;

plan tests => scalar(@paths);

my $i = 1;
for (@paths) {
    my $got = Win32::GetLongPathName($_);
    print "# '$_' => expect '$expect{$_}' => got '$got'\n";
    print "not " unless $expect{$_} eq $got;
    print "ok $i\n";
    ++$i;
}