Add some more tests for point class
This commit is contained in:
@@ -6,4 +6,37 @@ def test_init():
|
|||||||
pnt = point.Point(10, 20)
|
pnt = point.Point(10, 20)
|
||||||
assert pnt.get_x() == 10
|
assert pnt.get_x() == 10
|
||||||
assert pnt.get_y() == 20
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user