summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2008-05-14 11:19:53 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2008-05-14 11:19:53 +0000
commitc47e1a9c28db2890f724ee57e59f3a3c30d7740c (patch)
tree5648f0b0ff1a1eb2478f75484a26e3fa42e1f455 /t
parent60a00b6e423bfeeca3508398556e180955355079 (diff)
downloadmonitoring-plugin-perl-c47e1a9c28db2890f724ee57e59f3a3c30d7740c.tar.gz
Fixed parsing of scientific notation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1993 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 't')
-rw-r--r--t/Nagios-Plugin-Performance.t27
1 files changed, 23 insertions, 4 deletions
diff --git a/t/Nagios-Plugin-Performance.t b/t/Nagios-Plugin-Performance.t
index 7a28546..0c9ab74 100644
--- a/t/Nagios-Plugin-Performance.t
+++ b/t/Nagios-Plugin-Performance.t
@@ -1,6 +1,6 @@
1 1
2use strict; 2use strict;
3use Test::More tests => 111; 3use Test::More tests => 123;
4BEGIN { use_ok('Nagios::Plugin::Performance') }; 4BEGIN { use_ok('Nagios::Plugin::Performance') };
5 5
6diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE}; 6diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE};
@@ -162,13 +162,32 @@ is( $p[0]->threshold->warning, "-60:-5", "warn okay");
162is( $p[0]->threshold->critical, "-120:-3", "crit okay"); 162is( $p[0]->threshold->critical, "-120:-3", "crit okay");
163 163
164# Check infinity values are okay 164# Check infinity values are okay
165@p = Nagios::Plugin::Performance->parse_perfstring("salary=52GBP;~:23;45:"); 165@p = Nagios::Plugin::Performance->parse_perfstring("salary=52GBP;~:23.5;45.2:");
166is( $p[0]->label, "salary", "label okay"); 166is( $p[0]->label, "salary", "label okay");
167is( $p[0]->value, "52", "value okay"); 167is( $p[0]->value, "52", "value okay");
168is( $p[0]->uom, "GBP", "uom okay"); 168is( $p[0]->uom, "GBP", "uom okay");
169ok( defined eval { $p[0]->threshold->warning->is_set }, "Warning range has been set"); 169ok( defined eval { $p[0]->threshold->warning->is_set }, "Warning range has been set");
170is( $p[0]->threshold->critical->is_set, 1, "Critical range has been set"); 170is( $p[0]->threshold->critical->is_set, 1, "Critical range has been set");
171is( $p[0]->threshold->warning, "~:23", "warn okay"); 171is( $p[0]->threshold->warning, "~:23.5", "warn okay");
172is( $p[0]->threshold->critical, "45:", "warn okay"); 172is( $p[0]->threshold->critical, "45.2:", "warn okay");
173
174# Check scientific notation
175@p = Nagios::Plugin::Performance->parse_perfstring("offset=1.120567322e-05");
176is( $p[0]->label, "offset", "label okay for scientific notation");
177is( $p[0]->value, 1.120567322e-05, "value okay");
178is( $p[0]->uom, "", "uom okay");
179ok( ! $p[0]->threshold->warning->is_set, "Warning range has not been set");
180ok( ! $p[0]->threshold->critical->is_set, "Critical range has not been set");
181
182
183# Check scientific notation with warnings and criticals
184@p = Nagios::Plugin::Performance->parse_perfstring("offset=-1.120567322e-05unit;-1.1e-05:1.0e-03;4.3e+02:4.3e+25");
185is( $p[0]->label, "offset", "label okay for scientific notation in warnings and criticals");
186is( $p[0]->value, -1.120567322e-05, "value okay");
187is( $p[0]->uom, "unit", "uom okay");
188ok( $p[0]->threshold->warning->is_set, "Warning range has been set");
189is( $p[0]->threshold->warning, "-1.1e-05:0.001", "warn okay");
190is( $p[0]->threshold->critical->is_set, 1, "Critical range has been set");
191is( $p[0]->threshold->critical, "430:4.3e+25", "warn okay");
173 192
174# add_perfdata tests in t/Nagios-Plugin-01.t 193# add_perfdata tests in t/Nagios-Plugin-01.t