Browse Source

Negate unit tests.

la-knuth
Jurgen Van Gael 17 years ago
parent
commit
e9d8de0631
  1. 73
      src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs
  2. 2
      src/UnitTests/LinearAlgebraTests/Double/MatrixTests.cs

73
src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs

@ -478,5 +478,78 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
}
[Test]
[Row("Singular3x3")]
[Row("Square3x3")]
[Row("Square4x4")]
[Row("Tall3x2")]
[Row("Wide2x3")]
[MultipleAsserts]
public void CanNegate(string name)
{
var matrix = testMatrices[name];
var copy = matrix.Clone();
copy.Negate();
for (int i = 0; i < matrix.RowCount; i++)
{
for (int j = 0; j < matrix.ColumnCount; j++)
{
Assert.AreEqual(-matrix[i, j], copy[i, j]);
}
}
}
[Test]
[Row("Singular3x3")]
[Row("Square3x3")]
[Row("Square4x4")]
[Row("Tall3x2")]
[Row("Wide2x3")]
[MultipleAsserts]
public void CanNegateIntoResult(string name)
{
var matrix = testMatrices[name];
var copy = matrix.Clone();
matrix.Negate(copy);
for (int i = 0; i < matrix.RowCount; i++)
{
for (int j = 0; j < matrix.ColumnCount; j++)
{
Assert.AreEqual(-matrix[i, j], copy[i, j]);
}
}
}
[Test]
[ExpectedArgumentNullException]
public void NegateIntoResultFailsWhenResultIsNull()
{
var matrix = testMatrices["Singular3x3"];
Matrix copy = null;
matrix.Negate(copy);
}
[Test]
[ExpectedArgumentException]
public void NegateIntoResultFailsWhenResultHasMoreRows()
{
Matrix matrix = testMatrices["Singular3x3"];
Matrix target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
matrix.Negate(target);
}
[Test]
[ExpectedArgumentException]
public void NegateIntoResultFailsWhenResultHasMoreColumns()
{
Matrix matrix = testMatrices["Singular3x3"];
Matrix target = CreateMatrix(matrix.RowCount + 1, matrix.ColumnCount);
matrix.Negate(target);
}
}
}

2
src/UnitTests/LinearAlgebraTests/Double/MatrixTests.cs

@ -107,7 +107,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
[ExpectedArgumentNullException]
public void CopyToFailsWhenTargetIsNull()
{
Matrix matrix = testMatrices["Singular3x3"];

Loading…
Cancel
Save