def test_pop(self): stack = Stack(1) for i in range(10): stack.push(i) for i in range(9, 0, -1): top = stack.pop() self.assertEqual(top, i) stack.pop() self.assertRaises(NameError)
def test_push(self): stack = Stack() for i in range(10): stack.push(i) self.assertEqual(stack.top.data, i)
def test_isEmpty(self): new_stack = Stack() self.assertTrue(new_stack.isEmpty()) new_stack.push(3) self.assertFalse(new_stack.isEmpty())
def test_peak(self): stack = Stack(1) self.assertEqual(stack.peak(), 1)