public void InsertWorks() { var arr = new ValueArray <int>(5); for (int i = 0; i < 5; i++) { arr[i] = i + 1; } Assert.Equal(1, arr[0]); arr.Insert(0, 99); Assert.Equal(99, arr[0]); Assert.Equal(1, arr[1]); Assert.Equal(2, arr[2]); Assert.Equal(6, arr.Count); arr.Insert(1, 28); Assert.Equal(99, arr[0]); Assert.Equal(28, arr[1]); Assert.Equal(1, arr[2]); Assert.Equal(7, arr.Count); arr.Insert(7, 100); Assert.Equal(8, arr.Count); Assert.Equal(100, arr[7]); }
public void InsertFailsWhenFull() { _myArray.Count = 7; _myArray.Insert(1, 2); Assert.Throws <InvalidOperationException>(() => _myArray.Insert(2, 3)); Assert.Throws <InvalidOperationException>(() => _myArray.Insert(8, 10)); _myArray.Count = 2; Assert.Throws <IndexOutOfRangeException>(() => _myArray.Insert(7, 33)); }
public unsafe void LargerTypeWorks() { var arr = new ValueArray <Int64>(); Assert.True(sizeof(ValueArray <Int64>) > sizeof(Int64) * ValueArray <Int64> .MaximumSize); arr.Add(8589934591); arr.Add(0); arr.Insert(0, 1234567890); Assert.Equal(8589934591, arr[1]); }