Some checks failed
continuous-integration/drone/push Build is failing
Add some more tests for point class
43 lines
997 B
Python
43 lines
997 B
Python
#!/usr/bin/python3
|
|
|
|
import point
|
|
|
|
def test_init():
|
|
pnt = point.Point(10, 20)
|
|
assert pnt.get_x() == 10
|
|
assert pnt.get_y() == 20
|
|
|
|
def test_set_coordinates():
|
|
pnt = point.Point()
|
|
pnt.set_x(123)
|
|
pnt.set_y(654)
|
|
assert pnt.get_x() == 123
|
|
assert pnt.get_y() == 654
|
|
|
|
def test_get_random():
|
|
min_x = 10
|
|
max_x = 25
|
|
min_y = 30
|
|
max_y = 50
|
|
for i in range(100):
|
|
pnt = point.get_random(min_x, max_x, min_y, max_y)
|
|
assert min_x <= pnt.get_x() <= max_x
|
|
assert min_y <= pnt.get_y() <= max_y
|
|
|
|
def test_isequal():
|
|
pnt = point.Point(123, 456)
|
|
pnt_eq = point.Point(123, 456)
|
|
pnt_diff = point.Point(456, 123)
|
|
pnt_diff_x = point.Point(321, 456)
|
|
pnt_diff_y = point.Point(123, 654)
|
|
|
|
assert pnt == pnt_eq
|
|
assert not pnt == pnt_diff
|
|
assert not pnt == pnt_diff_x
|
|
assert not pnt == pnt_diff_y
|
|
|
|
assert not pnt == pnt_eq
|
|
assert pnt != pnt_diff
|
|
assert pnt != pnt_diff_x
|
|
assert pnt != pnt_diff_y
|