summaryrefslogtreecommitdiff
path: root/lib/Net/protoent.t
blob: 0c3160157b35492b11e18ab92bd235a1a402f12e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!./perl

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
}

BEGIN {
    our $haspe;
    eval { my @n = getprotobyname "tcp" };
    $haspe = 1 unless $@ && $@ =~ /unimplemented|unsupported/i;
    unless ($haspe) { print "1..0 # Skip: no getprotobyname\n"; exit 0 }
    use Config;
    $haspe = 0 unless $Config{'i_netdb'} eq 'define';
    unless ($haspe) { print "1..0 # Skip: no netdb.h\n"; exit 0 }
}

BEGIN {
    our @protoent = getprotobyname "tcp"; # This is the function getprotobyname.
    unless (@protoent) { print "1..0 # Skip: no tcp protocol\n"; exit 0 }
}

print "1..3\n";

use Net::protoent;

print "ok 1\n";

my $protoent = getprotobyname "tcp"; # This is the OO getprotobyname.

print "not " unless $protoent->name   eq $protoent[0];
print "ok 2\n";

print "not " unless $protoent->proto  == $protoent[2];
print "ok 3\n";

# Testing pretty much anything else is unportable.