예제 #1
0
def test_top_stack_empty():
    with pytest.raises(Exception):
        stack = Stack()
        expected = Exception("The stack is empty.")

        actual = stack.top()

        assert actual == expected, 'Error on test_top_stack_empty.'
예제 #2
0
def test_is_empty_true():
    stack = Stack()

    expected = True

    actual = stack.is_empty()

    assert actual == expected, 'Error on test_is_empty_true.'
예제 #3
0
def test_top_stack_not_empty():
    stack = Stack()
    value = 50
    stack.push(value)
    expected = value

    actual = stack.top()

    assert actual == expected, 'Error on test_top_stack_not_empty.'
예제 #4
0
def test_push_stack():
    stack = Stack()
    value = 50
    stack.push(value)

    expected = value

    actual = stack.min_top()

    assert actual == expected, 'Error on test_push_stack.'
예제 #5
0
def test_is_empty_false():
    stack = Stack()
    value = 50
    stack.push(value)

    expected = False

    actual = stack.is_empty()

    assert actual == expected, 'Error on test_is_empty_false.'
예제 #6
0
def test_min_stack():
    stack = Stack()
    stack.push(50)
    stack.push(100)
    stack.push(10)
    stack.push(30)

    expected = 10

    actual = stack.min()

    assert actual == expected, 'Error on test_min_stack.'
예제 #7
0
def test_top_stack():
    stack = Stack()
    value = 50
    stack.push(value)
    value = 100
    stack.push(value)
    value = 200
    stack.push(value)
    expected = value

    actual = stack.top()

    assert actual == expected, 'Error on test_top_stack.'
예제 #8
0
def test_min_stack_large():
    stack = Stack()
    stack.push(50)
    stack.push(100)
    stack.push(1000)
    stack.push(30)
    stack.push(150)
    stack.push(250)
    stack.push(5)
    stack.push(500)

    stack.pop()
    stack.pop()
    stack.pop()
    stack.pop()
    stack.pop()

    expected = 50

    actual = stack.min()

    assert actual == expected, 'Error on test_min_stack_large.'