Example #1
0
        public void TrimToOneTest()
        {
            foreach (var cap in new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 })
            {
                var master = new QuickList <int>(cap);
                master.Push(0);
                master.Push(1);
                master.Push(2);
                master.Push(3);
                master.Push(4);
                master.Push(5);
                master.Push(6);
                master.Push(7);
                master.Push(8);
                master.Push(9);
                master.Push(10);
                master.Push(11);
                master.Push(12);

                Assert.AreEqual(12, master.Trim(4, 4));
                var i = 4;
                foreach (var v in master)
                {
                    Assert.AreEqual(i++, v);
                }
                Assert.AreEqual(1, master.Count);
                Assert.AreEqual(5, i);
            }
        }
Example #2
0
        public void TrimBoundTest()
        {
            var master = new QuickList <int>(5);

            for (var i = 0; i < 255; i++)
            {
                master.Push(i);
            }

            Assert.AreEqual(250, master.Trim(250, 999));
            Assert.AreEqual(250, master[0]);
            Assert.AreEqual(251, master[1]);
            Assert.AreEqual(252, master[2]);
            Assert.AreEqual(253, master[3]);
            Assert.AreEqual(254, master[4]);

            master = new QuickList <int>(5);
            for (var i = 0; i < 255; i++)
            {
                master.Push(i);
            }
        }