From d022a71ce6f6f790f6095deda707729c433b2352 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 12 Jun 2024 13:15:54 +0100 Subject: [PATCH] test: add tests for INumber.Sign --- X10D.Tests/src/Numerics/NumberTests.cs | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 X10D.Tests/src/Numerics/NumberTests.cs diff --git a/X10D.Tests/src/Numerics/NumberTests.cs b/X10D.Tests/src/Numerics/NumberTests.cs new file mode 100644 index 000000000..f5b51275a --- /dev/null +++ b/X10D.Tests/src/Numerics/NumberTests.cs @@ -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