Skip to content

Commit

Permalink
Add missing specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Nov 29, 2018
1 parent fb78b81 commit 003083c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/std/big/big_decimal_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ describe BigDecimal do
describe "#round" do
{% for sign in %w[+ -] %}
context "(with {{sign.id}} sign)" do
it "returns self if digits are equal or more than significant digits" do
BigDecimal.new("{{sign.id}}2.5").round(1)
.should eq(BigDecimal.new(BigInt.new({{sign.id}}25), 1))
end

it "rounds :up" do
BigDecimal.new("{{sign.id}}2.1").round(0, :up)
.should eq(BigDecimal.new(BigInt.new({{sign.id}}3)))
Expand All @@ -198,6 +203,16 @@ describe BigDecimal do
BigDecimal.new("{{sign.id}}2.5").round(0, :half_even)
.should eq(BigDecimal.new(BigInt.new({{sign.id}}2)))
end

it "rounds :ceil" do
BigDecimal.new("{{sign.id}}2.5").round(0, :ceil)
.should eq(BigDecimal.new(BigInt.new({{sign.id}}{{sign == "+" ? 3 : 2}})))
end

it "rounds :floor" do
BigDecimal.new("{{sign.id}}2.5").round(0, :floor)
.should eq(BigDecimal.new(BigInt.new({{sign.id}}{{sign == "-" ? 3 : 2}})))
end
end
{% end %}
end
Expand Down

0 comments on commit 003083c

Please sign in to comment.