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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#!/usr/bin/perl
use Math::BigInt;
use NetAddr::IP::Util qw(
bcd2bin
ipv6_n2x
);
my $data = q|
got: '340282366920938963520000944000010176000'
# expected: '340282366920938463463374607431768211455'
# Failed test 'cafe:cafe::/64 Scalar numeric ok'
# at t/v6-numeric.t line 57.
# got: '269827015721314205120005577600083392000'
# expected: '269827015721314068804783158349174669312'
# Failed test 'cafe:cafe::/64 Array numeric ok for network'
# at t/v6-numeric.t line 58.
# got: '269827015721314205120005577600083392000'
# expected: '269827015721314068804783158349174669312'
# Failed test 'cafe:cafe::/64 Array numeric ok for mask'
# at t/v6-numeric.t line 59.
# got: '340282366920938963520000944000010176000'
# expected: '340282366920938463444927863358058659840'
# Failed test 'cafe:cafe::1/64 Scalar numeric ok'
# at t/v6-numeric.t line 57.
# got: '269827015721314205120005577600083392000'
# expected: '269827015721314068804783158349174669313'
# Failed test 'cafe:cafe::1/64 Array numeric ok for network'
# at t/v6-numeric.t line 58.
# got: '269827015721314205120005577600083392000'
# expected: '269827015721314068804783158349174669313'
# Failed test 'cafe:cafe::1/64 Array numeric ok for mask'
# at t/v6-numeric.t line 59.
# got: '340282366920938963520000944000010176000'
# expected: '340282366920938463444927863358058659840'
# Failed test 'dead:beef::/100 Scalar numeric ok'
# at t/v6-numeric.t line 57.
# got: '295990755014136299520006003200014752000'
# expected: '295990755014133383690938178081940045824'
# Failed test 'dead:beef::/100 Array numeric ok for network'
# at t/v6-numeric.t line 58.
# got: '295990755014136299520006003200014752000'
# expected: '295990755014133383690938178081940045824'
# Failed test 'dead:beef::/100 Array numeric ok for mask'
# at t/v6-numeric.t line 59.
# got: '340282366920938963520000944000010176000'
# expected: '340282366920938463463374607431499776000'
# Failed test 'dead:beef::1/100 Scalar numeric ok'
# at t/v6-numeric.t line 57.
# got: '295990755014136299520006003200014752000'
# expected: '295990755014133383690938178081940045825'
# Failed test 'dead:beef::1/100 Array numeric ok for network'
# at t/v6-numeric.t line 58.
# got: '295990755014136299520006003200014752000'
# expected: '295990755014133383690938178081940045825'
# Failed test 'dead:beef::1/100 Array numeric ok for mask'
# at t/v6-numeric.t line 59.
# got: '340282366920938963520000944000010176000'
# expected: '340282366920938463463374607431499776000'
|;
my @trial = split("\n",$data);
my @data;
foreach(@trial) {
if ($_ =~ /(?:got|expected)\:\s+\'(\d+)/) {
push @data,$1;
}
}
#for(my $i=0;$i <= $#data;$i +=2) {
# print $data[$i]," -\n";
# print $data[$i +1]," =\n";
# my $x = Math::BigInt->new($data[$i]);
# my $y = Math::BigInt->new($data[$i +1]);
# $x->bsub($y);
# print $x,"\n\n";
#}
for(my $i=0;$i <= $#data;$i +=2) {
my $x = ipv6_n2x(bcd2bin($data[$i]));
print $data[$i],"\t=> $x\n";
my $y = ipv6_n2x(bcd2bin($data[$i +1]));
print $data[$i +1],"\t=> $y\n";
}
|