Skip to content

Commit

Permalink
Add tests for negative decimals rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
mikernet committed Apr 19, 2021
1 parent 7037766 commit a0f1115
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Source/Singulink.Numerics.BigDecimal.Tests/RoundingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ public void RoundOverHalf()
}

[TestMethod]
public void MidPointAwayFromZero()
public void MidpointAwayFromZero()
{
Assert.AreEqual(1235m, BigDecimal.Round(1234.5m, 0, MidpointRounding.AwayFromZero));
Assert.AreEqual(1235m, BigDecimal.Round(1234.5675m, 0, MidpointRounding.AwayFromZero));
}

[TestMethod]
public void RoundingToNonExistantDigit()
public void NegativeDecimals()
{
Assert.AreEqual(0m, BigDecimal.Round(500m, -3));
Assert.AreEqual(-1000m, BigDecimal.Round(-500m, -3, MidpointRounding.AwayFromZero));
}

[TestMethod]
public void RoundingToNonExistentDigit()
{
// Ensures that rounding to a digit that doesn't exist in the mantissa works, i.e. 0.5 => 1

Expand Down

0 comments on commit a0f1115

Please sign in to comment.