xref: /openbsd/gnu/usr.bin/perl/cpan/Win32/t/Names.t (revision 274d7c50)
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() };
18    SKIP: {
19	skip('The Workstation service has not been started', 2) if (Win32::GetLastError() == 2138);
20	is( $@, '', "Win32::DomainName()" );
21	like( $domain, '/^[a-zA-Z0-9!@#$%^&()_\'{}.~-]+$/', "  - checking returned domain" );
22    }
23}
24
25# test Win32::GetArchName()
26$ENV{PROCESSOR_ARCHITECTURE} ||= "unknown";
27my $archname = eval { Win32::GetArchName() };
28is( $@, '', "Win32::GetArchName()" );
29cmp_ok( length($archname), '>=', 3, "  - checking returned architecture name" );
30
31# test Win32::GetChipName()
32my $chipname = eval { Win32::GetChipName() };
33is( $@, '', "Win32::GetChipName()" );
34cmp_ok( length($chipname), '>=', 3, "  - checking returned chip name" );
35
36# test Win32::GetOSName()
37#  - scalar context
38my $osname = eval { Win32::GetOSName() };
39is( $@, '', "Win32::GetOSName() in scalar context" );
40cmp_ok( length($osname), '>', 3, "  - checking returned OS name" );
41
42#  - list context
43my ($osname2, $desc) = eval { Win32::GetOSName() };
44is( $@, '', "Win32::GetOSName() in list context" );
45cmp_ok( length($osname2), '>', 3, "  - checking returned OS name" );
46ok( defined($desc), "  - checking returned description" );
47is( $osname2, $osname, "  - checking that OS name is the same in both calls" );
48
49# test Win32::LoginName()
50my $login = eval { Win32::LoginName() };
51is( $@, '', "Win32::LoginName()" );
52cmp_ok( length($login), '>', 0, "  - checking returned login name" );
53
54# test Win32::NodeName()
55my $nodename = eval { Win32::NodeName() };
56is( $@, '', "Win32::NodeName()" );
57cmp_ok( length($nodename), '>', 0, "  - checking returned node name" );
58