Newer
Older
NetAddr-IP / Lite / t / aton.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_n2dx
  5. );
  6. use NetAddr::IP::Lite;
  7.  
  8. $| = 1;
  9.  
  10. print "1..2\n";
  11.  
  12. my $test = 1;
  13. sub ok() {
  14. print 'ok ',$test++,"\n";
  15. }
  16.  
  17. my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24
  18. my $hiip = new NetAddr::IP::Lite('FF00::4/120');
  19.  
  20. ## test aton
  21.  
  22. my $exp = 'FF00:0:0:0:0:0:0:4';
  23. my $txt = inet_n2dx($hiip->aton);
  24. print "got: $txt, exp: $exp\nnot "
  25. unless $txt eq $exp;
  26. &ok;
  27.  
  28. $exp = '1.2.3.4';
  29. $txt = inet_n2dx($loip->aton);
  30. print "got: $txt, exp: $exp\nnot "
  31. unless $txt eq $exp;
  32. &ok;
  33.