Skip to content

Commit 389b47e

Browse files
committed
Fix tests
1 parent a296878 commit 389b47e

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

Tests/Core/SparseArrayTests.cs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,40 @@ namespace Tests.Core
1313
[TestClass]
1414
public class SparseArrayTests
1515
{
16+
[TestMethod]
17+
public void DirectOrderShouldWorkCorrectlyInFlatMode()
18+
{
19+
var sparseArray = new SparseArray<int>();
20+
21+
unchecked
22+
{
23+
for (var i = 0; i <= 128; i++)
24+
sparseArray[i] = i;
25+
}
26+
27+
var output = sparseArray.ForwardOrder.ToArray();
28+
for (var i = 0; i <= 128; i++)
29+
Assert.AreEqual(i, output[i].Value);
30+
}
31+
32+
[TestMethod]
33+
public void RebuildToSparseShouldWorkCorrectly()
34+
{
35+
var sparseArray = new SparseArray<int>();
36+
37+
unchecked
38+
{
39+
for (var i = 0; i < 128; i++)
40+
{
41+
var v = (i * 67) % 128;
42+
sparseArray[v] = v;
43+
}
44+
}
45+
46+
for (var i = 0; i < 128; i++)
47+
Assert.AreEqual(i, sparseArray[i]);
48+
}
49+
1650
[TestMethod]
1751
public void DirectOrderShouldWorkCorrectlyInSparseMode()
1852
{
@@ -38,13 +72,25 @@ public void DirectOrderShouldWorkCorrectlyInSparseMode2()
3872
{
3973
sparseArray[0] = 1;
4074
sparseArray[1] = 2;
75+
sparseArray[2] = 3;
76+
sparseArray[3] = 4;
77+
sparseArray[4] = 5;
78+
sparseArray[5] = 6;
79+
sparseArray[6] = 7;
80+
sparseArray[7] = 8;
4181
sparseArray[10000] = 10000;
4282
}
4383

4484
var output = sparseArray.ForwardOrder.ToArray();
4585
Assert.AreEqual(1, output[0].Value);
4686
Assert.AreEqual(2, output[1].Value);
47-
Assert.AreEqual(10000, output[2].Value);
87+
Assert.AreEqual(3, output[2].Value);
88+
Assert.AreEqual(4, output[3].Value);
89+
Assert.AreEqual(5, output[4].Value);
90+
Assert.AreEqual(6, output[5].Value);
91+
Assert.AreEqual(7, output[6].Value);
92+
Assert.AreEqual(8, output[7].Value);
93+
Assert.AreEqual(10000, output[8].Value);
4894
}
4995

5096
[TestMethod]

0 commit comments

Comments
 (0)