Fixed MPIR.Net unit tests
This commit is contained in:
parent
5aab0cf7b0
commit
0aacd623e9
@ -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;
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user