Beispiel #1
0
        public void TestTrim()
        {
            var buf = new x2net.Buffer();

            buf.EnsureCapacity(buf.BlockSize);  // numBlocks + 1

            buf.Position = 24;

            // front <= pos
            buf.Trim();

            Assert.Equal(buf.BlockSize - 24, buf.Length);
            Assert.Equal(0, buf.Position);

            buf.Position = (int)buf.Length;

            // reset
            buf.Trim();

            Assert.Equal(0, buf.Length);
            Assert.Equal(0, buf.Position);

            buf.EnsureCapacity(buf.BlockSize);

            buf.MarkToRead(1024);
            buf.Position = 24;

            // front <= marker
            buf.Trim();

            Assert.Equal(buf.BlockSize - 1024, buf.Length);
            Assert.Equal(0, buf.Position);
        }