diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2008-05-14 11:19:53 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2008-05-14 11:19:53 +0000 |
commit | c47e1a9c28db2890f724ee57e59f3a3c30d7740c (patch) | |
tree | 5648f0b0ff1a1eb2478f75484a26e3fa42e1f455 /t | |
parent | 60a00b6e423bfeeca3508398556e180955355079 (diff) | |
download | monitoring-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.t | 27 |
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 | ||
2 | use strict; | 2 | use strict; |
3 | use Test::More tests => 111; | 3 | use Test::More tests => 123; |
4 | BEGIN { use_ok('Nagios::Plugin::Performance') }; | 4 | BEGIN { use_ok('Nagios::Plugin::Performance') }; |
5 | 5 | ||
6 | diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE}; | 6 | diag "\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"); | |||
162 | is( $p[0]->threshold->critical, "-120:-3", "crit okay"); | 162 | is( $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:"); |
166 | is( $p[0]->label, "salary", "label okay"); | 166 | is( $p[0]->label, "salary", "label okay"); |
167 | is( $p[0]->value, "52", "value okay"); | 167 | is( $p[0]->value, "52", "value okay"); |
168 | is( $p[0]->uom, "GBP", "uom okay"); | 168 | is( $p[0]->uom, "GBP", "uom okay"); |
169 | ok( defined eval { $p[0]->threshold->warning->is_set }, "Warning range has been set"); | 169 | ok( defined eval { $p[0]->threshold->warning->is_set }, "Warning range has been set"); |
170 | is( $p[0]->threshold->critical->is_set, 1, "Critical range has been set"); | 170 | is( $p[0]->threshold->critical->is_set, 1, "Critical range has been set"); |
171 | is( $p[0]->threshold->warning, "~:23", "warn okay"); | 171 | is( $p[0]->threshold->warning, "~:23.5", "warn okay"); |
172 | is( $p[0]->threshold->critical, "45:", "warn okay"); | 172 | is( $p[0]->threshold->critical, "45.2:", "warn okay"); |
173 | |||
174 | # Check scientific notation | ||
175 | @p = Nagios::Plugin::Performance->parse_perfstring("offset=1.120567322e-05"); | ||
176 | is( $p[0]->label, "offset", "label okay for scientific notation"); | ||
177 | is( $p[0]->value, 1.120567322e-05, "value okay"); | ||
178 | is( $p[0]->uom, "", "uom okay"); | ||
179 | ok( ! $p[0]->threshold->warning->is_set, "Warning range has not been set"); | ||
180 | ok( ! $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"); | ||
185 | is( $p[0]->label, "offset", "label okay for scientific notation in warnings and criticals"); | ||
186 | is( $p[0]->value, -1.120567322e-05, "value okay"); | ||
187 | is( $p[0]->uom, "unit", "uom okay"); | ||
188 | ok( $p[0]->threshold->warning->is_set, "Warning range has been set"); | ||
189 | is( $p[0]->threshold->warning, "-1.1e-05:0.001", "warn okay"); | ||
190 | is( $p[0]->threshold->critical->is_set, 1, "Critical range has been set"); | ||
191 | is( $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 |