示例#1
0
    def test_push(self):
        stack = Stack()

        stack.push(1)
        self.assertEqual(stack.stack[0], 1)

        stack.push(2)
        self.assertEqual(stack.stack[0], 2)
示例#2
0
    def test_is_empty_is_true(self):
        stack = Stack()

        self.assertTrue(stack.is_empty())
示例#3
0
    def test_peek_is_not_empty(self):
        stack = Stack()
        stack.stack = ['bananas']

        self.assertEqual('bananas', stack.peek())
示例#4
0
    def test_peek_is_empty(self):
        stack = Stack()

        self.assertIsNone(stack.peek())
示例#5
0
    def test_pop_not_empty(self):
        stack = Stack()
        stack.stack = [1, 2, 3]

        self.assertEqual(1, stack.pop())
        self.assertEqual(2, len(stack.stack))
示例#6
0
    def test_pop_empty(self):
        stack = Stack()

        self.assertIsNone(stack.pop())
示例#7
0
    def test_is_empty_is_false(self):
        stack = Stack()
        stack.stack = [1, 2, 3]

        self.assertFalse(stack.is_empty())