Skip to content

Commit

Permalink
test: add tests for INumber<T>.Sign
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Jun 12, 2024
1 parent e51296d commit d022a71
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions X10D.Tests/src/Numerics/NumberTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if NET7_0_OR_GREATER
using NUnit.Framework;
using X10D.Math;

namespace X10D.Tests.Numerics;

[TestFixture]
internal class NumberTests
{
[Test]
public void Sign_ShouldReturn1_GivenPositiveNumber()
{
Assert.That(NumberExtensions.Sign(2), Is.Positive);
Assert.That(NumberExtensions.Sign(2), Is.EqualTo(1));
}

[Test]
public void Sign_Should0_GivenZero()
{
Assert.That(NumberExtensions.Sign(0), Is.Not.Positive);
Assert.That(NumberExtensions.Sign(0), Is.Not.Negative);
Assert.That(NumberExtensions.Sign(0), Is.EqualTo(0));
}

[Test]
public void Sign_ShouldReturnNegative1_GivenNegativeNumber()
{
Assert.That(NumberExtensions.Sign(-2), Is.Negative);
Assert.That(NumberExtensions.Sign(-2), Is.EqualTo(-1));
}
}
#endif

0 comments on commit d022a71

Please sign in to comment.