Newer
Older
NetAddr-IP / Lite / bug2742981
@Michael Robinton Michael Robinton on 21 Oct 2014 3 KB Import of MIKER/NetAddr-IP-4.049 from CPAN.
  1. #!/usr/bin/perl
  2. use Math::BigInt;
  3. use NetAddr::IP::Util qw(
  4. bcd2bin
  5. ipv6_n2x
  6. );
  7.  
  8. my $data = q|
  9. got: '340282366920938963520000944000010176000'
  10. # expected: '340282366920938463463374607431768211455'
  11.  
  12. # Failed test 'cafe:cafe::/64 Scalar numeric ok'
  13. # at t/v6-numeric.t line 57.
  14. # got: '269827015721314205120005577600083392000'
  15. # expected: '269827015721314068804783158349174669312'
  16.  
  17. # Failed test 'cafe:cafe::/64 Array numeric ok for network'
  18. # at t/v6-numeric.t line 58.
  19. # got: '269827015721314205120005577600083392000'
  20. # expected: '269827015721314068804783158349174669312'
  21.  
  22. # Failed test 'cafe:cafe::/64 Array numeric ok for mask'
  23. # at t/v6-numeric.t line 59.
  24. # got: '340282366920938963520000944000010176000'
  25. # expected: '340282366920938463444927863358058659840'
  26.  
  27. # Failed test 'cafe:cafe::1/64 Scalar numeric ok'
  28. # at t/v6-numeric.t line 57.
  29. # got: '269827015721314205120005577600083392000'
  30. # expected: '269827015721314068804783158349174669313'
  31.  
  32. # Failed test 'cafe:cafe::1/64 Array numeric ok for network'
  33. # at t/v6-numeric.t line 58.
  34. # got: '269827015721314205120005577600083392000'
  35. # expected: '269827015721314068804783158349174669313'
  36.  
  37. # Failed test 'cafe:cafe::1/64 Array numeric ok for mask'
  38. # at t/v6-numeric.t line 59.
  39. # got: '340282366920938963520000944000010176000'
  40. # expected: '340282366920938463444927863358058659840'
  41.  
  42. # Failed test 'dead:beef::/100 Scalar numeric ok'
  43. # at t/v6-numeric.t line 57.
  44. # got: '295990755014136299520006003200014752000'
  45. # expected: '295990755014133383690938178081940045824'
  46.  
  47. # Failed test 'dead:beef::/100 Array numeric ok for network'
  48. # at t/v6-numeric.t line 58.
  49. # got: '295990755014136299520006003200014752000'
  50. # expected: '295990755014133383690938178081940045824'
  51.  
  52. # Failed test 'dead:beef::/100 Array numeric ok for mask'
  53. # at t/v6-numeric.t line 59.
  54. # got: '340282366920938963520000944000010176000'
  55. # expected: '340282366920938463463374607431499776000'
  56.  
  57. # Failed test 'dead:beef::1/100 Scalar numeric ok'
  58. # at t/v6-numeric.t line 57.
  59. # got: '295990755014136299520006003200014752000'
  60. # expected: '295990755014133383690938178081940045825'
  61.  
  62. # Failed test 'dead:beef::1/100 Array numeric ok for network'
  63. # at t/v6-numeric.t line 58.
  64. # got: '295990755014136299520006003200014752000'
  65. # expected: '295990755014133383690938178081940045825'
  66.  
  67. # Failed test 'dead:beef::1/100 Array numeric ok for mask'
  68. # at t/v6-numeric.t line 59.
  69. # got: '340282366920938963520000944000010176000'
  70. # expected: '340282366920938463463374607431499776000'
  71. |;
  72.  
  73. my @trial = split("\n",$data);
  74. my @data;
  75. foreach(@trial) {
  76. if ($_ =~ /(?:got|expected)\:\s+\'(\d+)/) {
  77. push @data,$1;
  78. }
  79. }
  80.  
  81. #for(my $i=0;$i <= $#data;$i +=2) {
  82. # print $data[$i]," -\n";
  83. # print $data[$i +1]," =\n";
  84. # my $x = Math::BigInt->new($data[$i]);
  85. # my $y = Math::BigInt->new($data[$i +1]);
  86. # $x->bsub($y);
  87. # print $x,"\n\n";
  88. #}
  89.  
  90. for(my $i=0;$i <= $#data;$i +=2) {
  91. my $x = ipv6_n2x(bcd2bin($data[$i]));
  92. print $data[$i],"\t=> $x\n";
  93. my $y = ipv6_n2x(bcd2bin($data[$i +1]));
  94. print $data[$i +1],"\t=> $y\n";
  95. }
  96.