예제 #1
0
def test_mul(a, b, c):
    testcalc = calc()
    testcalc.push(a)
    testcalc.push(b)
    testcalc.mul()
    r = testcalc.result()
    assert r == c
예제 #2
0
def test_sub(a, b, c):
    testcalc = calc()
    testcalc.push(a)
    testcalc.push(b)
    testcalc.sub()
    r = testcalc.result()
    assert r == c
예제 #3
0
def test_div(a, b, c):
    testcalc = calc()
    testcalc.push(a)
    testcalc.push(b)
    testcalc.div()
    r = testcalc.result()
    assert r == c
예제 #4
0
def test_add(a, b, c):
    testcalc = calc()
    testcalc.push(a)
    testcalc.push(b)
    testcalc.add()
    r = testcalc.result()
    assert r == c
예제 #5
0
def test_clear():
    testcalc = calc()
    testcalc.push(1)
    testcalc.push(2)
    testcalc.clear()
    result = len(testcalc.stack())
    assert result == 0
예제 #6
0
def test_pop():
    testcalc = calc()
    testcalc.push(1)
    testcalc.push(2)
    result = testcalc.pop()

    assert result == 2
예제 #7
0
def test_stack():
    testcalc = calc()
    testcalc.push(1)
    testcalc.push(2)
    testcalc.push(3)

    assert testcalc.stack() == [1, 2, 3]
예제 #8
0
def test_sqrt(a, c):
    testcalc = calc()
    testcalc.push(a)
    testcalc.sqrt()
    r = testcalc.result()
    assert r == c
예제 #9
0
def test_push():
    testcalc = calc()
    testcalc.push(0)
    assert testcalc.result() == 0