File: v4-old-first.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 (30 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (5)
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
use NetAddr::IP::Lite qw(:old_nth);

my $nets = {
    '10.0.0.16'		=> [ 24, '10.0.0.1', '10.0.0.254', '10.0.0.10'],
    '10.0.0.5'		=> [ 30, '10.0.0.5', '10.0.0.6', 'undef' ],
    '10.128.0.1'	=> [ 8, '10.0.0.1', '10.255.255.254', '10.0.0.10'],
    '10.128.0.1'	=> [ 24, '10.128.0.1', '10.128.0.254', '10.128.0.10'],
};

$| = 1;
print "1..", (3 * scalar keys %$nets), "\n";

my $count = 1;

for my $a (keys %$nets) {
    my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0];
    print '', (($ip->first->addr	ne $nets->{$a}->[1] ?
	    'not ' : ''),
	   "ok ", $count++, "\n");
    print '', (($ip->last->addr		ne $nets->{$a}->[2] ?
	    'not ' : ''),
	   "ok ", $count++, "\n");

    my $new = $ip->nth(10);
    print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ?
	    'not ' : ''),
	   "ok ", $count++, "\n");
}