Exemple #1
0
        public void Test_Not_Overflow()
        {
            var ringBuffer = new BoundedFifoBuffer <byte>(5);

            ringBuffer.Write(GetBytes("ABC"));
            ringBuffer.Write(GetBytes("DE"));
        }
Exemple #2
0
        public void Test_Single_Size_Buffer()
        {
            var ringBuffer = new BoundedFifoBuffer <byte>(1);

            for (var i = 0; i < 100; i++)
            {
                ringBuffer.Write(GetBytes("A"));
                Assert.AreEqual("A", GetString(ringBuffer.ReadToArray()));
                ringBuffer.Write(GetBytes("B"));
                Assert.AreEqual("B", GetString(ringBuffer.ReadToArray()));
            }
        }
Exemple #3
0
        public void Test_Simple_RingBuffer_Test_Read_Write_With_Dri1()
        {
            var ringBuffer = new BoundedFifoBuffer <byte>(5);

            for (var i = 0; i < 100; i++)
            {
                ringBuffer.Write(GetBytes("ABC"));
                Assert.AreEqual("ABC", GetString(ringBuffer.ReadToArray()));
                ringBuffer.Write(GetBytes("DEF"));
                Assert.AreEqual("DEF", GetString(ringBuffer.ReadToArray()));
            }
        }
Exemple #4
0
        public void Test_Read_Single_Item()
        {
            var s      = "This is a Hel\0lo teHel\0lost";
            var buffer = new BoundedFifoBuffer <byte>(1024);

            buffer.Write(Encoding.ASCII.GetBytes("BOO"));
            Assert.AreEqual('O', buffer.Last);

            buffer.Write(Encoding.ASCII.GetBytes(s));

            buffer.Read();
            buffer.Read();
            buffer.Read();

            Assert.AreEqual('t', buffer.Last);

            var t = Encoding.ASCII.GetString(buffer.PeekToArray());

            Assert.AreEqual(s, t);

            t = Encoding.ASCII.GetString(buffer.ToArray());
            Assert.AreEqual(s, t);
        }
Exemple #5
0
        public void Test_Overflow_On_Initial()
        {
            var ringBuffer = new BoundedFifoBuffer <byte>(5);

            ringBuffer.Write(GetBytes("ABCDEF"));
        }
        public void Test_Single_Size_Buffer()
        {
            var ringBuffer = new BoundedFifoBuffer<byte>(1);

            for (var i = 0; i < 100; i++)
            {
                ringBuffer.Write(GetBytes("A"));
                Assert.AreEqual("A", GetString(ringBuffer.ReadToArray()));
                ringBuffer.Write(GetBytes("B"));
                Assert.AreEqual("B", GetString(ringBuffer.ReadToArray()));
            }
        }
        public void Test_Simple_RingBuffer_Test_Read_Write_With_Drift2()
        {
            var ringBuffer = new BoundedFifoBuffer<byte>(5);

            for (var i = 0; i < 100; i++)
            {
                ringBuffer.Write(GetBytes("ABC"));
                Assert.AreEqual("ABC", GetString(ringBuffer.ReadToArray()));
                ringBuffer.Write(GetBytes("DEF"));
                Assert.AreEqual('D', ringBuffer[0]);
                Assert.AreEqual('E', ringBuffer[1]);
                Assert.AreEqual('F', ringBuffer[2]);
                ringBuffer.Clear();
            }
        }
        public void Test_Read_Single_Item()
        {
            var s = "This is a Hel\0lo teHel\0lost";
            var buffer = new BoundedFifoBuffer<byte>(1024);

            buffer.Write(Encoding.ASCII.GetBytes("BOO"));
            Assert.AreEqual('O', buffer.Last);

            buffer.Write(Encoding.ASCII.GetBytes(s));

            buffer.Read();
            buffer.Read();
            buffer.Read();

            Assert.AreEqual('t', buffer.Last);

            var t = Encoding.ASCII.GetString(buffer.PeekToArray());
            Assert.AreEqual(s, t);

            t = Encoding.ASCII.GetString(buffer.ToArray());
            Assert.AreEqual(s, t);
        }
        public void Test_Overflow_On_Initial()
        {
            var ringBuffer = new BoundedFifoBuffer<byte>(5);

            ringBuffer.Write(GetBytes("ABCDEF"));
        }
        public void Test_Not_Overflow()
        {
            var ringBuffer = new BoundedFifoBuffer<byte>(5);

            ringBuffer.Write(GetBytes("ABC"));
            ringBuffer.Write(GetBytes("DE"));
        }