summaryrefslogtreecommitdiff
path: root/t/02-number-handling.t
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-15 21:41:26 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-15 21:41:26 +0000
commit7e35de61a83d1c845721969e16b0b00e52df3092 (patch)
treea5e2c25b025fca7c90b5aa120b59c680806959b5 /t/02-number-handling.t
parentd88305e4a06c58854ec43dd906f285426ed2de60 (diff)
Number parsing fix for LedgerSMB.pm and more test cases
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1198 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 't/02-number-handling.t')
-rw-r--r--t/02-number-handling.t19
1 files changed, 19 insertions, 0 deletions
diff --git a/t/02-number-handling.t b/t/02-number-handling.t
index 6d38de27..23eb7fee 100644
--- a/t/02-number-handling.t
+++ b/t/02-number-handling.t
@@ -156,6 +156,21 @@ is($form->format_amount({'numberformat' => '1000.00'} , '1.00', 2, 'x'), '1.00',
is($lsmb->format_amount('user' => {'numberformat' => '1000.00'},
'amount' => '1.00', 'precision' => 2, 'neg_format' => 'x'), '1.00',
"lsmb: 1.00 with dash 'x'");
+is($form->format_amount({'numberformat' => '1000.00'} , '1.00'), '1',
+ "form: 1.00 with no precision or dash");
+is($lsmb->format_amount('user' => {'numberformat' => '1000.00'},
+ 'amount' => '1.00'), '1',
+ "lsmb: 1.00 with no precision or dash");
+is($form->format_amount({'numberformat' => '1000.00'} , '1.50'), '1.5',
+ "form: 1.50 with no precision or dash");
+is($lsmb->format_amount('user' => {'numberformat' => '1000.00'},
+ 'amount' => '1.50'), '1.5',
+ "lsmb: 1.50 with no precision or dash");
+is($form->format_amount({'numberformat' => '1000.00'} , '0.0', undef, '0'), '0',
+ "form: 0.0 with no precision, dash '0'");
+is($lsmb->format_amount('user' => {'numberformat' => '1000.00'},
+ 'amount' => '0.0', 'neg_format' => '0'), '0',
+ "lsmb: 0.0 with no precision, dash '0'");
foreach my $format (0 .. $#formats) {
%myconfig = (numberformat => $formats[$format][0]);
@@ -287,8 +302,12 @@ foreach my $format (0 .. $#formats) {
cmp_ok($form->parse_amount(\%myconfig, ''), '==', 0,
"form: Empty string returns 0");
+ cmp_ok($form->parse_amount(\%myconfig), '==', 0,
+ "form: undef string returns 0");
cmp_ok($form->parse_amount(\%myconfig, 'foo'), 'eq',
Math::BigFloat->bnan(), "form: Invalid string returns NaN");
+ cmp_ok($lsmb->parse_amount('user' => \%myconfig), '==', 0,
+ "lsmb: undef string returns 0");
cmp_ok($lsmb->parse_amount('user' => \%myconfig, 'amount' => ''), '==', 0,
"lsmb: Empty string returns 0");
cmp_ok($lsmb->parse_amount('user' => \%myconfig, 'amount' => 'foo'), 'eq',