Testing techniques
Last updated
Last updated
A stack is empty on construction.
A stack has size 0 on construction.
After n pushes to an empty stack, n > 0, the stack is not empty && its size is n.
If one pushes x then pops, the value popped is x, the size is decreased by one.
If one pushes x then peeks, the value returned is x, but the size stays the same.
If the size is n, then after n pops, the stack is empty and has a size 0.
Popping from an empty stack does throw a NoSuchElementException.
Peeking into an empty stack does throw a NoSuchElementException.
For bounded stacks only, pushing onto a full stack does throw an IllegalStateException.