from droite import *

def test(function, p1, p2, exp_result):
    fun_result = function(p1, p2)
    if fun_result == exp_result:
        print(f"{function.__name__}({p1}, {p2}) == {exp_result} --- SUCCESS!")
    else:
        print(f"{function.__name__}({p1}, {p2}) == {exp_result} --- ERROR! (result was:{fun_result})")


def tests():
    test(droite, (-2, 0), (1, 1.5), (-0.5, 1, 1.0))
    test(droite, (0, -3), (0, 5), (1, 0, 0))
    test(droite, (0, -1), (0, -1), None)

    test(appartient, (-0.5, 1, 1.0), (-2, 0), True)
    test(appartient, (-0.5, 1, 1.0), (1, 1.5), True)
    test(appartient, (-0.5, 1, 1.0), (0, -1), False)

    test(paralleles, (0, 1, 1), (0, 2, 3), True)
    test(paralleles, (-0.5, 1, 1.0), (0, 2, 3), False)

    test(intersection, (-0.5, 1, 1.0), (0, 2, 3), (1.0, 1.5))
    test(intersection, (0, 1, 1), (0, 2, 3), None)

    test(droite_normale, (-0.5, 1, 1.0), (-2, 0), (2.0, 1, -4.0))
    test(droite_normale, (-0.5, 1, 1.0), (3, 4), (2.0, 1, 10.0))

    test(symetrie_orthogonale, (-0.5, 1, 1.0), (-2, 0), (-2.0, 0.0))
    test(symetrie_orthogonale, (-0.5, 1, 1.0), (3, 4), (2.0, 1, 10.0))

    test(distance_droite_point, (-0.5, 1, 1.0), (-2, 0), 0.0)


if __name__ == "__main__":
    tests()