Commit | Line | Data |
0130bfd9 |
1 | use strict; |
2 | BEGIN { |
3 | eval "use Test::More"; |
4 | return unless $@; |
5 | print "1..0 # Skip: Test requires Test::More module\n"; |
6 | exit 0; |
7 | } |
8 | use Win32; |
9 | |
10 | my $tests = 14; |
11 | $tests += 2 if Win32::IsWinNT(); |
12 | |
13 | plan tests => $tests; |
14 | |
15 | # test Win32::DomainName() |
16 | if (Win32::IsWinNT()) { |
17 | my $domain = eval { Win32::DomainName() }; |
166cd87e |
18 | SKIP: { |
19 | skip 'The Workstation service has not been started', 2 if $^E == 2138; |
20 | is( $@, '', "Win32::DomainName()" ); |
21 | like( $domain, '/^[a-zA-Z0-9!@#$%^&()_\'{}.~-]+$/', " - checking returned domain" ); |
22 | } |
0130bfd9 |
23 | } |
24 | |
25 | # test Win32::GetArchName() |
26 | my $archname = eval { Win32::GetArchName() }; |
27 | is( $@, '', "Win32::GetArchName()" ); |
28 | cmp_ok( length($archname), '>=', 3, " - checking returned architecture name" ); |
29 | |
30 | # test Win32::GetChipName() |
31 | my $chipname = eval { Win32::GetChipName() }; |
32 | is( $@, '', "Win32::GetChipName()" ); |
33 | cmp_ok( length($chipname), '>=', 3, " - checking returned chip name" ); |
34 | |
35 | # test Win32::GetOSName() |
36 | # - scalar context |
37 | my $osname = eval { Win32::GetOSName() }; |
38 | is( $@, '', "Win32::GetOSName() in scalar context" ); |
39 | cmp_ok( length($osname), '>', 3, " - checking returned OS name" ); |
40 | |
41 | # - list context |
42 | my ($osname2, $desc) = eval { Win32::GetOSName() }; |
43 | is( $@, '', "Win32::GetOSName() in list context" ); |
166cd87e |
44 | cmp_ok( length($osname2), '>', 3, " - checking returned OS name" ); |
45 | ok( defined($desc), " - checking returned description" ); |
46 | is( $osname2, $osname, " - checking that OS name is the same in both calls" ); |
0130bfd9 |
47 | |
48 | # test Win32::LoginName() |
49 | my $login = eval { Win32::LoginName() }; |
50 | is( $@, '', "Win32::LoginName()" ); |
51 | cmp_ok( length($login), '>', 1, " - checking returned login name" ); |
52 | |
53 | # test Win32::NodeName() |
54 | my $nodename = eval { Win32::NodeName() }; |
55 | is( $@, '', "Win32::NodeName()" ); |
56 | cmp_ok( length($nodename), '>', 1, " - checking returned node name" ); |