Newer
Older
NetAddr-IP / Lite / t / v4-cnew.t
@Michael Robinton Michael Robinton on 21 Oct 2014 659 bytes Import of MIKER/NetAddr-IP-4.038 from CPAN.
  1. use NetAddr::IP::Lite;
  2.  
  3. my @subnets = (
  4. [ '127.1', '127.0.0.1/32' ],
  5. [ '127.1/16', '127.1.0.0/16' ],
  6. [ '10.10.10', '10.10.0.10/32' ],
  7. [ '10.10.10/24', '10.10.10.0/24' ],
  8. # include test for cisco syntax using space instead of '/'
  9. [ '127.1 16', '127.1.0.0/16' ],
  10. [ '10.10.10 24', '10.10.10.0/24' ],
  11. [ '10.10.10 255.255.255.0', '10.10.10.0/24' ],
  12. );
  13.  
  14. $| = 1;
  15.  
  16. print '1..', (scalar @subnets) , "\n";
  17.  
  18. my $count = 1;
  19.  
  20. for my $n (@subnets) {
  21. my $ip = new NetAddr::IP::Lite $n->[0];
  22. if ($ip eq $n->[1]) {
  23. print "ok $count\n";
  24. }
  25. else {
  26. print "not ok $count\n";
  27. }
  28.  
  29. ++ $count;
  30. }