Upgrade to Win32-0.32
[p5sagit/p5-mst-13.2.git] / ext / Win32 / t / Names.t
CommitLineData
0130bfd9 1use strict;
2BEGIN {
3 eval "use Test::More";
4 return unless $@;
5 print "1..0 # Skip: Test requires Test::More module\n";
6 exit 0;
7}
8use Win32;
9
10my $tests = 14;
11$tests += 2 if Win32::IsWinNT();
12
13plan tests => $tests;
14
15# test Win32::DomainName()
16if (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()
26my $archname = eval { Win32::GetArchName() };
27is( $@, '', "Win32::GetArchName()" );
28cmp_ok( length($archname), '>=', 3, " - checking returned architecture name" );
29
30# test Win32::GetChipName()
31my $chipname = eval { Win32::GetChipName() };
32is( $@, '', "Win32::GetChipName()" );
33cmp_ok( length($chipname), '>=', 3, " - checking returned chip name" );
34
35# test Win32::GetOSName()
36# - scalar context
37my $osname = eval { Win32::GetOSName() };
38is( $@, '', "Win32::GetOSName() in scalar context" );
39cmp_ok( length($osname), '>', 3, " - checking returned OS name" );
40
41# - list context
42my ($osname2, $desc) = eval { Win32::GetOSName() };
43is( $@, '', "Win32::GetOSName() in list context" );
166cd87e 44cmp_ok( length($osname2), '>', 3, " - checking returned OS name" );
45ok( defined($desc), " - checking returned description" );
46is( $osname2, $osname, " - checking that OS name is the same in both calls" );
0130bfd9 47
48# test Win32::LoginName()
49my $login = eval { Win32::LoginName() };
50is( $@, '', "Win32::LoginName()" );
51cmp_ok( length($login), '>', 1, " - checking returned login name" );
52
53# test Win32::NodeName()
54my $nodename = eval { Win32::NodeName() };
55is( $@, '', "Win32::NodeName()" );
56cmp_ok( length($nodename), '>', 1, " - checking returned node name" );