diff --git a/X10D.Tests/src/Core/DoubleTests.cs b/X10D.Tests/src/Core/DoubleTests.cs index c421cc5..d0bedcf 100644 --- a/X10D.Tests/src/Core/DoubleTests.cs +++ b/X10D.Tests/src/Core/DoubleTests.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Numerics; namespace X10D.Tests.Core; @@ -11,6 +12,22 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class DoubleTests { + [TestMethod] + public void ComplexSqrt() + { + Assert.AreEqual(0.0, 0.0.ComplexSqrt()); + Assert.AreEqual(1.414213562373095, 2.0.ComplexSqrt()); + Assert.AreEqual(3.0, 9.0.ComplexSqrt()); + Assert.AreEqual(4.0, 16.0.ComplexSqrt()); + Assert.AreEqual(new Complex(1.414213562373095, 1), (-2.0).ComplexSqrt()); + Assert.AreEqual(new Complex(3.0, 1), (-9.0).ComplexSqrt()); + Assert.AreEqual(new Complex(4.0, 1), (-16.0).ComplexSqrt()); + Assert.AreEqual(Complex.NaN, double.NaN.ComplexSqrt()); + Assert.AreEqual(new Complex(1, 1), (-1.0).ComplexSqrt()); + Assert.AreEqual(Complex.Infinity, double.NegativeInfinity.ComplexSqrt()); + Assert.AreEqual(Complex.Infinity, double.PositiveInfinity.ComplexSqrt()); + } + /// /// Test for /// diff --git a/X10D.Tests/src/Core/SingleTests.cs b/X10D.Tests/src/Core/SingleTests.cs index 212e2e6..87db537 100644 --- a/X10D.Tests/src/Core/SingleTests.cs +++ b/X10D.Tests/src/Core/SingleTests.cs @@ -1,10 +1,27 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Numerics; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace X10D.Tests.Core; [TestClass] public class SingleTests { + [TestMethod] + public void ComplexSqrt() + { + Assert.AreEqual(0.0f, 0.0f.ComplexSqrt()); + Assert.AreEqual(1.4142135f, 2.0f.ComplexSqrt()); + Assert.AreEqual(3.0f, 9.0f.ComplexSqrt()); + Assert.AreEqual(4.0f, 16.0f.ComplexSqrt()); + Assert.AreEqual(new Complex(1.4142135f, 1), (-2.0f).ComplexSqrt()); + Assert.AreEqual(new Complex(3.0f, 1), (-9.0f).ComplexSqrt()); + Assert.AreEqual(new Complex(4.0f, 1), (-16.0f).ComplexSqrt()); + Assert.AreEqual(Complex.NaN, float.NaN.ComplexSqrt()); + Assert.AreEqual(new Complex(1, 1), (-1.0f).ComplexSqrt()); + Assert.AreEqual(Complex.Infinity, float.NegativeInfinity.ComplexSqrt()); + Assert.AreEqual(Complex.Infinity, float.PositiveInfinity.ComplexSqrt()); + } + [TestMethod] public void DegreesToRadians() {