Newer
Older
NetAddr-IP / Lite / t / range.t
@Luis Muñoz Luis Muñoz on 21 Oct 2014 543 bytes Import of LUISMUNOZ/NetAddr-IP-4.001 from CPAN.
  1.  
  2. #use diagnostics;
  3. use NetAddr::IP::Util qw(
  4. inet_ntoa
  5. ipv6_n2x
  6. );
  7. use NetAddr::IP::Lite;
  8.  
  9. $| = 1;
  10.  
  11. print "1..2\n";
  12.  
  13. my $test = 1;
  14. sub ok() {
  15. print 'ok ',$test++,"\n";
  16. }
  17.  
  18. my $loip = new NetAddr::IP::Lite('1.2.3.4/24');
  19. my $hiip = new NetAddr::IP::Lite('FF00::4/120');
  20.  
  21. ## test range
  22.  
  23. my $exp = 'FF00:0:0:0:0:0:0:0 - FF00:0:0:0:0:0:0:FF';
  24. my $txt = $hiip->range;
  25. print "got: $txt, exp: $exp\nnot "
  26. unless $txt eq $exp;
  27. &ok;
  28.  
  29. $exp = '1.2.3.0 - 1.2.3.255';
  30. $txt = $loip->range;
  31. print "got: $txt, exp: $exp\nnot "
  32. unless $txt eq $exp;
  33. &ok;
  34.