Skip to content

Commit

Permalink
Add ceildiv spec
Browse files Browse the repository at this point in the history
  • Loading branch information
edipofederle authored and eregon committed Mar 5, 2023
1 parent e7dc804 commit 7c2ca54
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/integer/ceildiv_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative '../../spec_helper'

describe "Integer#ceildiv" do
ruby_version_is '3.2' do
it "returns a quotient of division which is rounded up to the nearest integer" do
0.ceildiv(3).should eql(0)
1.ceildiv(3).should eql(1)
3.ceildiv(3).should eql(1)
4.ceildiv(3).should eql(2)

4.ceildiv(-3).should eql(-1)
-4.ceildiv(3).should eql(-1)
-4.ceildiv(-3).should eql(2)

3.ceildiv(1.2).should eql(3)
3.ceildiv(6/5r).should eql(3)

(10**100-11).ceildiv(10**99-1).should eql(10)
(10**100-9).ceildiv(10**99-1).should eql(11)
end
end
end

0 comments on commit 7c2ca54

Please sign in to comment.