Commit | Line | Data |
bb27e7b6 |
1 | #!perl -w |
2 | |
3 | # tests for Win32::GetLongPathName() |
4 | |
5 | $^O =~ /^MSWin/ or print("1..0 # not win32\n" ), exit; |
6 | |
7 | my @paths = qw( |
8 | / |
9 | // |
10 | . |
11 | .. |
12 | c: |
13 | c:/ |
14 | c:./ |
15 | c:/. |
16 | c:/.. |
17 | c:./.. |
18 | //./ |
19 | //. |
20 | //.. |
21 | //./.. |
22 | ); |
23 | push @paths, map { my $x = $_; $x =~ s,/,\\,g; $x } @paths; |
24 | push @paths, qw( |
25 | ../\ |
26 | c:.\\../\ |
27 | c:/\..// |
28 | c://.\/./\ |
29 | \\.\\../\ |
30 | //\..// |
31 | //.\/./\ |
32 | ); |
33 | |
34 | my $drive = $ENV{SystemDrive}; |
35 | if ($drive) { |
36 | for (@paths) { |
37 | s/^c:/$drive/; |
38 | } |
39 | push @paths, $ENV{SystemRoot} if $ENV{SystemRoot}; |
40 | } |
41 | my %expect; |
42 | @expect{@paths} = map { my $x = $_; $x =~ s,(.[/\\])[/\\]+,$1,g; $x } @paths; |
43 | |
44 | print "1.." . @paths . "\n"; |
45 | my $i = 1; |
46 | for (@paths) { |
47 | my $got = Win32::GetLongPathName($_); |
48 | print "# '$_' => expect '$expect{$_}' => got '$got'\n"; |
49 | print "not " unless $expect{$_} eq $got; |
50 | print "ok $i\n"; |
51 | ++$i; |
52 | } |