Improve test coverage for point.py

This commit is contained in:
2020-03-22 17:42:53 +01:00
parent 4ae3fb1a78
commit f87e59f954

View File

@@ -55,19 +55,25 @@ def test_is_equal():
assert pnt != pnt_diff_x assert pnt != pnt_diff_x
assert pnt != pnt_diff_y assert pnt != pnt_diff_y
assert not pnt == None
def test_sort_set(): def test_sort_set():
"""Test the sorting algorithm""" """Test the sorting algorithm"""
point_set = [ \ point_set = [ \
point.Point(94.01, 68.5), \ point.Point(94.01, 68.5), \
point.Point(33.08, 86.28), \ point.Point(33.08, 86.28), \
point.Point(31.97, 34.14), \ point.Point(75.56, 34.14), \
point.Point(29.46, 69.56), \
point.Point(72.76, 74.25), \ point.Point(72.76, 74.25), \
point.Point(35.42, 8.76), \ point.Point(35.42, 8.76), \
point.Point(31.44, 60.7), \ point.Point(31.44, 60.7), \
point.Point(31.97, 34.14), \
point.Point(29.46, 17.73), \ point.Point(29.46, 17.73), \
point.Point(74.33, 4.58), \ point.Point(74.33, 4.58), \
point.Point(76.13, 59.69), \ point.Point(76.13, 59.69), \
point.Point(1.37, 85.25), \ point.Point(1.37, 85.25), \
point.Point(29.46, 30.59), \
point.Point(69.69, 34.14), \
point.Point(40.71, 34.02), \ point.Point(40.71, 34.02), \
point.Point(35.18, 14.32), \ point.Point(35.18, 14.32), \
point.Point(81.29, 55.71), \ point.Point(81.29, 55.71), \
@@ -79,8 +85,12 @@ def test_sort_set():
for i in range(len(point_set) - 1): for i in range(len(point_set) - 1):
assert point_set[i].get_x() <= point_set[i + 1].get_x() assert point_set[i].get_x() <= point_set[i + 1].get_x()
if point_set[i].get_x() == point_set[i + 1].get_x():
assert point_set[i].get_y() <= point_set[i + 1].get_y()
point.sort_set(point_set, True) point.sort_set(point_set, True)
for i in range(len(point_set) - 1): for i in range(len(point_set) - 1):
assert point_set[i].get_y() <= point_set[i + 1].get_y() assert point_set[i].get_y() <= point_set[i + 1].get_y()
if point_set[i].get_y() == point_set[i + 1].get_y():
assert point_set[i].get_x() <= point_set[i + 1].get_x()