File: v6-num.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 (53 lines) | stat: -rw-r--r-- 1,604 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
use NetAddr::IP::Lite;

my $nets = {
    'F0::'	=> [ 128, '1' ],
    'F1::'	=> [ 127, '2' ],
    'F2::'	=> [ 126, '2' ],
    'F3::'	=> [ 125, '6' ],
    'F4::'	=> [ 124, '14' ],
    'F5::'	=> [ 123, '30' ],
    'F6::'	=> [ 122, '62' ],
    'F7::'	=> [ 100, '268435454' ],
    'F8::'	=> [ 99, '536870910' ],
    'F9::'	=> [ 98, '1073741822' ],
    'FA::'	=> [ 97, '2147483646' ],
    'FB::'	=> [ 96, '4294967294' ],
    'FC::'	=> [ 95, '8589934590' ],
    'FD::'	=> [ 94, '17179869182' ],
    'FE::'	=> [ 93, '34359738366' ],
    'FF::'	=> [ 92, '68719476734' ],
    'F10::'	=> [ 64, '18446744073709551614' ],
    'F20::'	=> [ 32, '79228162514264337593543950334' ],
    'F30::'	=> [ 16, '5192296858534827628530496329220094' ],
    'F40::'	=> [ 8, '1329227995784915872903807060280344574' ],
    'F50::'	=> [ 4, '21267647932558653966460912964485513214' ],
    'F60::'	=> [ 2, '85070591730234615865843651857942052862' ],
    'F70::'	=> [ 1, '170141183460469231731687303715884105726' ],
    'F80::'	=> [ 0, '340282366920938463463374607431768211454' ],
    '0.0.0.1'	=> [ 31, '2' ],
    '0.0.0.2'	=> [ 30, '2' ],
    '0.0.0.3'	=> [ 2, '1073741822' ],
    '0.0.0.4'	=> [ 1, '2147483646' ],
    '0.0.0.5'	=> [ 0, '4294967294' ],
    '0.0.0.6'	=> [ 32, '1' ],
};

$| = 1;

$test = keys %$nets;
print "1..", $test, "\n";

$test = 1;
sub tst {
  foreach my $a (sort keys %$nets) {
    my $nc = $nets->{$a}->[1];	# net count
    my $ip = new NetAddr::IP::Lite($a, $nets->{$a}->[0]);
    print "/$nets->{$a}->[0] got: $_, exp: $nc\nnot "
	unless ($_ = $ip->num) eq $nc;
    print "ok ", $test++, "\n";
  }
}

tst();