def test_yxOrder_withEqualYAndNotEqualXCoordinatePoints_shouldCompareByXAndReturnCorrectComparatorResult(self): for i in range(500): xa = random.uniform(0, 1000) xb = random.uniform(-1000, -1) a = Point2D(xa, 1) b = Point2D(xb, 1) self.assertEqual(1, Point2D.yx_order(a, b)) self.assertEqual(-1, Point2D.yx_order(b, a))
def test_yxOrder_withEqualsXYCoordinatePoints_shouldReturnZero(self): for i in range(500): x = random.uniform(0, 1000) y = random.uniform(0, 1000) a = Point2D(x, y) b = Point2D(x, y) self.assertEqual(0, Point2D.yx_order(a, b)) self.assertEqual(0, Point2D.yx_order(b, a))
def test_yxOrder_withNotEqualYCoordinatePoints_shouldCompareByYAndReturnCorrectComparatorResult(self): for i in range(500): ya = random.uniform(0, 1000) yb = random.uniform(-1000, -1) a = Point2D(1, ya) b = Point2D(1, yb) self.assertEqual(1, Point2D.yx_order(a, b)) self.assertEqual(-1, Point2D.yx_order(b, a))
def __init__(self, p1, p2): if p1 is None: raise ValueError("Invalid argument 'p1' of None Type") if p2 is None: raise ValueError("Invalid argument 'p2' of None Type") if Point2D.yx_order(p1, p2) < 0: self.__upper = p1 self.__lower = p2 else: self.__upper = p2 self.__lower = p1