From a3c58a38620e82d8ba0b536c9d062e1c49846225 Mon Sep 17 00:00:00 2001 From: tetragon Date: Fri, 27 Oct 2006 19:36:15 +0000 Subject: 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 --- t/02-number-handling.t | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't') 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"); } -- cgit v1.2.3