public void PeekRepeats() { IQueue <int> q = new LifoQueue <int>(); q.Enqueue(123); int val = q.Peek(); Assert.AreEqual(123, val); Assert.AreEqual(1, q.Count); val = q.Peek(); Assert.AreEqual(123, val); Assert.AreEqual(1, q.Count); q.Enqueue(456); val = q.Peek(); Assert.AreEqual(456, val); Assert.AreEqual(2, q.Count); }
public void EnumeratorIsLifo() { int i; IQueue <int> q = new LifoQueue <int>(); for (i = 0; i < 100; i++) { q.Enqueue(i); } i = 99; foreach (int j in q) { Assert.AreEqual(i, j); i--; } }
public void LifoOrdering() { int i; IQueue <int> q = new LifoQueue <int>(); for (i = 0; i < 100; i++) { q.Enqueue(i); } Assert.AreEqual(100, q.Count); for (i = 99; i >= 0; i--) { int val = q.Dequeue(); Assert.AreEqual(i, val); } Assert.AreEqual(0, q.Count); }