| 1 | |||||||||||
| 2 | #use diagnostics; | ||||||||||
| 3 | 1 | ▶ | use NetAddr::IP::Lite; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | $| = 1; | |||||||||
| 6 | |||||||||||
| 7 | 10 | ▶ | sub ok() { | ||||||||
|
Subroutine
ok: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 10 | print 'ok ',$test++,"\n"; | |||||||||
| 9 | } | ||||||||||
| 10 | |||||||||||
| 11 | 1 | print "1..10\n"; | |||||||||
| 12 | |||||||||||
| 13 | 1 | $test = 1; | |||||||||
| 14 | |||||||||||
| 15 | ############## test new6 | ||||||||||
| 16 | |||||||||||
| 17 | 1 | my $exp = '0:0:0:0:0:0:0:3039/1'; | |||||||||
| 18 | |||||||||||
| 19 | 1 | my $ip = NetAddr::IP::Lite->new6(12345,1); | |||||||||
| 20 | 1 | my $got = $ip->cidr(); | |||||||||
| 21 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | unless $got eq $exp; | ||||||||||
| 23 | 1 | &ok; | |||||||||
| 24 | |||||||||||
| 25 | 1 | $ip = NetAddr::IP::Lite->new6('12345',1); | |||||||||
| 26 | 1 | $got = $ip->cidr(); | |||||||||
| 27 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | unless $got eq $exp; | ||||||||||
| 29 | 1 | &ok; | |||||||||
| 30 | |||||||||||
| 31 | 1 | $ip = NetAddr::IP::Lite->new6('12345/1'); | |||||||||
| 32 | 1 | $got = $ip->cidr(); | |||||||||
| 33 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | unless $got eq $exp; | ||||||||||
| 35 | 1 | &ok; | |||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | # 2^127 170141183460469231731687303715884105728 | ||||||||||
| 39 | |||||||||||
| 40 | 1 | $exp = '8000:0:0:0:0:0:0:0/1'; | |||||||||
| 41 | |||||||||||
| 42 | 1 | $ip = NetAddr::IP::Lite->new6('170141183460469231731687303715884105728/1'); | |||||||||
| 43 | 1 | $got = $ip->cidr(); | |||||||||
| 44 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | unless $got eq $exp; | ||||||||||
| 46 | 1 | &ok; | |||||||||
| 47 | |||||||||||
| 48 | # 2^128 340282366920938463463374607431768211456 | ||||||||||
| 49 | # minus one | ||||||||||
| 50 | |||||||||||
| 51 | 1 | $exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF/1'; | |||||||||
| 52 | |||||||||||
| 53 | 1 | $ip = NetAddr::IP::Lite->new6('340282366920938463463374607431768211455/1'); | |||||||||
| 54 | 1 | $got = $ip->cidr(); | |||||||||
| 55 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | unless $got eq $exp; | ||||||||||
| 57 | 1 | &ok; | |||||||||
| 58 | |||||||||||
| 59 | ############# test new | ||||||||||
| 60 | |||||||||||
| 61 | 1 | $exp = '0.0.48.57/1'; | |||||||||
| 62 | |||||||||||
| 63 | 1 | $ip = NetAddr::IP::Lite->new(12345,1); | |||||||||
| 64 | 1 | $got = $ip->cidr(); | |||||||||
| 65 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | unless $got eq $exp; | ||||||||||
| 67 | 1 | &ok; | |||||||||
| 68 | |||||||||||
| 69 | 1 | $ip = NetAddr::IP::Lite->new('12345',1); | |||||||||
| 70 | 1 | $got = $ip->cidr(); | |||||||||
| 71 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | unless $got eq $exp; | ||||||||||
| 73 | 1 | &ok; | |||||||||
| 74 | |||||||||||
| 75 | 1 | $ip = NetAddr::IP::Lite->new('12345/1'); | |||||||||
| 76 | 1 | $got = $ip->cidr(); | |||||||||
| 77 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | unless $got eq $exp; | ||||||||||
| 79 | 1 | &ok; | |||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | # 2^127 170141183460469231731687303715884105728 | ||||||||||
| 83 | |||||||||||
| 84 | 1 | $exp = '8000:0:0:0:0:0:0:0/1'; | |||||||||
| 85 | |||||||||||
| 86 | 1 | $ip = NetAddr::IP::Lite->new('170141183460469231731687303715884105728/1'); | |||||||||
| 87 | 1 | $got = $ip->cidr(); | |||||||||
| 88 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | unless $got eq $exp; | ||||||||||
| 90 | 1 | &ok; | |||||||||
| 91 | |||||||||||
| 92 | # 2^128 340282366920938463463374607431768211456 | ||||||||||
| 93 | # minus one | ||||||||||
| 94 | |||||||||||
| 95 | 1 | $exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF/1'; | |||||||||
| 96 | |||||||||||
| 97 | 1 | $ip = NetAddr::IP::Lite->new('340282366920938463463374607431768211455/1'); | |||||||||
| 98 | 1 | $got = $ip->cidr(); | |||||||||
| 99 | 1 | ▶ | print "got: $got\nexp: $exp\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | unless $got eq $exp; | ||||||||||
| 101 | 1 | &ok; | |||||||||
| 102 | |||||||||||