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