コード例 #1
0
 def test_push_one(self):
     stack = ArrayStack()
     stack.push(1)
     self.assertEqual(stack.list(), [1])
     self.assertEqual(stack.peek(), 1)
コード例 #2
0
 def test_peek_empty(self):
     stack = ArrayStack()
     with self.assertRaises(ValueError):
         stack.peek()
コード例 #3
0
 def test_peek_non_empty(self):
     stack = ArrayStack()
     stack.push(1)
     self.assertEqual(stack.peek(), 1)
コード例 #4
0
 def test_push_two(self):
     stack = ArrayStack()
     stack.push(1)
     stack.push(2)
     self.assertEqual(stack.list(), [1, 2])
     self.assertEqual(stack.peek(), 2)