Skip to content

Commit 7499042

Browse files
committed
Fix unit tests for Span<byte>
1 parent 87f7bc6 commit 7499042

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Tests/NFUnitTestTypes/UnitTestsSpanByte.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void RaisingExceptionsOfAllKindsTests()
4242
_ = span[span.Length];
4343
});
4444

45-
Assert.ThrowsException(typeof(IndexOutOfRangeException), () =>
45+
Assert.ThrowsException(typeof(ArgumentOutOfRangeException), () =>
4646
{
4747
Span<byte> span = new Span<byte>(array);
4848
_ = span[-1];
@@ -197,9 +197,14 @@ public void CopyToTests()
197197
toCopy = new Span<byte>(new byte[span.Length + 1]);
198198
span.CopyTo(toCopy);
199199

200-
CollectionAssert.AreEqual(array, toCopy.ToArray(), "Original array and SpanByte.CopyTo should be the same with larger destination");
200+
Assert.AreEqual(toCopy.Length, span.Length + 1);
201+
202+
byte[] tempArray = new byte[span.Length + 1];
203+
Array.Copy(array, tempArray, array.Length);
204+
205+
CollectionAssert.AreEqual(tempArray, toCopy.ToArray(), "Original array and SpanByte.CopyTo should be the same with larger destination");
201206

202-
Assert.AreEqual(toCopy[span.Length], (byte)0, "Copied span and original array have different lenghts.");
207+
Assert.AreEqual(toCopy[toCopy.Length - 1], (byte)0, "Last byte should be 0 (byte default)");
203208
}
204209

205210
[TestMethod]

0 commit comments

Comments
 (0)