Browse Source

fixed ToString and added missing tests

Signed-off-by: Marcus Cuda <marcus@cuda.net>
pull/36/head
Marcus Cuda 17 years ago
parent
commit
fdfdd07e7b
  1. 6
      src/Managed.UnitTests/ComplexTest.cs
  2. 10
      src/Managed/Complex.cs

6
src/Managed.UnitTests/ComplexTest.cs

@ -6,11 +6,11 @@
public class ComplexTest
{
[Test, MultipleAsserts]
public void CanCreateAComplexNumberUsingTheConstructor()
public void CanCreateComplexNumberUsingTheConstructor()
{
var complex = new Complex(1.1, -2.2);
AssertEx.That(() => complex.Real == 1.1, "Real Part");
AssertEx.That(() => complex.Imaginary == -2.2, "Imaginary Part");
Assert.AreEqual(complex.Real, 1.1, "Real part is 1.1");
Assert.AreEqual(complex.Imaginary, -2.2, "Imaginary part is -2.2");
}
}
}

10
src/Managed/Complex.cs

@ -229,7 +229,7 @@ namespace MathNet.Numerics
/// <value><c>true</c> if this instance is I; otherwise, <c>false</c>.</value>
public bool IsI
{
get { throw new NotImplementedException(); } // return Number.AlmostZero(real) && Number.AlmostEqual(imag, 1); }
get { return _real.AlmostZero() && _imag.AlmostEqual(1); }
}
/// <summary>
@ -239,7 +239,7 @@ namespace MathNet.Numerics
/// <value><c>true</c> if this instance is NaN; otherwise, <c>false</c>.</value>
public bool IsNaN
{
get { throw new NotImplementedException(); } // return double.IsNaN(real) || double.IsNaN(imag); }
get { return double.IsNaN(_real) || double.IsNaN(_imag); }
}
/// <summary>
@ -264,7 +264,7 @@ namespace MathNet.Numerics
/// <value><c>true</c> if this instance is a real number; otherwise, <c>false</c>.</value>
public bool IsReal
{
get { throw new NotImplementedException(); } // return Number.AlmostZero(imag); }
get { return _imag.AlmostZero(); }
}
/// <summary>
@ -275,7 +275,7 @@ namespace MathNet.Numerics
/// </value>
public bool IsRealNonNegative
{
get { throw new NotImplementedException(); } // return Number.AlmostZero(imag) && real >= 0; }
get { return _imag.AlmostZero() && _real >= 0; }
}
/// <summary>
@ -286,7 +286,7 @@ namespace MathNet.Numerics
/// </value>
public bool IsImaginary
{
get { throw new NotImplementedException(); } // return Number.AlmostZero(real); }
get { return _real.AlmostZero(); }
}
#region Static Initializers

Loading…
Cancel
Save