예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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]);
        }
예제 #4
0
        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++]);
            }
        }