public void RingBuffer_DropElement_DoesDrop() { var rb = new RingBuffer <int>(5, RingOverflowBehavior.DropElement); Add6ELements(rb); string memoryLayout = rb.ToString(); Assert.AreEqual("1,2,3,4,5", memoryLayout); }
public void RingBuffer_AutomaticExpansion_DoesExpand() { var rb = new RingBuffer <int>(5, RingOverflowBehavior.AutomaticExpansion); Add6ELements(rb); string memoryLayout = rb.ToString(); Assert.AreEqual("1,2,3,4,5,6,0,0,0,0", memoryLayout); }
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); }
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); }