diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-12-17 01:00:29 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-12-17 01:00:29 +0000 |
commit | 2570f408f0326bf9c7a9cbae55e0ccf909b8c820 (patch) | |
tree | bbcc796e88ebaf2629e955cd7c0a60c617313153 /actionpack | |
parent | 86deb270953f9c5b62813d3e1938f33cc807bd7f (diff) | |
download | rails-2570f408f0326bf9c7a9cbae55e0ccf909b8c820.tar.gz rails-2570f408f0326bf9c7a9cbae55e0ccf909b8c820.tar.bz2 rails-2570f408f0326bf9c7a9cbae55e0ccf909b8c820.zip |
Work around a cross-platform number_to_precision inconsistency in unit tests. Closes #6315. [jesperron]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5727 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/template/number_helper_test.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb index df2c9183fb..75fcc82500 100644 --- a/actionpack/test/template/number_helper_test.rb +++ b/actionpack/test/template/number_helper_test.rb @@ -22,7 +22,7 @@ class NumberHelperTest < Test::Unit::TestCase def test_number_to_currency assert_equal("$1,234,567,890.50", number_to_currency(1234567890.50)) assert_equal("$1,234,567,890.51", number_to_currency(1234567890.506)) - assert_equal("$1,234,567,890", number_to_currency(1234567890.50, {:precision => 0})) + assert_equal("$1,234,567,892", number_to_currency(1234567891.50, {:precision => 0})) assert_equal("$1,234,567,890.5", number_to_currency(1234567890.50, {:precision => 1})) assert_equal("£1234567890,50", number_to_currency(1234567890.50, {:unit => "£", :separator => ",", :delimiter => ""})) assert_equal("$1,234,567,890.50", number_to_currency("1234567890.50")) @@ -53,16 +53,20 @@ class NumberHelperTest < Test::Unit::TestCase assert_equal("x", number_with_delimiter("x")) assert_nil number_with_delimiter(nil) end - + def test_number_with_precision assert_equal("111.235", number_with_precision(111.2346)) assert_equal("111.23", number_with_precision(111.2346, 2)) assert_equal("111.00", number_with_precision(111, 2)) assert_equal("111.235", number_with_precision("111.2346")) + assert_equal("112", number_with_precision(111.50, 0)) + assert_equal("1234567892", number_with_precision(1234567891.50, 0)) + + # Return non-numeric params unchanged. assert_equal("x", number_with_precision("x")) assert_nil number_with_precision(nil) end - + def test_number_to_human_size assert_equal '0 Bytes', number_to_human_size(0) assert_equal '1 Byte', number_to_human_size(1) |