Exemplo n.º 1
0
        public void TrueForAll()
        {
            const int TestCount = 1000;
            const int LoopCount = 1248;
            var       random    = new Random();

            var list       = new List <int>();
            var speedyList = new SpeedyList <int>();

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

            for (int n = 0; n < TestCount; n++)
            {
                int  checkIndex = random.Next(list.Count);
                bool result1    = list.TrueForAll(x => x < checkIndex);
                bool result2    = speedyList.TrueForAll(x => x < checkIndex);
                Assert.AreEqual(result1, result2);
            }
        }