[Nagiosplug-checkins] nagiosplug/plugins-scripts/t utils.t, 1.1, 1.2

Ton Voon tonvoon at users.sourceforge.net
Fri Oct 27 17:37:33 CEST 2006


Update of /cvsroot/nagiosplug/nagiosplug/plugins-scripts/t
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3566/t

Modified Files:
	utils.t 
Log Message:
More edge testcases. Allow anything if ends with a . as long as correct 
characters


Index: utils.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/t/utils.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- utils.t	26 Oct 2006 21:02:21 -0000	1.1
+++ utils.t	27 Oct 2006 15:37:31 -0000	1.2
@@ -4,8 +4,10 @@
 #
 # $Id$
 #
+# Run with perl t/utils.t
 
-#use strict;
+use warnings;
+use strict;
 use Test::More;
 use NPTest;
 
@@ -19,16 +21,29 @@
 	"host-hyphened.com" => 1,
 	"rubbish" => 1,
 	"-start.com" => 0,
-	"endsindot." => 0,
+	"nonfqdn-but-endsindot." => 1,
+	"fqdn.and.endsindot." => 1,
 	"lots.of.dots.dot.org" => 1,
+	"endingwithdoubledots.." => 0,
+	"toomany..dots" => 0,
+	".start.with.dot" => 0,
 	"10.20.30.40" => 1,
 	"10.20.30.40.50" => 0,
 	"10.20.30" => 0,
+	"10.20.30.40." => 1,	# This is considered a hostname because of trailing dot. It probably won't exist though...
+	"888." => 1,		# This is because it could be a domain
+	"host.888." => 1,
+	"where.did.that.!.come.from." => 0,
+	"no.underscores_.com" => 0,
 	};
 
-plan tests => scalar keys %$hostname_checks;
+plan tests => ((scalar keys %$hostname_checks) + 4);
 
 foreach my $h (sort keys %$hostname_checks) {
 	is (utils::is_hostname($h), $hostname_checks->{$h}, "$h should return ".$hostname_checks->{$h});
 }
 
+is(utils::is_hostname(), 0, "No parameter errors");
+is(utils::is_hostname(""), 0, "Empty string errors");
+is(utils::is_hostname(0), 0, "0 also errors");
+is(utils::is_hostname(1), 0, "1 also errors");





More information about the Commits mailing list