Example #1
0
        /// <summary>
        /// Asserts that the expected value and the actual value are equal.
        /// </summary>
        /// <param name="expected">The expected value.</param>
        /// <param name="actual">The actual value.</param>
        public static void AreEqual(Complex32 expected, Complex32 actual)
        {
            if (expected.IsNaN() && actual.IsNaN())
            {
                return;
            }

            if (expected.IsInfinity() && expected.IsInfinity())
            {
                return;
            }

            bool pass = expected.Real.AlmostEqual(actual.Real);

            if (!pass)
            {
                Assert.Fail("Real components are not equal. Expected:{0}; Actual:{1}", expected.Real, actual.Real);
            }

            pass = expected.Imaginary.AlmostEqual(actual.Imaginary);
            if (!pass)
            {
                Assert.Fail("Imaginary components are not equal. Expected:{0}; Actual:{1}", expected.Imaginary, actual.Imaginary);
            }
        }
Example #2
0
        public static void AlmostEqual(Complex32 expected, Complex32 actual)
        {
            if (expected.IsNaN() && actual.IsNaN() || expected.IsInfinity() && expected.IsInfinity())
            {
                return;
            }

            if (!expected.Real.AlmostEqual(actual.Real))
            {
                Assert.Fail("Real components are not equal. Expected:{0}; Actual:{1}", expected.Real, actual.Real);
            }

            if (!expected.Imaginary.AlmostEqual(actual.Imaginary))
            {
                Assert.Fail("Imaginary components are not equal. Expected:{0}; Actual:{1}", expected.Imaginary, actual.Imaginary);
            }
        }
Example #3
0
        public void CanDetermineIfInfinity()
        {
            var complex = new Complex32(float.PositiveInfinity, 1);

            Assert.IsTrue(complex.IsInfinity(), "Real part is infinity.");
            complex = new Complex32(1, float.NegativeInfinity);
            Assert.IsTrue(complex.IsInfinity(), "Imaginary part is infinity.");
            complex = new Complex32(float.NegativeInfinity, float.PositiveInfinity);
            Assert.IsTrue(complex.IsInfinity(), "Both parts are infinity.");
        }
 public void CanDetermineIfInfinity()
 {
     var complex = new Complex32(float.PositiveInfinity, 1);
     Assert.IsTrue(complex.IsInfinity(), "Real part is infinity.");
     complex = new Complex32(1, float.NegativeInfinity);
     Assert.IsTrue(complex.IsInfinity(), "Imaginary part is infinity.");
     complex = new Complex32(float.NegativeInfinity, float.PositiveInfinity);
     Assert.IsTrue(complex.IsInfinity(), "Both parts are infinity.");
 }