Пример #1
0
        public void GapBuffer_RemoveTest()
        {
            GapBuffer <int> buf = CreateTestGapBuffer();

            Assert.IsFalse(buf.Remove(0));

            Assert.AreEqual(16, buf.IndexOf(999));
            Assert.IsTrue(buf.Remove(999));
            Assert.AreEqual(-1, buf.IndexOf(999));

            buf.RemoveAt(1);
            Assert.AreEqual(1, buf.Gap);

            buf.RemoveAt(0);
            Assert.AreEqual(23, buf.Count);
            Assert.AreEqual(0, buf.Gap);
            Assert.AreEqual(9, buf.GapCount);
            Assert.AreEqual(9, buf.AfterGap);

            buf.RemoveAt(21);
            Assert.AreEqual(21, buf.Gap);

            buf.RemoveAt(21);
            Assert.AreEqual(21, buf.Count);
            Assert.AreEqual(21, buf.Gap);
            Assert.AreEqual(11, buf.GapCount);
            Assert.AreEqual(32, buf.AfterGap);

            for (int i = 0; i < buf.Count; i++)
            {
                Assert.AreEqual(102 + i, buf[i]);
            }
        }