public void AsSpan_when_not_items_Added_returns_empty_span() { using var listPool = new ValueListPool <int>(10); Span <int> sut = listPool.AsSpan(); Assert.Equal(0, sut.Length); }
public void AsSpan_returns_span_for_added_items() { int[] expectedValues = s_fixture.Create <int[]>(); using var listPool = new ValueListPool <int>(expectedValues, ValueListPool <int> .SourceType.Copy); Span <int> sut = listPool.AsSpan(); Assert.Equal(expectedValues.Length, sut.Length); foreach (int expectedValue in expectedValues) { Assert.True(sut.Contains(expectedValue)); } }
public int ValueListPool_AsSpan() { int count = 0; using ValueListPool <int> list = new ValueListPool <int>(0); for (int i = 0; i < N; i++) { list.Add(i); } foreach (int item in list.AsSpan()) { count += item; } return(count); }
public void AsSpan_returns_span_for_added_items() { int[] expectedValues = s_fixture.Create <int[]>(); using var listPool = new ValueListPool <int>(expectedValues, ValueListPool <int> .SourceType.Copy); Span <int> sut = listPool.AsSpan(); Assert.Equal(expectedValues.Length, sut.Length); foreach (int expectedValue in expectedValues) { bool containsValue = false; foreach (int actualValue in sut) { if (actualValue == expectedValue) { containsValue = true; break; } } Assert.True(containsValue); } }