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() }; |
18 | is( $@, '', "Win32::DomainName()" ); |
19 | like( $domain, '/^[a-zA-Z0-9!@#$%^&()_\'{}.~-]+$/', " - checking returned domain" ); |
20 | } |
21 | |
22 | # test Win32::GetArchName() |
23 | my $archname = eval { Win32::GetArchName() }; |
24 | is( $@, '', "Win32::GetArchName()" ); |
25 | cmp_ok( length($archname), '>=', 3, " - checking returned architecture name" ); |
26 | |
27 | # test Win32::GetChipName() |
28 | my $chipname = eval { Win32::GetChipName() }; |
29 | is( $@, '', "Win32::GetChipName()" ); |
30 | cmp_ok( length($chipname), '>=', 3, " - checking returned chip name" ); |
31 | |
32 | # test Win32::GetOSName() |
33 | # - scalar context |
34 | my $osname = eval { Win32::GetOSName() }; |
35 | is( $@, '', "Win32::GetOSName() in scalar context" ); |
36 | cmp_ok( length($osname), '>', 3, " - checking returned OS name" ); |
37 | |
38 | # - list context |
39 | my ($osname2, $desc) = eval { Win32::GetOSName() }; |
40 | is( $@, '', "Win32::GetOSName() in list context" ); |
41 | cmp_ok( length($osname), '>', 3, " - checking returned OS name" ); |
42 | cmp_ok( length($desc ), '>', 3, " - checking returned description" ); |
43 | is( $osname2, $osname, " - checking that OS name is the same in both calls" ); |
44 | |
45 | # test Win32::LoginName() |
46 | my $login = eval { Win32::LoginName() }; |
47 | is( $@, '', "Win32::LoginName()" ); |
48 | cmp_ok( length($login), '>', 1, " - checking returned login name" ); |
49 | |
50 | # test Win32::NodeName() |
51 | my $nodename = eval { Win32::NodeName() }; |
52 | is( $@, '', "Win32::NodeName()" ); |
53 | cmp_ok( length($nodename), '>', 1, " - checking returned node name" ); |