utils.t 587 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/perl -w -I ..
  2. #
  3. # utils.pm tests
  4. #
  5. # $Id$
  6. #
  7. #use strict;
  8. use Test::More;
  9. use NPTest;
  10. use lib "..";
  11. use utils;
  12. my $hostname_checks = {
  13. "www.altinity.com" => 1,
  14. "www.888.com" => 1,
  15. "888.com" => 1,
  16. "host-hyphened.com" => 1,
  17. "rubbish" => 1,
  18. "-start.com" => 0,
  19. "endsindot." => 0,
  20. "lots.of.dots.dot.org" => 1,
  21. "10.20.30.40" => 1,
  22. "10.20.30.40.50" => 0,
  23. "10.20.30" => 0,
  24. };
  25. plan tests => scalar keys %$hostname_checks;
  26. foreach my $h (sort keys %$hostname_checks) {
  27. is (utils::is_hostname($h), $hostname_checks->{$h}, "$h should return ".$hostname_checks->{$h});
  28. }