Fixed MPIR.Net unit tests

This commit is contained in:
Alex Dyachenko 2019-06-28 12:18:50 -04:00
parent 5aab0cf7b0
commit 0aacd623e9
6 changed files with 27 additions and 12 deletions

View File

@ -65,14 +65,14 @@ namespace MPIR.Tests.HugeFloatTests
[TestClass]
public class Arithmetic
{
[ClassInitialize]
public static void Setup(TestContext context)
[TestInitialize]
public void Setup()
{
HugeFloat.DefaultPrecision = 128;
}
[ClassCleanup]
public static void Cleanup()
[TestCleanup]
public void Cleanup()
{
HugeFloat.DefaultPrecision = 64;
}

View File

@ -69,6 +69,9 @@ namespace MPIR.Tests.HugeFloatTests
[TestMethod]
public void FloatCompareToHugeIntExpression()
{
var previousDefaultPrecision = HugeFloat.DefaultPrecision;
HugeFloat.DefaultPrecision = 256;
using (var a = new HugeFloat("-222509832503450298345039835740293845721345345354"))
using (var b = new HugeInt("222509832503450298345039835740293845721345345353"))
{
@ -82,6 +85,8 @@ namespace MPIR.Tests.HugeFloatTests
Assert.AreEqual(-1, Math.Sign((a + 1).CompareTo(1 - b)));
Assert.AreEqual(1, Math.Sign((a + 1).CompareTo(-b - 1)));
}
HugeFloat.DefaultPrecision = previousDefaultPrecision;
}
[TestMethod]

View File

@ -32,11 +32,16 @@ namespace MPIR.Tests.HugeFloatTests
public static void Init(TestContext context)
{
AlmostOne = new HugeFloat(0.99999);
}
[TestInitialize]
public void TestInit()
{
HugeFloat.DefaultPrecision = 128;
}
[ClassCleanup]
public static void Cleanup()
[TestCleanup]
public void Cleanup()
{
HugeFloat.DefaultPrecision = 64;
}

View File

@ -30,8 +30,8 @@ namespace MPIR.Tests.HugeFloatTests
[TestClass]
public class ExpressionTests
{
[ClassInitialize]
public static void Setup(TestContext context)
[TestInitialize]
public void Setup()
{
HugeFloat.DefaultPrecision = 64;
}

View File

@ -28,14 +28,14 @@ namespace MPIR.Tests.HugeFloatTests
[TestClass]
public class Precision
{
[ClassInitialize]
public static void Setup(TestContext context)
[TestInitialize]
public void Setup()
{
HugeFloat.DefaultPrecision = 128;
}
[ClassCleanup]
public static void Cleanup()
[TestCleanup]
public void Cleanup()
{
HugeFloat.DefaultPrecision = 64;
}

View File

@ -69,6 +69,9 @@ namespace MPIR.Tests.HugeIntTests
[TestMethod]
public void IntCompareToHugeFloatExpression()
{
var previousPrecision = HugeFloat.DefaultPrecision;
HugeFloat.DefaultPrecision = 256;
using (var a = new HugeInt("-222509832503450298345039835740293845721345345354"))
using (var b = new HugeFloat("222509832503450298345039835740293845721345345353"))
{
@ -82,6 +85,8 @@ namespace MPIR.Tests.HugeIntTests
Assert.AreEqual(-1, System.Math.Sign((a + 1).CompareTo(1 - b)));
Assert.AreEqual(1, System.Math.Sign((a + 1).CompareTo(-b - 1)));
}
HugeFloat.DefaultPrecision = previousPrecision;
}
[TestMethod]