示例#1
0
        public void SetInternalArray_WithCount()
        {
            var list = new LightweightList <int>();

            list.SetInternalArray(Enumerable.Range(0, 10).ToArray(), 7);

            var span = list.AsSpan();
            var arr  = list.GetInternalArray();

            Assert.Equal(10, list.Capacity);
            Assert.Equal(10, arr.Length);

            Assert.Equal(7, list.Count);
            Assert.Equal(7, span.Length);

            for (int i = 0; i < 7; i++)
            {
                Assert.Equal(i, list[i]);
                Assert.Equal(i, span[i]);
                Assert.Equal(i, arr[i]);
            }
        }