Ejemplo n.º 1
0
 def test_problem_3_5(self):
     stack = Stack.Stack()
     for i in [7, 6, 3, 5, 1, 2, 4]:
         stack.push(i)
     p_3_5.sort_stack(stack)
     for i in range(7, 0, -1):
         self.assertEqual(i, stack.pop())
Ejemplo n.º 2
0
 def test_stack(self):
     my_stack = Stack.Stack()
     for i in range(1,5):
         my_stack.push(i)
     self.assertEqual(str(my_stack), '4 3 2 1')
     self.assertEqual(my_stack.peek(), 4)
     test_array = []
     for i in range(4):
         test_array += [my_stack.pop()]
     self.assertEqual(test_array, [4, 3, 2, 1])
     self.assertEqual(my_stack.is_empty(), True)
     self.assertEqual(my_stack.pop(), None)
     self.assertEqual(my_stack.peek(), None)