示例#1
0
        public void CopyTo()
        {
            const int LoopCount  = 1000;
            var       list       = new List <int>();
            var       speedyList = new SpeedyList <int>();
            var       random     = new Random();

            for (int i = 0; i < LoopCount; i++)
            {
                int index = random.Next(list.Count);
                int value = random.Next(LoopCount) + 1;
                list.Insert(index, value);
                speedyList.Insert(index, value);
            }
            Assert.AreEqual(LoopCount, list.Count);
            Assert.AreEqual(list.Count, speedyList.Count);

            var array1 = new int[LoopCount];
            var array2 = new int[LoopCount];

            list.CopyTo(array1, 0);
            speedyList.CopyTo(array2, 0);

            for (int i = 0; i < LoopCount; i++)
            {
                Assert.AreNotEqual(0, array1[i]);
                Assert.AreEqual(array1[i], array2[i]);
            }
        }