|
Line 0
Link Here
|
| 0 |
- |
1 |
use strict; |
|
|
2 |
use warnings; |
| 3 |
use 5.010; |
| 4 |
|
| 5 |
use C4::Context; |
| 6 |
use Test::More tests => 18; |
| 7 |
use Test::MockModule; |
| 8 |
|
| 9 |
BEGIN { use_ok('Koha::MoneyUtils'); } |
| 10 |
|
| 11 |
my $money_string; |
| 12 |
|
| 13 |
my @normalize_test = ( |
| 14 |
{ 'orig' => '', 'norm' => '.0' }, |
| 15 |
{ 'orig' => '0', 'norm' => '0.0' }, |
| 16 |
{ 'orig' => '1', 'norm' => '1.0' }, |
| 17 |
{ 'orig' => '23', 'norm' => '23.0' }, |
| 18 |
{ 'orig' => '1.23', 'norm' => '1.23' }, |
| 19 |
{ 'orig' => '1,23', 'norm' => '1.23' }, |
| 20 |
{ 'orig' => '1.23 €', 'norm' => '1.23' }, |
| 21 |
{ 'orig' => '1,23€', 'norm' => '1.23' }, |
| 22 |
{ 'orig' => '$1.23', 'norm' => '1.23' }, |
| 23 |
{ 'orig' => '$ 1,23', 'norm' => '1.23' }, |
| 24 |
{ 'orig' => '.23', 'norm' => '.23' }, |
| 25 |
{ 'orig' => ',23', 'norm' => '.23' }, |
| 26 |
{ 'orig' => '.2', 'norm' => '.2' }, |
| 27 |
{ 'orig' => ',2', 'norm' => '.2' }, |
| 28 |
{ 'orig' => '1.23456', 'norm' => '1.23456' }, |
| 29 |
{ 'orig' => '1,234.56', 'norm' => '1234.56' }, |
| 30 |
{ 'orig' => '1 234,56', 'norm' => '1234.56' } |
| 31 |
); |
| 32 |
|
| 33 |
|
| 34 |
foreach my $test (@normalize_test) { |
| 35 |
my $errstr = 'normalize_money("'.$test->{'orig'}.'") is not '.$test->{'norm'}; |
| 36 |
cmp_ok(normalize_money($test->{'orig'}), 'eq', $test->{'norm'}, $errstr); |
| 37 |
} |