From 9b9b75ae5bb83533bcbf69eb2db50dfcd4ff0b44 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 21 Apr 2022 12:20:19 +0100 Subject: [PATCH] Add Sqrt tests --- X10D.Tests/src/Core/DoubleTests.cs | 13 +++++++++++++ X10D.Tests/src/Core/SingleTests.cs | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/X10D.Tests/src/Core/DoubleTests.cs b/X10D.Tests/src/Core/DoubleTests.cs index a815f42..c421cc5 100644 --- a/X10D.Tests/src/Core/DoubleTests.cs +++ b/X10D.Tests/src/Core/DoubleTests.cs @@ -102,4 +102,17 @@ public class DoubleTests Assert.AreEqual(5.0, 7.0.Round(5)); Assert.AreEqual(10.0, 7.5.Round(5)); } + + [TestMethod] + public void Sqrt() + { + Assert.AreEqual(0.0, 0.0.Sqrt()); + Assert.AreEqual(1.414213562373095, 2.0.Sqrt()); + Assert.AreEqual(3.0, 9.0.Sqrt()); + Assert.AreEqual(4.0, 16.0.Sqrt()); + Assert.AreEqual(double.NaN, double.NaN.Sqrt()); + Assert.AreEqual(double.NaN, (-1.0).Sqrt()); + Assert.AreEqual(double.NaN, double.NegativeInfinity.Sqrt()); + Assert.AreEqual(double.PositiveInfinity, double.PositiveInfinity.Sqrt()); + } } diff --git a/X10D.Tests/src/Core/SingleTests.cs b/X10D.Tests/src/Core/SingleTests.cs index d562e94..212e2e6 100644 --- a/X10D.Tests/src/Core/SingleTests.cs +++ b/X10D.Tests/src/Core/SingleTests.cs @@ -26,4 +26,17 @@ public class SingleTests Assert.AreEqual(6.0f, 0.10471976f.RadiansToDegrees()); Assert.AreEqual(12.0f, 0.20943952f.RadiansToDegrees()); } + + [TestMethod] + public void Sqrt() + { + Assert.AreEqual(0.0f, 0.0f.Sqrt()); + Assert.AreEqual(1.4142135f, 2.0f.Sqrt()); + Assert.AreEqual(3.0f, 9.0f.Sqrt()); + Assert.AreEqual(4.0f, 16.0f.Sqrt()); + Assert.AreEqual(float.NaN, float.NaN.Sqrt()); + Assert.AreEqual(float.NaN, (-1.0f).Sqrt()); + Assert.AreEqual(float.NaN, float.NegativeInfinity.Sqrt()); + Assert.AreEqual(float.PositiveInfinity, float.PositiveInfinity.Sqrt()); + } }