public void CopyToArrayToSmallTest() { SingleLinkedList <int> testList = new SingleLinkedList <int>(); testList.Add(0); testList.Add(1); testList.Add(2); int[] array = new int[4]; Assert.Catch <ArgumentException>(() => testList.CopyTo(array, 2)); }
public void CopyToArrayArrayIndexTest() { SingleLinkedList <int> testList = new SingleLinkedList <int>(); testList.Add(0); testList.Add(1); testList.Add(2); int[] array = new int[4]; Assert.Catch <ArgumentOutOfRangeException>(() => testList.CopyTo(array, -1)); }
public void CopyToTest() { SingleLinkedList <int> testList = new SingleLinkedList <int>(); testList.Add(0); testList.Add(1); testList.Add(2); int[] array = new int[5]; testList.CopyTo(array, 2); Assert.AreEqual(0, array[2]); Assert.AreEqual(1, array[3]); Assert.AreEqual(2, array[4]); }
public void TestSingleLinkedList_CopyTo() { var list = new SingleLinkedList <int>(); var data = new[] { 1, 2, 3, 4, 5, 6, 7 }; foreach (var item in data) { list.Add(item); } var newData = new int[7]; list.CopyTo(newData, 0); var index = 0; foreach (var item in list) { Assert.IsTrue(item == newData[index++]); } }