Exemplo n.º 1
0
 void Add5Elemenets(RingBuffer <int> rb)
 {
     rb.Add(1);
     rb.Add(2);
     rb.Add(3);
     rb.Add(4);
     rb.Add(5);
 }
Exemplo n.º 2
0
        public void RingBuffer_Count()
        {
            var rb = new RingBuffer <int>(5, RingOverflowBehavior.ThrowException);

            rb.Add(1);
            rb.Add(2);
            Assert.AreEqual(rb.Count, 2);
        }
Exemplo n.º 3
0
        public void RingBuffer_PeekHead_Peeks()
        {
            var rb = new RingBuffer <int>(5, RingOverflowBehavior.ThrowException);

            rb.Add(1);
            rb.Add(2);
            int head = rb.PeekHead;

            Assert.AreEqual(head, 1);
            string memoryLayout = rb.ToString();

            Assert.AreEqual("1,2,0,0,0", memoryLayout);
        }
Exemplo n.º 4
0
        public void RingBuffer_ThrowException_Throws()
        {
            var rb = new RingBuffer <int>(5, RingOverflowBehavior.ThrowException);

            Add5Elemenets(rb);
            Assert.Catch <System.OverflowException>(() => rb.Add(6));
        }
Exemplo n.º 5
0
        public void RingBuffer_OverrideHeadAndContinue_DoesOverride()
        {
            var rb = new RingBuffer <int>(5, RingOverflowBehavior.OverrideHeadAndContinue);

            Add6ELements(rb);
            rb.Add(7);
            string memoryLayout = rb.ToString();

            Assert.AreEqual("6,7,3,4,5", memoryLayout);
        }
Exemplo n.º 6
0
 void Add6ELements(RingBuffer <int> rb)
 {
     Add5Elemenets(rb);
     rb.Add(6);
 }