Skip to content

Commit 69eeeb0

Browse files
committed
Add net8.0 target and update tests to NUnit 4.
1 parent 4ebafb8 commit 69eeeb0

23 files changed

+316
-327
lines changed

CSparse.Tests/CSparse.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
@@ -41,7 +41,7 @@
4141
</ItemGroup>
4242

4343
<ItemGroup>
44-
<PackageReference Include="NUnit" Version="3.14.0" />
44+
<PackageReference Include="NUnit" Version="4.0.1" />
4545
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
4646
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
4747
</ItemGroup>

CSparse.Tests/Complex/DenseMatrixTest.cs

+27-27
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public void TestL1Norm()
2424
var actual = A.L1Norm();
2525
var expected = 2.0;
2626

27-
Assert.AreEqual(expected, actual);
27+
Assert.That(actual, Is.EqualTo(expected));
2828

2929
var data = MatrixHelper.LoadDense(2, 2);
3030

3131
actual = data.A.L1Norm();
3232
expected = 6.0;
3333

34-
Assert.AreEqual(expected, actual);
34+
Assert.That(actual, Is.EqualTo(expected));
3535
}
3636

3737
[Test]
@@ -42,14 +42,14 @@ public void TestInfinityNorm()
4242
var actual = A.InfinityNorm();
4343
var expected = 2.0;
4444

45-
Assert.AreEqual(expected, actual);
45+
Assert.That(actual, Is.EqualTo(expected));
4646

4747
var data = MatrixHelper.LoadDense(2, 2);
4848

4949
actual = data.A.InfinityNorm();
5050
expected = 7.0;
5151

52-
Assert.AreEqual(expected, actual);
52+
Assert.That(actual, Is.EqualTo(expected));
5353
}
5454

5555
[Test]
@@ -60,14 +60,14 @@ public void TestFrobeniusNorm()
6060
var actual = A.FrobeniusNorm();
6161
var expected = 6.0;
6262

63-
Assert.AreEqual(expected, actual);
63+
Assert.That(actual, Is.EqualTo(expected));
6464

6565
var data = MatrixHelper.LoadDense(2, 2);
6666

6767
actual = data.A.FrobeniusNorm();
6868
expected = 5.477225575;
6969

70-
Assert.AreEqual(expected, actual);
70+
Assert.That(actual, Is.EqualTo(expected));
7171
}
7272

7373
[TestCase(2, 2)]
@@ -84,7 +84,7 @@ public void TestGetRow(int rows, int columns)
8484

8585
for (int j = 0; j < columns; j++)
8686
{
87-
Assert.AreEqual(A.At(i, j), y[j]);
87+
Assert.That(y[j], Is.EqualTo(A.At(i, j)));
8888
}
8989
}
9090
}
@@ -103,7 +103,7 @@ public void TestGetColumn(int rows, int columns)
103103

104104
for (int i = 0; i < rows; i++)
105105
{
106-
Assert.AreEqual(A.At(i, j), y[i]);
106+
Assert.That(y[i], Is.EqualTo(A.At(i, j)));
107107
}
108108
}
109109
}
@@ -125,7 +125,7 @@ public void TestSetRow(int rows, int columns)
125125

126126
for (int j = 0; j < columns; j++)
127127
{
128-
Assert.AreEqual(x, A.At(i, j));
128+
Assert.That(A.At(i, j), Is.EqualTo(x));
129129
}
130130
}
131131
}
@@ -147,7 +147,7 @@ public void TestSetColumn(int rows, int columns)
147147

148148
for (int i = 0; i < rows; i++)
149149
{
150-
Assert.AreEqual(x, A.At(i, j));
150+
Assert.That(A.At(i, j), Is.EqualTo(x));
151151
}
152152
}
153153
}
@@ -165,7 +165,7 @@ public void TestMatrixVectorMultiply(int rows, int columns)
165165

166166
A.Multiply(x, actual);
167167

168-
CollectionAssert.AreEqual(data.Ax, actual);
168+
Assert.That(actual, Is.EqualTo(data.Ax).AsCollection);
169169
}
170170

171171
[TestCase(2, 2)]
@@ -181,13 +181,13 @@ public void TestMatrixVectorTransposeMultiply(int rows, int columns)
181181

182182
A.TransposeMultiply(y, actual);
183183

184-
CollectionAssert.AreEqual(data.ATy, actual);
184+
Assert.That(actual, Is.EqualTo(data.ATy).AsCollection);
185185

186186
var AT = data.AT;
187187

188188
AT.Multiply(y, actual);
189189

190-
CollectionAssert.AreEqual(data.ATy, actual);
190+
Assert.That(actual, Is.EqualTo(data.ATy).AsCollection);
191191
}
192192

193193
[TestCase(2, 2)]
@@ -203,7 +203,7 @@ public void TestMatrixVectorMultiplyUpdate(int rows, int columns)
203203

204204
A.Multiply(1.0, x, 0.0, actual);
205205

206-
CollectionAssert.AreEqual(data.Ax, actual);
206+
Assert.That(actual, Is.EqualTo(data.Ax).AsCollection);
207207
}
208208

209209
[TestCase(2, 2)]
@@ -219,7 +219,7 @@ public void TestMatrixVectorTransposeMultiplyUpdate(int rows, int columns)
219219

220220
A.TransposeMultiply(1.0, y, 0.0, actual);
221221

222-
CollectionAssert.AreEqual(data.ATy, actual);
222+
Assert.That(actual, Is.EqualTo(data.ATy).AsCollection);
223223
}
224224

225225
[TestCase(2, 2)]
@@ -234,8 +234,8 @@ public void TestMatrixTranspose(int rows, int columns)
234234
var actualA = A.Transpose();
235235
var actualB = B.Transpose();
236236

237-
CollectionAssert.AreEqual(data.AT.Values, actualA.Values);
238-
CollectionAssert.AreEqual(data.BT.Values, actualB.Values);
237+
Assert.That(actualA.Values, Is.EqualTo(data.AT.Values).AsCollection);
238+
Assert.That(actualB.Values, Is.EqualTo(data.BT.Values).AsCollection);
239239
}
240240

241241
[TestCase(2, 2)]
@@ -249,7 +249,7 @@ public void TestMatrixSum(int rows, int columns)
249249

250250
var actual = A.Add(B);
251251

252-
CollectionAssert.AreEqual(data.ApB.Values, actual.Values);
252+
Assert.That(actual.Values, Is.EqualTo(data.ApB.Values).AsCollection);
253253
}
254254

255255
[TestCase(2, 2)]
@@ -266,11 +266,11 @@ public void TestMatrixMultiply(int rows, int columns)
266266

267267
var actual = AT.Multiply(B);
268268

269-
CollectionAssert.AreEqual(data.ATmB.Values, actual.Values, ComplexNumberComparer.Default);
269+
Assert.That(actual.Values, Is.EqualTo(data.ATmB.Values).Using<Complex>(ComplexNumberComparer.Default));
270270

271271
actual = A.Multiply(BT);
272272

273-
CollectionAssert.AreEqual(data.AmBT.Values, actual.Values, ComplexNumberComparer.Default);
273+
Assert.That(actual.Values, Is.EqualTo(data.AmBT.Values).Using<Complex>(ComplexNumberComparer.Default));
274274
}
275275

276276
[Test]
@@ -298,7 +298,7 @@ public void TestMatrixPointwiseMultiply()
298298

299299
A.PointwiseMultiply(B, actual);
300300

301-
CollectionAssert.AreEqual(expected.Values, actual.Values);
301+
Assert.That(actual.Values, Is.EqualTo(expected.Values).AsCollection);
302302

303303
// Test exceptions:
304304

@@ -329,7 +329,7 @@ public void TestMatrixParallelMultiply()
329329
}
330330
}
331331
var A = DenseMatrix.OfColumnMajor(120, 120, values);
332-
CollectionAssert.AreEqual(A.Multiply(A).Values, A.ParallelMultiply(A).Values);
332+
Assert.That(A.ParallelMultiply(A).Values, Is.EqualTo(A.Multiply(A).Values).AsCollection);
333333
}
334334

335335
#region Matrix creation
@@ -343,7 +343,7 @@ public void TestOfMatrix(int rows, int columns)
343343
var denseA = denseData.A;
344344
var denseB = DenseMatrix.OfMatrix(denseA);
345345

346-
Assert.IsTrue(denseA.Equals(denseB));
346+
Assert.That(denseA.Equals(denseB), Is.True);
347347
}
348348

349349
[TestCase(2, 2)]
@@ -354,7 +354,7 @@ public void TestOfIndexed(int rows, int columns)
354354
var denseA = denseData.A;
355355
var denseB = DenseMatrix.OfIndexed(rows, columns, denseA.EnumerateIndexed());
356356

357-
Assert.IsTrue(denseA.Equals(denseB));
357+
Assert.That(denseA.Equals(denseB), Is.True);
358358
}
359359

360360
[TestCase(2, 2)]
@@ -365,7 +365,7 @@ public void TestOfColumnMajor(int rows, int columns)
365365
var denseA = denseData.A;
366366
var denseB = DenseMatrix.OfColumnMajor(rows, columns, denseA.Values);
367367

368-
Assert.IsTrue(denseA.Equals(denseB));
368+
Assert.That(denseA.Equals(denseB), Is.True);
369369
}
370370

371371
[Test]
@@ -380,7 +380,7 @@ public void TestOfDiagonalArray()
380380

381381
for (int i = 0; i < order; i++)
382382
{
383-
Assert.AreEqual(A.At(i, i), a);
383+
Assert.That(a, Is.EqualTo(A.At(i, i)));
384384
}
385385
}
386386

@@ -393,7 +393,7 @@ public void TestCreateIdentity()
393393

394394
for (int i = 0; i < order; i++)
395395
{
396-
Assert.AreEqual(A.At(i, i), Complex.One);
396+
Assert.That(Complex.One, Is.EqualTo(A.At(i, i)));
397397
}
398398
}
399399

CSparse.Tests/Complex/Factorization/SparseCholeskyTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void TestSolve()
2929
// Compute residual r = b - Ax.
3030
A.Multiply(-1.0, x, 1.0, r);
3131

32-
Assert.IsTrue(Vector.Norm(r.Length, r) < EPS);
32+
Assert.That(Vector.Norm(r.Length, r) < EPS, Is.True);
3333
}
3434

3535
[Test]
@@ -51,8 +51,8 @@ public void TestEmptyFactorize()
5151

5252
var chol = SparseCholesky.Create(A, ColumnOrdering.MinimumDegreeAtPlusA);
5353

54-
Assert.NotNull(chol);
55-
Assert.IsTrue(chol.NonZerosCount == 0);
54+
Assert.That(chol, Is.Not.Null);
55+
Assert.That(chol.NonZerosCount == 0, Is.True);
5656
}
5757
}
5858
}

CSparse.Tests/Complex/Factorization/SparseLDLTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void TestSolve()
3030
// Compute residual r = b - Ax.
3131
A.Multiply(-1.0, x, 1.0, r);
3232

33-
Assert.IsTrue(Vector.Norm(r.Length, r) < EPS);
33+
Assert.That(Vector.Norm(r.Length, r) < EPS, Is.True);
3434
}
3535

3636
[Test]
@@ -52,7 +52,7 @@ public void TestSolveNonSpd()
5252
// Compute residual r = b - Ax.
5353
A.Multiply(-1.0, x, 1.0, r);
5454

55-
Assert.IsTrue(Vector.Norm(r.Length, r) < EPS);
55+
Assert.That(Vector.Norm(r.Length, r) < EPS, Is.True);
5656
}
5757
}
5858
}

CSparse.Tests/Complex/Factorization/SparseLUTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void TestSolve()
2929
// Compute residual r = b - Ax.
3030
A.Multiply(-1.0, x, 1.0, r);
3131

32-
Assert.IsTrue(Vector.Norm(r.Length, r) < EPS);
32+
Assert.That(Vector.Norm(r.Length, r) < EPS, Is.True);
3333
}
3434

3535
[Test]
@@ -54,7 +54,7 @@ public void TestSolveTranspose()
5454
// Compute residual r = b - A'x.
5555
AT.Multiply(-1.0, x, 1.0, r);
5656

57-
Assert.IsTrue(Vector.Norm(r.Length, r) < EPS);
57+
Assert.That(Vector.Norm(r.Length, r) < EPS, Is.True);
5858
}
5959

6060
[Test]
@@ -64,8 +64,8 @@ public void TestEmptyFactorize()
6464

6565
var lu = SparseLU.Create(A, ColumnOrdering.MinimumDegreeAtPlusA, 1.0);
6666

67-
Assert.NotNull(lu);
68-
Assert.IsTrue(lu.NonZerosCount == 0);
67+
Assert.That(lu, Is.Not.Null);
68+
Assert.That(lu.NonZerosCount == 0, Is.True);
6969
}
7070
}
7171
}

0 commit comments

Comments
 (0)