def test_push_two_then_pop(self): stack = ArrayStack() stack.push(1) stack.push(2) res = stack.pop() self.assertEqual(res, 2) self.assertEqual(stack.list(), [1])
def test_push_one(self): stack = ArrayStack() stack.push(1) self.assertEqual(stack.list(), [1]) self.assertEqual(stack.peek(), 1)
def test_push_until_full(self): stack = ArrayStack(5) for i in range(5): stack.push(i) self.assertEqual(stack.list(), [0, 1, 2, 3, 4])
def test_push_two(self): stack = ArrayStack() stack.push(1) stack.push(2) self.assertEqual(stack.list(), [1, 2]) self.assertEqual(stack.peek(), 2)