Hong-Phuc Bui
4 days ago 4c5ba07d9c2f044c179d3bfdd41a6f9f20691ac9
polymonial/polynomial_test.py
@@ -3,8 +3,9 @@
def test_polynomial_representation():
    c = Polynomial(5, 6, 0, -7)
    s = f'{c}'
    assert s == '5 6 0 -7'
    r = repr(c)
    s = str(c)
    print(r, s, c)
def test_evaluate():
    l = Polynomial(-12.5, 3.6)
@@ -15,14 +16,15 @@
def test_evaluate_2():
    l = Polynomial(11, 7, -5, -4, 2)
    x = 2
    rest_expected = [-3, -5, 0, 2]
    q_expected = [-3, -5, 0, 2]
    y_expected = 5
    (y, rest) = l.evaluate(x)
    (y, q) = l.evaluate(x)
    assert abs(y - y_expected) < EPSILON
    for (i, r) in enumerate( rest_expected ):
        assert abs(r - rest[i]) < EPSILON
    for (i, r) in enumerate( q_expected ):
        assert abs(r - q[i]) < EPSILON
    print(Polynomial(*q))
if __name__ == "__main__":
    test_evaluate_2()
    #test_evaluate_2()
    test_polynomial_representation()