コード例 #1
0
def test_max_with_changes():
    stack = MaxStack()

    stack.push(10)
    stack.push(50)
    stack.push(75)
    stack.push(5)

    assert stack.max() == 75

    stack.pop()
    stack.pop()

    assert stack.max() == 50
コード例 #2
0
def test_max_with_duplicates():
    stack = MaxStack()

    stack.push(10)
    stack.push(50)
    stack.push(50)

    assert stack.max() == 50

    stack.pop()

    assert stack.max() == 50

    stack.pop()

    assert stack.max() == 10
コード例 #3
0
def test_max():
    stack = MaxStack()

    stack.push(10)
    stack.push(50)
    stack.push(1)

    assert stack.max() == 50
コード例 #4
0
def test_max_no_items():
    stack = MaxStack()

    with pytest.raises(IndexError):
        stack.max()