Exemple #1
0
def test_empty():
    test_stack = stack()

    assert(test_stack.empty())

    test_stack.push(1)
    assert(not test_stack.empty())
Exemple #2
0
def test_size():
    test_stack = stack()

    assert(test_stack.size() == 0)

    pushed_numbers = randint(1, 20)
    for i in range(pushed_numbers):
        test_stack.push(i)
    assert(test_stack.size() == pushed_numbers)
Exemple #3
0
def test_push():
    test_stack = stack()

    test_stack.push(0)
    assert(test_stack.top() == 0)
    assert(test_stack.size() == 1)

    test_stack.push(1)
    assert(test_stack.top() == 1)
    assert(test_stack.size() == 2)
Exemple #4
0
def test_top():
    test_stack = stack()

    assert(test_stack.top() is None)

    test_stack.push(1)
    assert(test_stack.top() == 1)

    test_stack.push(2)
    assert(test_stack.top() == 2)
Exemple #5
0
def test_drop():
    test_stack = stack()

    test_stack.drop()
    assert(test_stack.empty())

    pushed_numbers = randint(10, 20)
    for i in range(pushed_numbers):
        test_stack.push(i)
    test_stack.drop()
    assert(test_stack.empty())
Exemple #6
0
def test_pop():
    test_stack = stack()

    assert(test_stack.pop() is None)
    assert(test_stack.size() == 0)

    test_stack.push(1)
    test_stack.push(5)
    assert(test_stack.pop() == 5)
    assert(test_stack.size() == 1)
    assert(test_stack.pop() == 1)
    assert(test_stack.size() == 0)
    assert(test_stack.pop() is None)