summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-27 19:36:15 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-27 19:36:15 +0000
commita3c58a38620e82d8ba0b536c9d062e1c49846225 (patch)
tree0722e9ccda8a9277a8d9885f95d012dd8b852c43
parent6391fead9523a9744a63213533c28e6ce425d51a (diff)
Add tests for parsing empty and invalid strings
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@342 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--t/02-number-handling.t10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/02-number-handling.t b/t/02-number-handling.t
index a59b0ac5..0a6b43dc 100644
--- a/t/02-number-handling.t
+++ b/t/02-number-handling.t
@@ -114,6 +114,11 @@ foreach my $format (0 .. $#formats) {
$value = Math::BigFloat->new('-21');
cmp_ok($form->parse_amount(\%myconfig, $expected), '==', $value,
"$expected parsed as $formats[$format][0] - $value");
+
+ is($form->parse_amount(\%myconfig, ''), undef,
+ "Empty string returns undef");
+ cmp_ok($form->parse_amount(\%myconfig, 'foo'), '==',
+ Math::BigFloat->bnan(), "Invalid string returns NaN");
}
foreach my $format (0 .. $#formats) {
@@ -150,4 +155,9 @@ foreach my $format (0 .. $#formats) {
$form->parse_amount(\%myconfig, $expected)),
'==', $value,
"$expected parsed as $formats[$format][0] - $value");
+
+ is($form->parse_amount(\%myconfig, ''), undef,
+ "Empty string returns undef");
+ cmp_ok($form->parse_amount(\%myconfig, 'foo'), '==',
+ Math::BigFloat->bnan(), "Invalid string returns NaN");
}