From dc31f1cd3841d486e920e59ce42e888ca94e4289 Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Wed, 21 Mar 2007 00:52:56 +0000 Subject: Finished initial --extra-opts support; added Getopt spec-to-help and multiline help support. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1643 f882894a-f735-0410-b71e-b25c423dba1c --- t/Nagios-Plugin-Getopt-01.t | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 't/Nagios-Plugin-Getopt-01.t') diff --git a/t/Nagios-Plugin-Getopt-01.t b/t/Nagios-Plugin-Getopt-01.t index b708a5f..bad1367 100644 --- a/t/Nagios-Plugin-Getopt-01.t +++ b/t/Nagios-Plugin-Getopt-01.t @@ -27,8 +27,8 @@ sub setup # Add argument - named version $ng->arg( - spec => 'critical|c=s', - help => qq(-c, --critical=INTEGER\n Exit with CRITICAL status if less than INTEGER foobars are free), + spec => 'critical|c=i', + help => qq(Exit with CRITICAL status if less than INTEGER foobars are free), required => 1, ); @@ -104,6 +104,7 @@ like($@, qr/$PARAM{version}/, 'version info includes version'); like($@, qr/$PARAM{url}/, 'version info includes url'); unlike($@, qr/Usage:/, 'no usage message'); unlike($@, qr/Missing arg/, 'no missing arguments'); + @ARGV = ( '--version' ); $ng = setup; ok(! defined eval { $ng->getopts }, 'getopts died on version'); @@ -128,6 +129,7 @@ like($@, qr/--verbose/, 'help includes default options 2'); like($@, qr/--warning/, 'help includes custom option 1'); like($@, qr/--critical/, 'help includes custom option 2'); unlike($@, qr/Missing arg/, 'no missing arguments'); + @ARGV = ( '--help' ); $ng = setup; ok(! defined eval { $ng->getopts }, 'getopts died on help'); @@ -140,6 +142,6 @@ like($@, qr/Usage:/, 'help includes usage message'); like($@, qr/--version/, 'help includes default options 1'); like($@, qr/--verbose/, 'help includes default options 2'); like($@, qr/--warning/, 'help includes custom option 1'); -like($@, qr/--critical/, 'help includes custom option 2'); +like($@, qr/-c, --critical=INTEGER/, 'help includes custom option 2, with expanded args'); unlike($@, qr/Missing arg/, 'no missing arguments'); -- cgit v1.2.3-74-g34f1