Newer
Older
NetAddr-IP / Lite / t / old-num.t
@Luis Muñoz Luis Muñoz on 21 Oct 2014 447 bytes Import of LUISMUNOZ/NetAddr-IP-4.001 from CPAN.
  1.  
  2. #use diagnostics;
  3. use NetAddr::IP::Lite qw(:old_nth);
  4.  
  5. $| = 1;
  6.  
  7. sub ok() {
  8. print 'ok ',$test++,"\n";
  9. }
  10.  
  11. my @try = qw(
  12. 10/32 0
  13. 10/31 1
  14. 10/30 3
  15. ::1/128 0
  16. ::1/127 1
  17. ::1/126 3
  18. 1.2.3.11/29 7
  19. FF::8B/125 7
  20. );
  21.  
  22. print '1..',(@try/2),"\n";
  23.  
  24. $test = 1;
  25.  
  26. foreach(my $i = 0;$i <=$#try;$i+= 2) {
  27. my $ip = NetAddr::IP::Lite->new($try[$i]);
  28. my $exp = $try[$i +1];
  29.  
  30. print "got: $_, exp: $exp\nnot "
  31. unless ($_ = $ip->num) == $exp;
  32. &ok;
  33. }