Skip to content

Commit 4e8af8b

Browse files
committed
refactor(tests): migrate np.where and np.asanyarray tests from TUnit to MSTest v3
Post-rebase cleanup after master migrated the test suite from TUnit to MSTest v3 (commits ac02033, e0db3c3). The 4 test files introduced on this branch still used TUnit's [Test] attribute and `using TUnit.Core;`, which broke the build. Changes per file: - Replace `using TUnit.Core;` (removed) - Add `[TestClass]` attribute to the test class - Replace all `[Test]` attributes with `[TestMethod]` Files migrated: - test/NumSharp.UnitTest/Logic/np.where.Test.cs - test/NumSharp.UnitTest/Logic/np.where.BattleTest.cs - test/NumSharp.UnitTest/Backends/Kernels/WhereSimdTests.cs - test/NumSharp.UnitTest/Creation/np.asanyarray.Tests.cs Verified: all 112 np.where tests and 62 np.asanyarray tests pass on net8.0 and net10.0.
1 parent 44dd163 commit 4e8af8b

4 files changed

Lines changed: 178 additions & 177 deletions

File tree

test/NumSharp.UnitTest/Backends/Kernels/WhereSimdTests.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Diagnostics;
33
using NumSharp.Backends.Kernels;
4-
using TUnit.Core;
54
using NumSharp.UnitTest.Utilities;
65
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
76

@@ -11,11 +10,12 @@ namespace NumSharp.UnitTest.Backends.Kernels
1110
/// Tests for SIMD-optimized np.where implementation.
1211
/// Verifies correctness of the SIMD path for all supported dtypes.
1312
/// </summary>
13+
[TestClass]
1414
public class WhereSimdTests
1515
{
1616
#region SIMD Correctness
1717

18-
[Test]
18+
[TestMethod]
1919
public void Where_Simd_Float32_Correctness()
2020
{
2121
var rng = np.random.RandomState(42);
@@ -34,7 +34,7 @@ public void Where_Simd_Float32_Correctness()
3434
}
3535
}
3636

37-
[Test]
37+
[TestMethod]
3838
public void Where_Simd_Float64_Correctness()
3939
{
4040
var rng = np.random.RandomState(43);
@@ -52,7 +52,7 @@ public void Where_Simd_Float64_Correctness()
5252
}
5353
}
5454

55-
[Test]
55+
[TestMethod]
5656
public void Where_Simd_Int32_Correctness()
5757
{
5858
var rng = np.random.RandomState(44);
@@ -70,7 +70,7 @@ public void Where_Simd_Int32_Correctness()
7070
}
7171
}
7272

73-
[Test]
73+
[TestMethod]
7474
public void Where_Simd_Int64_Correctness()
7575
{
7676
var rng = np.random.RandomState(45);
@@ -88,7 +88,7 @@ public void Where_Simd_Int64_Correctness()
8888
}
8989
}
9090

91-
[Test]
91+
[TestMethod]
9292
public void Where_Simd_Byte_Correctness()
9393
{
9494
var rng = np.random.RandomState(46);
@@ -106,7 +106,7 @@ public void Where_Simd_Byte_Correctness()
106106
}
107107
}
108108

109-
[Test]
109+
[TestMethod]
110110
public void Where_Simd_Int16_Correctness()
111111
{
112112
var rng = np.random.RandomState(47);
@@ -124,7 +124,7 @@ public void Where_Simd_Int16_Correctness()
124124
}
125125
}
126126

127-
[Test]
127+
[TestMethod]
128128
public void Where_Simd_UInt16_Correctness()
129129
{
130130
var rng = np.random.RandomState(48);
@@ -142,7 +142,7 @@ public void Where_Simd_UInt16_Correctness()
142142
}
143143
}
144144

145-
[Test]
145+
[TestMethod]
146146
public void Where_Simd_UInt32_Correctness()
147147
{
148148
var rng = np.random.RandomState(49);
@@ -160,7 +160,7 @@ public void Where_Simd_UInt32_Correctness()
160160
}
161161
}
162162

163-
[Test]
163+
[TestMethod]
164164
public void Where_Simd_UInt64_Correctness()
165165
{
166166
var rng = np.random.RandomState(50);
@@ -178,7 +178,7 @@ public void Where_Simd_UInt64_Correctness()
178178
}
179179
}
180180

181-
[Test]
181+
[TestMethod]
182182
public void Where_Simd_Boolean_Correctness()
183183
{
184184
var rng = np.random.RandomState(51);
@@ -196,7 +196,7 @@ public void Where_Simd_Boolean_Correctness()
196196
}
197197
}
198198

199-
[Test]
199+
[TestMethod]
200200
public void Where_Simd_Char_Correctness()
201201
{
202202
var rng = np.random.RandomState(52);
@@ -225,7 +225,7 @@ public void Where_Simd_Char_Correctness()
225225

226226
#region Path Selection
227227

228-
[Test]
228+
[TestMethod]
229229
public void Where_NonContiguous_Works()
230230
{
231231
// Sliced arrays are non-contiguous, should work correctly
@@ -244,7 +244,7 @@ public void Where_NonContiguous_Works()
244244
}
245245
}
246246

247-
[Test]
247+
[TestMethod]
248248
public void Where_Broadcast_Works()
249249
{
250250
// Broadcasted arrays
@@ -265,7 +265,7 @@ public void Where_Broadcast_Works()
265265
Assert.AreEqual(20, (int)result[1, 1]); // cond[1]=false -> y=20
266266
}
267267

268-
[Test]
268+
[TestMethod]
269269
public void Where_Decimal_Works()
270270
{
271271
var cond = np.array(new[] { true, false, true });
@@ -280,7 +280,7 @@ public void Where_Decimal_Works()
280280
Assert.AreEqual(3.3m, (decimal)result[2]);
281281
}
282282

283-
[Test]
283+
[TestMethod]
284284
public void Where_NonBoolCondition_Works()
285285
{
286286
// Non-bool condition requires truthiness check
@@ -294,7 +294,7 @@ public void Where_NonBoolCondition_Works()
294294

295295
#region Edge Cases
296296

297-
[Test]
297+
[TestMethod]
298298
public void Where_Simd_SmallArray()
299299
{
300300
// Array smaller than vector width
@@ -307,7 +307,7 @@ public void Where_Simd_SmallArray()
307307
result.Should().BeOfValues(1, 20, 3);
308308
}
309309

310-
[Test]
310+
[TestMethod]
311311
public void Where_Simd_VectorAlignedSize()
312312
{
313313
var rng = np.random.RandomState(53);
@@ -327,7 +327,7 @@ public void Where_Simd_VectorAlignedSize()
327327
}
328328
}
329329

330-
[Test]
330+
[TestMethod]
331331
public void Where_Simd_WithScalarTail()
332332
{
333333
// Size that requires scalar tail processing
@@ -344,7 +344,7 @@ public void Where_Simd_WithScalarTail()
344344
}
345345
}
346346

347-
[Test]
347+
[TestMethod]
348348
public void Where_Simd_AllTrue()
349349
{
350350
var size = 100;
@@ -360,7 +360,7 @@ public void Where_Simd_AllTrue()
360360
}
361361
}
362362

363-
[Test]
363+
[TestMethod]
364364
public void Where_Simd_AllFalse()
365365
{
366366
var size = 100;
@@ -376,7 +376,7 @@ public void Where_Simd_AllFalse()
376376
}
377377
}
378378

379-
[Test]
379+
[TestMethod]
380380
public void Where_Simd_Alternating()
381381
{
382382
var size = 100;
@@ -395,7 +395,7 @@ public void Where_Simd_Alternating()
395395
}
396396
}
397397

398-
[Test]
398+
[TestMethod]
399399
public void Where_Simd_NaN_Propagates()
400400
{
401401
var cond = np.array(new[] { true, false, true });
@@ -409,7 +409,7 @@ public void Where_Simd_NaN_Propagates()
409409
Assert.AreEqual(2.0, (double)result[2], 1e-10);
410410
}
411411

412-
[Test]
412+
[TestMethod]
413413
public void Where_Simd_Infinity()
414414
{
415415
var cond = np.array(new[] { true, false, true, false });
@@ -428,7 +428,7 @@ public void Where_Simd_Infinity()
428428

429429
#region Performance Sanity Check
430430

431-
[Test]
431+
[TestMethod]
432432
public void Where_Simd_LargeArray_Correctness()
433433
{
434434
var rng = np.random.RandomState(54);
@@ -458,7 +458,7 @@ public void Where_Simd_LargeArray_Correctness()
458458

459459
#region 2D/Multi-dimensional
460460

461-
[Test]
461+
[TestMethod]
462462
public void Where_Simd_2D_Contiguous()
463463
{
464464
var rng = np.random.RandomState(55);
@@ -483,7 +483,7 @@ public void Where_Simd_2D_Contiguous()
483483
}
484484
}
485485

486-
[Test]
486+
[TestMethod]
487487
public void Where_Simd_3D_Contiguous()
488488
{
489489
var rng = np.random.RandomState(56);

0 commit comments

Comments
 (0)