1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:25:43 +00:00

test: add tests for Span<T>.Count

This commit is contained in:
Oliver Booth 2023-04-02 00:18:47 +01:00
parent 586057ba3d
commit f10ff4a36c
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -6,6 +6,26 @@ namespace X10D.Tests.Collections;
[TestClass] [TestClass]
public class SpanTest public class SpanTest
{ {
[TestMethod]
public void Count_ShouldReturn0_GivenEmptySpan()
{
Span<int> span = Span<int>.Empty;
int count = span.Count(2);
Assert.AreEqual(0, count);
}
[TestMethod]
public void Count_ShouldReturn8_GivenSpanWith8MatchingElements()
{
Span<int> span = stackalloc int[16] {1, 2, 3, 2, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2};
int count = span.Count(2);
Assert.AreEqual(8, count);
}
[TestMethod] [TestMethod]
public void Split_OnEmptySpan_ShouldYieldNothing() public void Split_OnEmptySpan_ShouldYieldNothing()
{ {