From a0f1115ba387fbde4ef493c98dc1ab8727302b72 Mon Sep 17 00:00:00 2001 From: Mike Marynowski Date: Sun, 18 Apr 2021 20:45:27 -0400 Subject: [PATCH] Add tests for negative decimals rounding --- .../RoundingTests.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/Singulink.Numerics.BigDecimal.Tests/RoundingTests.cs b/Source/Singulink.Numerics.BigDecimal.Tests/RoundingTests.cs index 28776f6..9b645ab 100644 --- a/Source/Singulink.Numerics.BigDecimal.Tests/RoundingTests.cs +++ b/Source/Singulink.Numerics.BigDecimal.Tests/RoundingTests.cs @@ -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