File: firstlast.t

package info (click to toggle)
libnetaddr-ip-perl 4.079%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 1,580 kB
  • ctags: 251
  • sloc: perl: 1,417; cpp: 67; sh: 51; makefile: 9
file content (66 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download | duplicates (4)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

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

$| = 1;

print "1..8\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;

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

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

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

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

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