Browse Source

fixed ToString and added missing tests

Signed-off-by: Marcus Cuda <marcus@cuda.net>
pull/2/head
Marcus Cuda 17 years ago
parent
commit
8b9e92fac3
  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 public class ComplexTest
{ {
[Test, MultipleAsserts] [Test, MultipleAsserts]
public void CanCreateAComplexNumberUsingTheConstructor() public void CanCreateComplexNumberUsingTheConstructor()
{ {
var complex = new Complex(1.1, -2.2); var complex = new Complex(1.1, -2.2);
AssertEx.That(() => complex.Real == 1.1, "Real Part"); Assert.AreEqual(complex.Real, 1.1, "Real part is 1.1");
AssertEx.That(() => complex.Imaginary == -2.2, "Imaginary Part"); 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> /// <value><c>true</c> if this instance is I; otherwise, <c>false</c>.</value>
public bool IsI public bool IsI
{ {
get { throw new NotImplementedException(); } // return Number.AlmostZero(real) && Number.AlmostEqual(imag, 1); } get { return _real.AlmostZero() && _imag.AlmostEqual(1); }
} }
/// <summary> /// <summary>
@ -239,7 +239,7 @@ namespace MathNet.Numerics
/// <value><c>true</c> if this instance is NaN; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is NaN; otherwise, <c>false</c>.</value>
public bool IsNaN public bool IsNaN
{ {
get { throw new NotImplementedException(); } // return double.IsNaN(real) || double.IsNaN(imag); } get { return double.IsNaN(_real) || double.IsNaN(_imag); }
} }
/// <summary> /// <summary>
@ -264,7 +264,7 @@ namespace MathNet.Numerics
/// <value><c>true</c> if this instance is a real number; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is a real number; otherwise, <c>false</c>.</value>
public bool IsReal public bool IsReal
{ {
get { throw new NotImplementedException(); } // return Number.AlmostZero(imag); } get { return _imag.AlmostZero(); }
} }
/// <summary> /// <summary>
@ -275,7 +275,7 @@ namespace MathNet.Numerics
/// </value> /// </value>
public bool IsRealNonNegative public bool IsRealNonNegative
{ {
get { throw new NotImplementedException(); } // return Number.AlmostZero(imag) && real >= 0; } get { return _imag.AlmostZero() && _real >= 0; }
} }
/// <summary> /// <summary>
@ -286,7 +286,7 @@ namespace MathNet.Numerics
/// </value> /// </value>
public bool IsImaginary public bool IsImaginary
{ {
get { throw new NotImplementedException(); } // return Number.AlmostZero(real); } get { return _real.AlmostZero(); }
} }
#region Static Initializers #region Static Initializers

Loading…
Cancel
Save