public void Test_RefEnumerable_Indexer_ThrowsIndexOutOfRange() { int[] array = new[] { 0, 0, 0, 0 }; Assert.ThrowsException <IndexOutOfRangeException>(() => RefEnumerable <int> .DangerousCreate(ref array[0], array.Length, 1)[-1]); Assert.ThrowsException <IndexOutOfRangeException>(() => RefEnumerable <int> .DangerousCreate(ref array[0], array.Length, 1)[array.Length]); }
public void Test_RefEnumerable_Index_Indexer(int step, int[] values) { Span <int> data = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; RefEnumerable <int> enumerable = RefEnumerable <int> .DangerousCreate(ref data[0], values.Length, step); for (int i = 1; i <= enumerable.Length; i++) { Assert.AreEqual(values[^ i], enumerable[^ i]);
public void Test_RefEnumerable_DangerousCreate_Ok(int length, int step, int[] values) { Span <int> data = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; RefEnumerable <int> enumerable = RefEnumerable <int> .DangerousCreate(ref data[0], length, step); int[] result = enumerable.ToArray(); CollectionAssert.AreEqual(result, values); }
public void Test_RefEnumerable_DangerousCreate_BelowZero(int length, int step) { _ = RefEnumerable <int> .DangerousCreate(ref Unsafe.NullRef <int>(), length, step); }