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

            for (int i = 0; i < 10; i++)
            {
                list.Insert(0, i);
            }

            Assert.Equal(16, list.Capacity);
            Assert.Equal(16, list.GetInternalArray().Length);

            Assert.Equal(10, list.Count);
            Assert.Equal(10, list.AsSpan().Length);

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

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