From 97a8cc896dcb1f95a5158396f9fb0e0e22395518 Mon Sep 17 00:00:00 2001 From: Alex Dyachenko Date: Sat, 23 May 2015 20:36:51 -0400 Subject: [PATCH] Fixed unit tests broken after the merge. 3 tests broken due to MPIR behavior (FitsUxxx returns false for -0.9) --- mpir.net/mpir.net-tests/HugeFloatTests/Arithmetic.cs | 12 ++++++++++++ mpir.net/mpir.net-tests/HugeFloatTests/Assignment.cs | 2 +- .../HugeFloatTests/ConstructionAndDisposal.cs | 12 ++++++++++++ .../mpir.net-tests/HugeFloatTests/Conversions.cs | 9 ++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mpir.net/mpir.net-tests/HugeFloatTests/Arithmetic.cs b/mpir.net/mpir.net-tests/HugeFloatTests/Arithmetic.cs index 730ef81c..ec6abbe5 100644 --- a/mpir.net/mpir.net-tests/HugeFloatTests/Arithmetic.cs +++ b/mpir.net/mpir.net-tests/HugeFloatTests/Arithmetic.cs @@ -65,6 +65,18 @@ namespace MPIR.Tests.HugeFloatTests [TestClass] public class Arithmetic { + [ClassInitialize] + public static void Setup(TestContext context) + { + HugeFloat.DefaultPrecision = 128; + } + + [ClassCleanup] + public static void Cleanup() + { + HugeFloat.DefaultPrecision = 64; + } + #region Add [TestMethod] diff --git a/mpir.net/mpir.net-tests/HugeFloatTests/Assignment.cs b/mpir.net/mpir.net-tests/HugeFloatTests/Assignment.cs index 265756c2..ce7f8627 100644 --- a/mpir.net/mpir.net-tests/HugeFloatTests/Assignment.cs +++ b/mpir.net/mpir.net-tests/HugeFloatTests/Assignment.cs @@ -107,7 +107,7 @@ namespace MPIR.Tests.HugeFloatTests using (var b = new HugeFloat()) { b.SetTo(a); - FloatAssert.AreEqual(".3333333333333333333333333333333333333333333333333333333333", b); + FloatAssert.AreEqual(".33333333333333333333333333333333333333333333333333333333333333333333333333333333333", b); } } //more tests coming here diff --git a/mpir.net/mpir.net-tests/HugeFloatTests/ConstructionAndDisposal.cs b/mpir.net/mpir.net-tests/HugeFloatTests/ConstructionAndDisposal.cs index 004258d3..9e02c50e 100644 --- a/mpir.net/mpir.net-tests/HugeFloatTests/ConstructionAndDisposal.cs +++ b/mpir.net/mpir.net-tests/HugeFloatTests/ConstructionAndDisposal.cs @@ -25,6 +25,18 @@ namespace MPIR.Tests.HugeFloatTests [TestClass] public class ConstructionAndDisposal { + [TestInitialize] + public void Setup() + { + HugeFloat.DefaultPrecision = 128; + } + + [TestCleanup] + public void Cleanup() + { + HugeFloat.DefaultPrecision = 64; + } + [TestMethod] public void FloatDefaultConstructor() { diff --git a/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs b/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs index 0730f6b3..2f616ff0 100644 --- a/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs +++ b/mpir.net/mpir.net-tests/HugeFloatTests/Conversions.cs @@ -32,6 +32,13 @@ namespace MPIR.Tests.HugeFloatTests public static void Init(TestContext context) { AlmostOne = new HugeFloat(0.99999); + HugeFloat.DefaultPrecision = 128; + } + + [ClassCleanup] + public static void Cleanup() + { + HugeFloat.DefaultPrecision = 64; } [TestMethod] @@ -204,7 +211,7 @@ namespace MPIR.Tests.HugeFloatTests n = "-98ABCDEF876529834765234123984761"; a.SetTo(n, 16); - Assert.AreEqual("-0." + n.Substring(1) + "@" + (n.Length - 1), a.ToString(16)); + Assert.AreEqual("-0." + n.Substring(1) + "@" + (n.Length - 1).ToString("x"), a.ToString(16)); } }