1 #!/usr/bin/perl -w -I ..
6 # Run with perl t/utils.t
16 my $hostname_checks = {
17 "www.altinity.com" => 1,
20 "host-hyphened.com" => 1,
23 "nonfqdn-but-endsindot." => 1,
24 "fqdn.and.endsindot." => 1,
25 "lots.of.dots.dot.org" => 1,
26 "endingwithdoubledots.." => 0,
28 ".start.with.dot" => 0,
30 "10.20.30.40.50" => 0,
32 "10.20.30.40." => 1, # This is considered a hostname because of trailing dot. It probably won't exist though...
33 "888." => 1, # This is because it could be a domain
35 "where.did.that.!.come.from." => 0,
36 "no.underscores_.com" => 0,
37 "a.somecompany.com" => 1,
41 plan tests
=> ((scalar keys %$hostname_checks) + 4);
43 foreach my $h (sort keys %$hostname_checks) {
44 is
(utils
::is_hostname
($h), $hostname_checks->{$h}, "$h should return ".$hostname_checks->{$h});
47 is
(utils
::is_hostname
(), 0, "No parameter errors");
48 is
(utils
::is_hostname
(""), 0, "Empty string errors");
49 is
(utils
::is_hostname
(0), 0, "0 also errors");
50 is
(utils
::is_hostname
(1), 0, "1 also errors");