Skip to content

Commit 7a65a29

Browse files
committed
Added tests for off-by-one Get[Row|Column] for 2D arrays
1 parent 2745962 commit 7a65a29

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.2D.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public void Test_ArrayExtensions_2D_GetRow_Rectangle()
194194
Assert.AreSame(new int[1, 0].GetRow(0).ToArray(), Array.Empty<int>());
195195

196196
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetRow(-1));
197+
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetRow(3));
197198

198199
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetRow(20));
199200
}
@@ -221,6 +222,7 @@ public void Test_ArrayExtensions_2D_GetColumn_Rectangle()
221222
CollectionAssert.AreEqual(array.GetColumn(1).ToArray(), new[] { 2, 6, 10 });
222223

223224
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetColumn(-1));
225+
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetColumn(4));
224226

225227
Assert.ThrowsException<ArgumentOutOfRangeException>(() => array.GetColumn(20));
226228
}

0 commit comments

Comments
 (0)