Upgraded Rails and RSpec
[monkeycharger.git] / vendor / rails / activesupport / test / core_ext / float_ext_test.rb
blobb74add519fbcdb6bae365aa90e3ee69d78c2036e
1 require File.dirname(__FILE__) + '/../abstract_unit'
3 class FloatExtRoundingTests < Test::Unit::TestCase
4   def test_round_for_positive_number
5     assert_equal 1,    1.4.round
6     assert_equal 2,    1.6.round
7     assert_equal 2,    1.6.round(0)
8     assert_equal 1.4,  1.4.round(1)
9     assert_equal 1.4,  1.4.round(3)
10     assert_equal 1.5,  1.45.round(1)
11     assert_equal 1.45, 1.445.round(2)
12   end
14   def test_round_for_negative_number
15     assert_equal( -1,   -1.4.round )
16     assert_equal( -2,   -1.6.round )
17     assert_equal( -1.4, -1.4.round(1) )
18     assert_equal( -1.5, -1.45.round(1) )
19   end
21   def test_round_with_negative_precision
22     assert_equal 123460.0, 123456.0.round(-1)
23     assert_equal 123500.0, 123456.0.round(-2)
24   end
25 end