fmt: shared number formatting for HTML and PDF
This commit is contained in:
parent
9e85082758
commit
f7319a08a9
4 changed files with 54 additions and 18 deletions
22
test/fmt_test.rb
Normal file
22
test/fmt_test.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
require_relative 'test_helper'
|
||||
|
||||
class FmtTest < Minitest::Test
|
||||
def test_rate_pads_to_min_dp
|
||||
assert_equal '2.9500', Fmt.rate('2.95')
|
||||
assert_equal '3.0000', Fmt.rate(3)
|
||||
end
|
||||
|
||||
def test_rate_keeps_captured_precision
|
||||
assert_equal '2.95123456', Fmt.rate('2.95123456')
|
||||
end
|
||||
|
||||
def test_rate_groups_thousands
|
||||
assert_equal '1,050.2500', Fmt.rate('1050.25')
|
||||
end
|
||||
|
||||
def test_ltc_trims_trailing_zeros
|
||||
assert_equal '1.25', Fmt.ltc('1.250000')
|
||||
assert_equal '2', Fmt.ltc('2.0')
|
||||
assert_equal '0.00123456', Fmt.ltc('0.00123456')
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue