示例#1
0
        public void LastIndexOf3()
        {
            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);

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