public void Count01() { var cq = new CircularStack <int>(4); Assert.AreEqual(0, cq.Count()); cq.Push(1); cq.Push(1); Assert.AreEqual(2, cq.Count()); cq.Pop(); Assert.AreEqual(1, cq.Count()); cq.Pop(); Assert.AreEqual(0, cq.Count()); }
public void Clear01() { var capacity = 4; var cq = new CircularStack <int>(capacity); Assert.AreEqual(capacity, cq.Capacity()); for (int i = 0; i < 6; i++) { cq.Push(i); } Assert.AreEqual(capacity, cq.Count()); cq.Clear(); Assert.AreEqual(0, cq.Count()); for (int i = 0; i < 6; i++) { cq.Push(i); } Assert.AreEqual(capacity, cq.Count()); }
public void PeekPeekBottom01() { var capacity = 4; var cq = new CircularStack <int>(capacity); for (int i = 0; i < 6; i++) { cq.Push(i); } Assert.AreEqual(capacity, cq.Count()); Assert.AreEqual(5, cq.Peek()); Assert.AreEqual(2, cq.PeekBottom()); }
public void Pop01() { var capacity = 4; var cq = new CircularStack <int>(capacity); for (int i = 0; i < capacity; i++) { cq.Push(i); } for (int i = 0; i < capacity; i++) { Assert.AreEqual(capacity - (i + 1), cq.Pop()); Assert.AreEqual(capacity - (i + 1), cq.Count()); } Assert.Throws <InvalidOperationException>(() => cq.Pop()); }