File: firstlast.t

package info (click to toggle)
libnetaddr-ip-perl 4.028%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,048 kB
  • ctags: 101
  • sloc: perl: 850; ansic: 90; pascal: 78; sh: 48; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (2)
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
39

#use diagnostics;
use NetAddr::IP::Lite;

$| = 1;

print "1..4\n";

my $test = 1;
sub ok() {
  print 'ok ',$test++,"\n";
}

my $ip4 = NetAddr::IP::Lite->new('1.2.3.11/29');
my $ip6 = NetAddr::IP::Lite->new('FF::8B/125');

my $exp = '1.2.3.9';
my $rv = $ip4->first->addr;
print "got: $rv, exp: $exp\nnot "
	unless $rv eq $exp;
&ok;

$exp = '1.2.3.14';
$rv = $ip4->last->addr;
print "got: $rv, exp: $exp\nnot "
	unless $rv eq $exp;
&ok;

$exp = 'FF:0:0:0:0:0:0:89';
$rv = $ip6->first->addr;
print "got: $rv, exp: $exp\nnot "
	unless $rv eq $exp;
&ok;

$exp = 'FF:0:0:0:0:0:0:8E';
$rv = $ip6->last->addr;
print "got: $rv, exp: $exp\nnot "
	unless $rv eq $exp;
&ok;