| 1 | #!/bin/perl |
| 2 | |
| 3 | use Test::More tests => 28; |
| 4 | |
| 5 | BEGIN { |
| 6 | use_ok('Locale::Currency::Format'); |
| 7 | } |
| 8 | is( currency_format( 'usd', 1000 ), '1,000.00 USD', "USD" ); |
| 9 | is( currency_format( 'usd', 1000, FMT_NOZEROS ), '1,000 USD', "Format USD No Zeros" ); |
| 10 | is( currency_format( 'usd', 1000, FMT_HTML ), '$1,000.00', "Format USD HTML" ); |
| 11 | is( currency_format( 'usd', 1000, FMT_NAME ), "1,000.00 US Dollar", "Format USD Name" ); |
| 12 | is( currency_format( 'usd', 1000, FMT_SYMBOL ), "\x{0024}1,000.00", "Format USD Symbol" ); |
| 13 | is( currency_format('usd'), undef, "Not Blank" ); |
| 14 | is( currency_format(), undef, "Not Blank" ); |
| 15 | is( currency_format( 'us', 1000 ), undef, "Check US" ); |
| 16 | is( currency_symbol( 'vnd', SYM_UTF ), "\x{20AB}", "Check VND Symbol" ); |
| 17 | is( currency_symbol( 'vnd', SYM_HTML ), "₫", "Check VND HTML" ); |
| 18 | is( currency_symbol(), undef, "Check symbol" ); |
| 19 | is( currency_symbol( 'usd', 10 ), undef, "Check USD symbol" ); |
| 20 | is( currency_symbol('vn'), undef, "Check VN symbol" ); |
| 21 | is( currency_symbol('aed'), undef, "Check SED symbol" ); |
| 22 | is( currency_set( 'USD', '#.###,## $', FMT_COMMON ), 'USD', "Setting custom currency" ); |
| 23 | is( currency_format( 'USD', 1000, FMT_COMMON ), '1.000,00 $', "Check custom" ); |
| 24 | is( currency_set('USD'), 'USD', "Reset custom currency" ); |
| 25 | is( currency_format( 'USD', 1000, FMT_COMMON ), '$1,000.00', "Check custom reset is" ); |
| 26 | is( currency_set( 'GBP', "\x{00A3}#,###.##", FMT_COMMON ), 'GBP', "custom GBP" ); |
| 27 | is( decimal_precision('usd'), 2, "Check USD decimal precision" ); |
| 28 | is( decimal_precision('bhd'), 3, "Check BHD decimal precision" ); |
| 29 | is( decimal_separator('usd'), '.', "Check USD decimal seperator" ); |
| 30 | is( decimal_separator('eur'), ',', "Check EUR decimal seperator" ); |
| 31 | is( thousands_separator('usd'), ',', "Check USD thousands seperator" ); |
| 32 | is( thousands_separator('eur'), '.', "Check EUR thousands seperator" ); |
| 33 | is( currency_name('usd'), 'US Dollar', "Check USD currency name" ); |
| 34 | is( currency_name('gbp'), 'Pound Sterling', "Check GBP currency name" ); |