Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / t / form / format_amount.t
1 use strict;
2 use Test::More;
3
4 use lib 't';
5
6 use_ok('SL::Form');
7 require_ok('SL::Form');
8
9
10 package LxDebugMock;
11 sub enter_sub {};
12 sub leave_sub {};
13
14 $main::lxdebug = bless({}, 'LxDebugMock');
15
16 package main;
17
18
19 my $form = Form->new();
20
21
22 my $config = {};
23
24
25 $config->{numberformat} = '1.000,00';
26
27 is($form->format_amount($config, '1e1', 2), '10,00', 'format 1e1 (numberformat: 1.000,00)');
28 is($form->format_amount($config, 1000, 2), '1.000,00', 'format 1000 (numberformat: 1.000,00)');
29 is($form->format_amount($config, 1000.1234, 2), '1.000,12', 'format 1000.1234 (numberformat: 1.000,00)');
30 is($form->format_amount($config, 1000000000.1234, 2), '1.000.000.000,12', 'format 1000000000.1234 (numberformat: 1.000,00)');
31 is($form->format_amount($config, -1000000000.1234, 2), '-1.000.000.000,12', 'format -1000000000.1234 (numberformat: 1.000,00)');
32
33
34 $config->{numberformat} = '1,000.00';
35
36 is($form->format_amount($config, '1e1', 2), '10,00', 'format 1e1 (numberformat: 1,000.00)');
37 is($form->format_amount($config, 1000, 2), '1.000,00', 'format 1000 (numberformat: 1,000.00)');
38 is($form->format_amount($config, 1000.1234, 2), '1.000,12', 'format 1000.1234 (numberformat: 1,000.00)');
39 is($form->format_amount($config, 1000000000.1234, 2), '1.000.000.000,12', 'format 1000000000.1234 (numberformat: 1,000.00)');
40 is($form->format_amount($config, -1000000000.1234, 2), '-1.000.000.000,12', 'format -1000000000.1234 (numberformat: 1,000.00)');
41
42 done_testing;
43
44 1;