コード例 #1
0
 def test_clear_stack(self):
     stack = Stack([9])
     stack.clear()
     self.assertEqual(0, stack.count())
     self.assertEqual('', str(stack))
コード例 #2
0
 def test_create_empty_stack(self):
     stack = Stack()
     self.assertEqual('', str(stack))
コード例 #3
0
 def test_count_stack(self):
     stack = Stack([4, 9])
     self.assertEqual(2, stack.count())
コード例 #4
0
 def test_count_stack_empty_stack(self):
     stack = Stack()
     self.assertEqual(0, stack.count())
コード例 #5
0
 def test_peek_empty_stack(self):
     stack = Stack()
     with self.assertRaises(ValueError):
         stack.peek()
     self.assertEqual('', str(stack))
コード例 #6
0
 def test_peek_non_empty_stack(self):
     stack = Stack([4, 9])
     value = stack.peek()
     self.assertEqual('4, 9', str(stack))
     self.assertEqual('4', str(value))
コード例 #7
0
 def test_push_on_non_empty_stack(self):
     stack = Stack([4, 9])
     stack.push(6)
     self.assertEqual('6, 4, 9', str(stack))
コード例 #8
0
 def test_push_on_empty_stack(self):
     stack = Stack()
     stack.push(6)
     self.assertEqual('6', str(stack))
コード例 #9
0
 def test_create_stack_from_content(self):
     stack = Stack([5, 8, 9])
     self.assertEqual('5, 8, 9', str(stack))