Skip to content

Commit

Permalink
Update to v2.0.0 (remove static config + add factory)
Browse files Browse the repository at this point in the history
  • Loading branch information
XeroXP committed Jul 12, 2022
1 parent 60bc90a commit 8cbacf2
Show file tree
Hide file tree
Showing 27 changed files with 6,435 additions and 6,843 deletions.
39 changes: 16 additions & 23 deletions BigSharp.Tests/BigAbsTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using BigSharp.Tests.Extensions;
using Newtonsoft.Json;
using NUnit.Framework;
using System;
using System.Globalization;

namespace BigSharp.Tests
{
Expand All @@ -17,20 +14,17 @@ public void Setup()
[Test]
public void Abs()
{
var t = (object expected0, object value0) =>
{
string expected = expected0.ToExpectedString();

Big? value = value0.ToBig();
var bigFactory = new BigFactory(new BigConfig());

if (value == null)
Assert.Fail();
var t = (object expected0, BigArgument value) =>
{
string expected = expected0.ToExpectedString(bigFactory.Config.PE, bigFactory.Config.NE);

BigTests.AreEqual(expected, new Big(value).Abs().ToString());
BigTests.AreEqual(expected, bigFactory.Big(value).Abs().ToString());
};

Big.DP = 20;
Big.RM = RoundingMode.ROUND_HALF_UP;
bigFactory.Config.DP = 20;
bigFactory.Config.RM = RoundingMode.ROUND_HALF_UP;

t(1, 1);
t(1, -1);
Expand All @@ -48,23 +42,22 @@ public void Abs()
t(123456.7891011, -123456.7891011);
t(999.999, "-999.999");
t(99, 99);
t(1, new Big(-1));
t(0.001, new Big(0.001));
t(0.001, new Big("-0.001"));
t(1, bigFactory.Big(-1));
t(0.001, bigFactory.Big(0.001));
t(0.001, bigFactory.Big("-0.001"));
t(0, 0);
t(0, -0);
t(0, "-0");

var minusZero = 1 / double.NegativeInfinity;

t(0, 0);
t(0, -0);
t(0, "-0");
t(0, minusZero);

BigTests.IsNegativeZero(new Big("-0"));
BigTests.IsNegativeZero(new Big(minusZero));
BigTests.IsPositiveZero(new Big(-0).Abs());
BigTests.IsPositiveZero(new Big("-0").Abs());
BigTests.IsPositiveZero(new Big(minusZero).Abs());
BigTests.IsNegativeZero(bigFactory.Big("-0"));
BigTests.IsNegativeZero(bigFactory.Big(minusZero));
BigTests.IsPositiveZero(bigFactory.Big("-0").Abs());
BigTests.IsPositiveZero(bigFactory.Big(minusZero).Abs());

t(5e-324, 5e-324);
t(5e-324, -5e-324);
Expand Down
368 changes: 182 additions & 186 deletions BigSharp.Tests/BigCmpEqGtGteLtLteTests.cs

Large diffs are not rendered by default.

Loading

0 comments on commit 8cbacf2

Please sign in to comment.