24 lines
761 B
Python
24 lines
761 B
Python
# import sys
|
|
|
|
# sys.path.append('/home/songsenand/Project/ToyDesigner/')
|
|
|
|
from toydesigner.objects import *
|
|
|
|
|
|
def test_line():
|
|
line1 = Line((1, 3), (1, 4))
|
|
assert line1.slope() == float("inf")
|
|
assert line1.y_intercept() == 0
|
|
line2 = Line((1, 1), (2, 2))
|
|
assert line2.slope() == 1
|
|
assert line2.y_intercept() == 0
|
|
assert line2.equation() == "y = 1.0x"
|
|
line3 = Line((37, 5), (7, 29))
|
|
assert line3.slope() == -0.8
|
|
assert line3.y_intercept() == 34.6
|
|
assert line3.equation() == "y = -0.8x + 34.6"
|
|
assert (12, 25) in line3
|
|
assert (12, 12) not in line3
|
|
assert (3, 32.2) not in line3
|
|
assert line3.contains((6, 29.8), allow_on_extended=True) == True
|
|
assert line3.length()**2 == (37 - 7) ** 2 + (5 - 29) ** 2 |