Write 3 test cases to test the operation of a stack. The test
cases should be black box test cases.
The input and output functionality that you can test for a stack
are creating an empty stack with a certain capacity, "push" an
item
on the stack, "pop" an item off of the stack, and examine the item
on the top of the stack ("top").
At least 1 of your test cases needs to test a boundrary condition
and at least 1 of your test cases
needs to test a nominal conditional. Your test cases should be
written in verbal form.
An example of a test case for a List class is the
following:
Create an empty list. Then add 3 integer elements to the list where
position 0 is a 11, position 1 is
a 21, and position 2 is a 31. Now erase position 0 of the list.
Test to see that position 0 has a 21
and position 1 has a 31.
# There can be various cases which can be tested on a stack: 1. Check empty stack: When the stack gets initialized, its size should be equals to 0. 2. Create stack and push some elements: Create a new Stack. Push 3 integers, 10, 20 and 30.. Now Check the size of stack should be 3. 3. Check the order of elements being removed: Create a new Stack. Push 3 integers, 10, 20 and 30.. Now remove the elements one by one until the stack becomes empty. The removed elements should be in order 30, 20 & 10. 4. check top method: Create a new Stack. Push 2 integers, 10, 20. The top method should return 20. The push 30. Now top method should return 30. Pop a element. The top method should now return 20 again.
************************************************** Please consider providing a thumbs up to this question if it helps you.
Get Answers For Free
Most questions answered within 1 hours.