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
1 changed files with 20 additions and 0 deletions

View File

@ -6,6 +6,26 @@ namespace X10D.Tests.Collections;
[TestClass]
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]
public void Split_OnEmptySpan_ShouldYieldNothing()
{