summaryrefslogtreecommitdiff
path: root/test/test_mathn.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-25 06:28:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-25 06:28:00 +0000
commit631dde2572eb78cbf09d73d23a43852ccb199bd1 (patch)
treed85aad8b66468b69730c9a85362879b56f5aa41a /test/test_mathn.rb
parentb6d10b6c378edcb88d3238b5c862e585ad9c8b33 (diff)
round-down
* numeric.c (round_half_down, int_round_half_down): support round-down mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_mathn.rb')
-rw-r--r--test/test_mathn.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_mathn.rb b/test/test_mathn.rb
index 2ea049502c..bafc4c8dbc 100644
--- a/test/test_mathn.rb
+++ b/test/test_mathn.rb
@@ -157,6 +157,27 @@ class TestMathn < Test::Unit::TestCase
assert_equal((-12/5), (-12/5).round(2, half: :up))
assert_equal(( -5/2), ( -5/2).round(2, half: :up))
assert_equal((-13/5), (-13/5).round(2, half: :up))
+
+ assert_equal( 3, ( 13/5).round(half: :down))
+ assert_equal( 2, ( 5/2).round(half: :down))
+ assert_equal( 2, ( 12/5).round(half: :down))
+ assert_equal(-2, (-12/5).round(half: :down))
+ assert_equal(-2, ( -5/2).round(half: :down))
+ assert_equal(-3, (-13/5).round(half: :down))
+
+ assert_equal( 3, ( 13/5).round(0, half: :down))
+ assert_equal( 2, ( 5/2).round(0, half: :down))
+ assert_equal( 2, ( 12/5).round(0, half: :down))
+ assert_equal(-2, (-12/5).round(0, half: :down))
+ assert_equal(-2, ( -5/2).round(0, half: :down))
+ assert_equal(-3, (-13/5).round(0, half: :down))
+
+ assert_equal(( 13/5), ( 13/5).round(2, half: :down))
+ assert_equal(( 5/2), ( 5/2).round(2, half: :down))
+ assert_equal(( 12/5), ( 12/5).round(2, half: :down))
+ assert_equal((-12/5), (-12/5).round(2, half: :down))
+ assert_equal(( -5/2), ( -5/2).round(2, half: :down))
+ assert_equal((-13/5), (-13/5).round(2, half: :down))
EOS
end
end